Advertisement
BobMe

Minecraft WorldEdit Code Connection

Feb 17th, 2020
743
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let item: Item = WOODEN_PICKAXE
  2. let numbe: Number = 0
  3. let position1: Position
  4. let position2: Position
  5. let pos1place = true
  6. let pos2place = true
  7. let copy1: Position
  8. let copy2: Position
  9.  
  10. function filler(num1:Position,num2:Position,blocktype:string) {
  11.     blocks.fill(blocks.blockByName(blocktype), num1, num2, FillOperation.Replace)
  12. }
  13.  
  14. function replace(num1:Position,num2:Position,blocktype1:string,blocktype2:string) {
  15.     blocks.replace(blocks.blockByName(blocktype2), blocks.blockByName(blocktype1), num1, num2)
  16. }
  17.  
  18. function filler2(num1:Position,num2:Position,blocktype:Block) {
  19.     blocks.fill(blocktype, num1, num2, FillOperation.Replace)
  20. }
  21.  
  22. function copypaste(num1:Position,num2:Position) {
  23.     blocks.clone(num1, num2, player.position().add(pos(0,-1,0)), CloneMask.Replace, CloneMode.Normal)
  24. }
  25.  
  26. function volumer() {
  27.     let x1 = position1.getValue(Axis.X)
  28.     let y1 = position1.getValue(Axis.Y)
  29.     let z1 = position1.getValue(Axis.Z)
  30.     let x2 = position2.getValue(Axis.X)
  31.     let y2 = position2.getValue(Axis.Y)
  32.     let z2 = position2.getValue(Axis.Z)
  33.     let x = (x1-x2)+1
  34.     let y = (y1-y2)+1
  35.     let z = (z1-z2)+1
  36.     let volume = (x*z)*y
  37.     if (volume < 0) {
  38.         volume = volume * -1
  39.     }
  40.     return (volume)
  41. }
  42.  
  43. player.onItemInteracted(item, function () {
  44.     if (numbe == 0) {
  45.         numbe = 1
  46.         if (position1 != null) {
  47.             if (pos1place == true) {
  48.                 filler(position1,position1,"AIR")
  49.             } else {
  50.                 pos1place = true
  51.             }
  52.             position1 = player.position().add(pos(0,-1,0))
  53.             filler2(position1,position1,BLUE_STAINED_GLASS)
  54.             player.say("§9§lPosition 1 set: §f("+position1+")")
  55.         } else {
  56.             position1 = player.position().add(pos(0,-1,0))
  57.             filler2(position1,position1,BLUE_STAINED_GLASS)
  58.             player.say("§9§lPosition 1 set: §f("+position1+")")
  59.         }
  60.     } else {
  61.         numbe = 0
  62.         if (position2 != null) {
  63.            if (pos2place == true) {
  64.                 filler(position2,position2,"AIR")
  65.             } else {
  66.                 pos2place = true
  67.             }
  68.             position2 = player.position().add(pos(0,-1,0))
  69.             filler2(position2,position2,MAGENTA_STAINED_GLASS)
  70.             player.say("§9§lPosition 2 set: §f("+position2+")")
  71.         } else {
  72.             position2 = player.position().add(pos(0,-1,0))
  73.             filler2(position2,position2,MAGENTA_STAINED_GLASS)
  74.             player.say("§9§lPosition 2 set: §f("+position2+")")
  75.         }
  76.     }
  77. })
  78.  
  79. player.onChat(";fill", function () {
  80.     if (position1 != null && position2 != null) {
  81.         pos1place = false
  82.         pos2place = false
  83.         let block:string = player.getChatArg(0)
  84.         let volume = volumer()
  85.         if (volume < 0) {
  86.             volume = volume * -1
  87.         }
  88.         if (volume != 1) {
  89.             player.say("§9§lFilled §7"+volume+"§9 blocks")
  90.         } else {
  91.             player.say("§9§lFilled §7"+volume+"§9 block")
  92.         }
  93.         filler(position1,position2,block)
  94.     } else {
  95.         player.say("§4§lPositions must be set first!")
  96.     }
  97. })
  98.  
  99. player.onChat(";replace", function () {
  100.     if (position1 != null && position2 != null) {
  101.         pos1place = false
  102.         pos2place = false
  103.         let block1:string = player.getChatArg(0)
  104.         let block2:string = player.getChatArg(1)
  105.     let volume = volumer()
  106.         if (volume < 0) {
  107.             volume = volume * -1
  108.         }
  109.         if (volume != 1) {
  110.             player.say("§9§lReplaced a zone of §7"+volume+"§9 blocks")
  111.         } else {
  112.             player.say("§9§lReplaced a zone of §7"+volume+"§9 block")
  113.         }
  114.         replace(position1,position2,block1,block2)
  115.         blocks.place(blocks.blockByName(block2), position1)
  116.         blocks.place(blocks.blockByName(block2), position2)
  117.     } else {
  118.         player.say("§4§lPositions must be set first!")
  119.     }
  120. })
  121.  
  122. player.onChat(";copy", function () {
  123.     if (position1 != null && position2 != null) {
  124.         copy1 = position1
  125.         copy2 = position2
  126.         let volume = volumer()
  127.        if (volume != 1) {
  128.             player.say("§9§lCopied a zone of §7"+volume+"§9 blocks")
  129.         } else {
  130.             player.say("§9§lCopied a zone of §7"+volume+"§9 block")
  131.         }
  132.     } else {
  133.         player.say("§4§lPositions must be set first!")
  134.     }
  135. })
  136.  
  137. player.onChat(";paste", function () {
  138.     if (copy1 != null) {
  139.         blocks.place(blocks.blockByName("AIR"), position1)
  140.         blocks.place(blocks.blockByName("AIR"), position2)
  141.         copypaste(copy1,copy2)
  142.         player.say("§9§lZone pasted")
  143.     } else {
  144.         player.say("§4§lYou must copy a selection first!")
  145.     }
  146. })
  147.  
  148. player.onChat(";destroy", function () {
  149.     if (position1 != null && position2 != null) {
  150.         pos1place = false
  151.         pos2place = false
  152.         let volume = volumer()
  153.         if (volume < 0) {
  154.             volume = volume * -1
  155.         }
  156.         if (volume != 1) {
  157.             player.say("§9§lDestroyed §7"+volume+"§9 blocks")
  158.         } else {
  159.             player.say("§9§lDestroyed §7"+volume+"§9 block")
  160.         }
  161.         filler(position1,position2,"AIR")
  162.     } else {
  163.         player.say("§4§lPositions must be set first!")
  164.     }
  165. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement