Advertisement
BobMe

VAULTS: Minecraft Code Connection

Feb 25th, 2020
482
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. // WARNING: RE-RUNNING THIS SCRIPT WITH THINGS ALREADY IN YOUR VAULT WILL
  2. // RESULT IN YOU LOSING YOUR ITEMS. BE CAREFUL!
  3. //
  4. // RUN ;vault BEFORE REBOOTING THE SCRIPT
  5.  
  6. let vault_position: Position = positions.groundPosition(player.position().add(pos(-1,1,0)))
  7. player.say("§c§lVault is now visible.")
  8. blocks.place(CHEST,vault_position)
  9. let vault_enabled = true
  10. let vault_called = false
  11.  
  12. player.onChat(";vault", function () {
  13. vault_called = true
  14. })
  15.  
  16. loops.forever(function () {
  17. let ppos = player.position()
  18. let x = vault_position.getValue(Axis.X) - ppos.getValue(Axis.X)
  19. let z = vault_position.getValue(Axis.Z) - ppos.getValue(Axis.Z)
  20. if (x < 0) {
  21. x = x * -1
  22. }
  23. if (z < 0) {
  24. z = z * -1
  25. }
  26. if (x + z > 16 && vault_enabled == true && vault_called == false) {
  27. vault_enabled = false
  28. player.say("§e§lVault has been safely stored.")
  29. blocks.clone(vault_position, vault_position, world(ppos.getValue(Axis.X),1,ppos.getValue(Axis.Z)), CloneMask.Replace, CloneMode.Normal)
  30. blocks.place(AIR, vault_position)
  31. vault_position = world(ppos.getValue(Axis.X),1,ppos.getValue(Axis.Z))
  32. } else if (x+z > 150 && vault_enabled == false && vault_called == false) {
  33. blocks.clone(vault_position, vault_position, world(ppos.getValue(Axis.X),1,ppos.getValue(Axis.Z)), CloneMask.Replace, CloneMode.Normal)
  34. blocks.place(BEDROCK, vault_position)
  35. vault_position = world(ppos.getValue(Axis.X),1,ppos.getValue(Axis.Z))
  36. player.say("§7§lVault automatically moved: ("+vault_position+")")
  37. } else if (vault_called == true) {
  38. vault_enabled = true
  39. vault_called = false
  40. let poss = positions.groundPosition(player.position().add(pos(-1,1,0)))
  41. blocks.clone(vault_position,vault_position, poss, CloneMask.Replace, CloneMode.Normal)
  42. if (vault_position.getValue(Axis.Y) == 1) {
  43. blocks.place(BEDROCK,vault_position)
  44. } else {
  45. blocks.place(AIR,vault_position)
  46. }
  47. player.say("§c§lVault is now visible.")
  48. vault_position = poss
  49. }
  50. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement