Advertisement
BobMe

Minecraft Code Connection - World Edit (revamped)

Jul 9th, 2021
2,154
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.     let max = 30
  12.     let distanceX = Math.abs(num1.getValue(Axis.X) - num2.getValue(Axis.X))
  13.     let distanceY = Math.abs(num1.getValue(Axis.Y) - num2.getValue(Axis.Y))
  14.     let distanceZ = Math.abs(num1.getValue(Axis.Z) - num2.getValue(Axis.Z))
  15.     let iX = Math.floor(distanceX/max) + 1
  16.     let iXR = distanceX%max
  17.     let iY = Math.floor(distanceY/max) + 1
  18.     let iYR = distanceY%max
  19.     let iZ = Math.floor(distanceZ/max) + 1
  20.     let iZR = distanceZ%max
  21.     let yNegative = (num1.getValue(Axis.Y) > num2.getValue(Axis.Y))
  22.     let xNegative = (num1.getValue(Axis.X) > num2.getValue(Axis.X))
  23.     let zNegative = (num1.getValue(Axis.Z) > num2.getValue(Axis.Z))
  24.     let yCurrent = num1.getValue(Axis.Y)
  25.     let xCurrent = num1.getValue(Axis.X)
  26.     let zCurrent = num1.getValue(Axis.Z)
  27.     let yPast = yCurrent
  28.     let xPast = xCurrent
  29.     let zPast = zCurrent
  30.     for (let y = 0; y < iY; y++) {
  31.         yPast = yCurrent
  32.         if (Math.abs(yCurrent - num2.getValue(Axis.Y)) >= max) {
  33.             if (yNegative == false) {
  34.                 yCurrent += max
  35.             } else {
  36.                 yCurrent -= max
  37.             }
  38.         } else {
  39.             yCurrent = num2.getValue(Axis.Y)
  40.         }
  41.         for (let x = 0; x < iX; x++) {
  42.             xPast = xCurrent
  43.             if (Math.abs(xCurrent - num2.getValue(Axis.X)) >= max) {
  44.                 if (xNegative == false) {
  45.                     xCurrent += max
  46.                 } else {
  47.                     xCurrent -= max
  48.                 }
  49.             } else {
  50.                 xCurrent = num2.getValue(Axis.X)
  51.             }
  52.             for (let z = 0; z < iZ; z++) {
  53.                 zPast = zCurrent
  54.                 if (Math.abs(zCurrent - num2.getValue(Axis.Z)) >= max) {
  55.                     if (zNegative == false) {
  56.                         zCurrent += max
  57.                     } else {
  58.                         zCurrent -= max
  59.                     }
  60.                 } else {
  61.                     zCurrent = num2.getValue(Axis.Z)
  62.                 }
  63.                 builder.teleportTo(world(xPast,yPast,zPast))
  64.                 builder.mark()
  65.                 builder.teleportTo(world(xCurrent,yCurrent,zCurrent))
  66.                 builder.fill(blocks.blockByName(blocktype))
  67.             }
  68.             zCurrent = num1.getValue(Axis.Z)
  69.             zPast = zCurrent
  70.         }
  71.         xCurrent = num1.getValue(Axis.X)
  72.         xPast = xCurrent
  73.     }
  74. }
  75.  
  76. function replace(num1:Position,num2:Position,blocktype1:string,blocktype2:string) {
  77.     let max = 30
  78.     let distanceX = Math.abs(num1.getValue(Axis.X) - num2.getValue(Axis.X))
  79.     let distanceY = Math.abs(num1.getValue(Axis.Y) - num2.getValue(Axis.Y))
  80.     let distanceZ = Math.abs(num1.getValue(Axis.Z) - num2.getValue(Axis.Z))
  81.     let iX = Math.floor(distanceX/max) + 1
  82.     let iXR = distanceX%max
  83.     let iY = Math.floor(distanceY/max) + 1
  84.     let iYR = distanceY%max
  85.     let iZ = Math.floor(distanceZ/max) + 1
  86.     let iZR = distanceZ%max
  87.     let yNegative = (num1.getValue(Axis.Y) > num2.getValue(Axis.Y))
  88.     let xNegative = (num1.getValue(Axis.X) > num2.getValue(Axis.X))
  89.     let zNegative = (num1.getValue(Axis.Z) > num2.getValue(Axis.Z))
  90.     let yCurrent = num1.getValue(Axis.Y)
  91.     let xCurrent = num1.getValue(Axis.X)
  92.     let zCurrent = num1.getValue(Axis.Z)
  93.     let yPast = yCurrent
  94.     let xPast = xCurrent
  95.     let zPast = zCurrent
  96.     for (let y = 0; y < iY; y++) {
  97.         yPast = yCurrent
  98.         if (Math.abs(yCurrent - num2.getValue(Axis.Y)) >= max) {
  99.             if (yNegative == false) {
  100.                 yCurrent += max
  101.             } else {
  102.                 yCurrent -= max
  103.             }
  104.         } else {
  105.             yCurrent = num2.getValue(Axis.Y)
  106.         }
  107.         for (let x = 0; x < iX; x++) {
  108.             xPast = xCurrent
  109.             if (Math.abs(xCurrent - num2.getValue(Axis.X)) >= max) {
  110.                 if (xNegative == false) {
  111.                     xCurrent += max
  112.                 } else {
  113.                     xCurrent -= max
  114.                 }
  115.             } else {
  116.                 xCurrent = num2.getValue(Axis.X)
  117.             }
  118.             for (let z = 0; z < iZ; z++) {
  119.                 zPast = zCurrent
  120.                 if (Math.abs(zCurrent - num2.getValue(Axis.Z)) >= max) {
  121.                     if (zNegative == false) {
  122.                         zCurrent += max
  123.                     } else {
  124.                         zCurrent -= max
  125.                     }
  126.                 } else {
  127.                     zCurrent = num2.getValue(Axis.Z)
  128.                 }
  129.                 blocks.replace(blocks.blockByName(blocktype2), blocks.blockByName(blocktype1), world(xPast,yPast,zPast), world(xCurrent,yCurrent,zCurrent))
  130.             }
  131.             zCurrent = num1.getValue(Axis.Z)
  132.             zPast = zCurrent
  133.         }
  134.         xCurrent = num1.getValue(Axis.X)
  135.         xPast = xCurrent
  136.     }
  137. }
  138.  
  139. function walls(num1:Position,num2:Position,blocktype:string) {
  140.     let pos1 = world(num2.getValue(Axis.X),num2.getValue(Axis.Y),num1.getValue(Axis.Z)) // orange
  141.     let pos2 = world(num1.getValue(Axis.X),num1.getValue(Axis.Y),num2.getValue(Axis.Z)) // yellow
  142.     let pos3 = world(num1.getValue(Axis.X),num2.getValue(Axis.Y),num1.getValue(Axis.Z)) // green
  143.     let pos4 = world(num2.getValue(Axis.X),num1.getValue(Axis.Y),num2.getValue(Axis.Z)) // purple
  144.     filler(num1,pos1,blocktype)
  145.     filler(pos1,pos4,blocktype)
  146.     filler(num2,pos2,blocktype)
  147.     filler(pos2,pos3,blocktype)
  148. }
  149.  
  150. function floor(num1:Position,num2:Position,blocktype:string) {
  151.     let gag:any = null
  152.     if (num1.getValue(Axis.Y) <= num2.getValue(Axis.Y)) {
  153.         gag = num1.getValue(Axis.Y)
  154.     } else {
  155.         gag = num2.getValue(Axis.Y)
  156.     }
  157.     filler(world(num1.getValue(Axis.X),gag,num1.getValue(Axis.Z)),world(num2.getValue(Axis.X),gag,num2.getValue(Axis.Z)),blocktype)
  158. }
  159.  
  160. function ceiling(num1:Position,num2:Position,blocktype:string) {
  161.     let gag:any = null
  162.     if (num1.getValue(Axis.Y) >= num2.getValue(Axis.Y)) {
  163.         gag = num1.getValue(Axis.Y)
  164.     } else {
  165.         gag = num2.getValue(Axis.Y)
  166.     }
  167.     filler(world(num1.getValue(Axis.X),gag,num1.getValue(Axis.Z)),world(num2.getValue(Axis.X),gag,num2.getValue(Axis.Z)),blocktype)
  168. }
  169.  
  170. function filler2(num1:Position,num2:Position,blocktype:Block) {
  171.     blocks.fill(blocktype, num1, num2, FillOperation.Replace)
  172. }
  173.  
  174. function copypaste(num1:Position,num2:Position) {
  175.     blocks.clone(num1, num2, player.position().add(pos(0,-1,0)), CloneMask.Replace, CloneMode.Normal)
  176. }
  177.  
  178. function volumer() {
  179.     let x1 = position1.getValue(Axis.X)
  180.     let y1 = position1.getValue(Axis.Y)
  181.     let z1 = position1.getValue(Axis.Z)
  182.     let x2 = position2.getValue(Axis.X)
  183.     let y2 = position2.getValue(Axis.Y)
  184.     let z2 = position2.getValue(Axis.Z)
  185.     let x = (x1-x2)+1
  186.     let y = (y1-y2)+1
  187.     let z = (z1-z2)+1
  188.     let volume = (x*z)*y
  189.     if (volume < 0) {
  190.         volume = volume * -1
  191.     }
  192.     return (volume)
  193. }
  194.  
  195. player.onItemInteracted(item, function () {
  196.     if (numbe == 0) {
  197.         numbe = 1
  198.         if (position1 != null) {
  199.             if (pos1place == true) {
  200.                 filler(position1,position1,"AIR")
  201.             } else {
  202.                 pos1place = true
  203.             }
  204.             position1 = player.position().add(pos(0,-1,0))
  205.             filler2(position1,position1,BLUE_STAINED_GLASS)
  206.             player.say("§9§lPosition 1 set: §f("+position1+")")
  207.         } else {
  208.             position1 = player.position().add(pos(0,-1,0))
  209.             filler2(position1,position1,BLUE_STAINED_GLASS)
  210.             player.say("§9§lPosition 1 set: §f("+position1+")")
  211.         }
  212.     } else {
  213.         numbe = 0
  214.         if (position2 != null) {
  215.            if (pos2place == true) {
  216.                 filler(position2,position2,"AIR")
  217.             } else {
  218.                 pos2place = true
  219.             }
  220.             position2 = player.position().add(pos(0,-1,0))
  221.             filler2(position2,position2,MAGENTA_STAINED_GLASS)
  222.             player.say("§d§lPosition 2 set: §f("+position2+")")
  223.         } else {
  224.             position2 = player.position().add(pos(0,-1,0))
  225.             filler2(position2,position2,MAGENTA_STAINED_GLASS)
  226.             player.say("§d§lPosition 2 set: §f("+position2+")")
  227.         }
  228.     }
  229. })
  230.  
  231. player.onChat(";fill", function (num1:Number) {
  232.     if (position1 != null && position2 != null) {
  233.         pos1place = false
  234.         pos2place = false
  235.         let block:string = player.getChatArg(0)
  236.         let volume = volumer()
  237.         if (volume < 0) {
  238.             volume = volume * -1
  239.         }
  240.         if (volume > 3600*5) {
  241.             if (volume != 1) {
  242.                 player.say("§9§lFilling §7"+volume+"§9 blocks...")
  243.             } else {
  244.                 player.say("§9§lFilling §7"+volume+"§9 block...")
  245.             }
  246.             filler(position1,position2,block)
  247.             player.say("§a§lDone!")
  248.         } else {
  249.             filler(position1,position2,block)
  250.             if (volume != 1) {
  251.                 player.say("§9§lFilled §7"+volume+"§9 blocks")
  252.             } else {
  253.                 player.say("§9§lFilled §7"+volume+"§9 block")
  254.             }
  255.         }
  256.     } else {
  257.         player.say("§4§lPositions must be set first!")
  258.     }
  259. })
  260.  
  261. player.onChat(";replace", function (num1:Number,num2:Number) {
  262.     if (position1 != null && position2 != null) {
  263.         pos1place = false
  264.         pos2place = false
  265.         let block1:string = player.getChatArg(0)
  266.         let block2:string = player.getChatArg(1)
  267.         let volume = volumer()
  268.         if (volume < 0) {
  269.             volume = volume * -1
  270.         }
  271.         if (volume > 3600*5) {
  272.             if (volume != 1) {
  273.                 player.say("§9§lReplacing §7"+volume+"§9 blocks...")
  274.             } else {
  275.                 player.say("§9§lReplacing §7"+volume+"§9 block...")
  276.             }
  277.             replace(position1,position2,block1,block2)
  278.             player.say("§a§lDone!")
  279.         } else {
  280.             replace(position1,position2,block1,block2)
  281.             if (volume != 1) {
  282.                 player.say("§9§lReplaced §7"+volume+"§9 blocks")
  283.             } else {
  284.                 player.say("§9§lReplaced §7"+volume+"§9 block")
  285.             }
  286.         }
  287.     } else {
  288.         player.say("§4§lPositions must be set first!")
  289.     }
  290. })
  291.  
  292. player.onChat(";copy", function () {
  293.     if (position1 != null && position2 != null) {
  294.         copy1 = position1
  295.         copy2 = position2
  296.         let volume = volumer()
  297.        if (volume != 1) {
  298.             player.say("§9§lCopied a zone of §7"+volume+"§9 blocks")
  299.         } else {
  300.             player.say("§9§lCopied a zone of §7"+volume+"§9 block")
  301.         }
  302.     } else {
  303.         player.say("§4§lPositions must be set first!")
  304.     }
  305. })
  306.  
  307. player.onChat(";paste", function () {
  308.     if (copy1 != null) {
  309.         blocks.place(blocks.blockByName("AIR"), position1)
  310.         blocks.place(blocks.blockByName("AIR"), position2)
  311.         copypaste(copy1,copy2)
  312.         player.say("§9§lZone pasted")
  313.     } else {
  314.         player.say("§4§lYou must copy a selection first!")
  315.     }
  316. })
  317.  
  318. player.onChat(";destroy", function () {
  319.     if (position1 != null && position2 != null) {
  320.         pos1place = false
  321.         pos2place = false
  322.         let volume = volumer()
  323.         if (volume < 0) {
  324.             volume = volume * -1
  325.         }
  326.         if (volume > 3600*5) {
  327.             if (volume != 1) {
  328.                 player.say("§9§lDestroying §7"+volume+"§9 blocks...")
  329.             } else {
  330.                 player.say("§9§lDestroying §7"+volume+"§9 block...")
  331.             }
  332.             filler(position1,position2,"AIR")
  333.             player.say("§a§lDone!")
  334.         } else {
  335.             filler(position1,position2,"AIR")
  336.             if (volume != 1) {
  337.                 player.say("§9§lDestroyed §7"+volume+"§9 blocks")
  338.             } else {
  339.                 player.say("§9§lDestroyed §7"+volume+"§9 block")
  340.             }
  341.         }
  342.     } else {
  343.         player.say("§4§lPositions must be set first!")
  344.     }
  345. })
  346.  
  347. player.onChat(";walls", function (num:Number) {
  348.     if (position1 != null && position2 != null) {
  349.         pos1place = false
  350.         pos2place = false
  351.         let block1:string = player.getChatArg(0)
  352.         walls(position1,position2,block1)
  353.         player.say("§9§lWalls made")
  354.     } else {
  355.         player.say("§4§lPositions must be set first!")
  356.     }
  357. })
  358.  
  359. player.onChat(";floor", function (num:Number) {
  360.     if (position1 != null && position2 != null) {
  361.         pos1place = false
  362.         pos2place = false
  363.         let block1:string = player.getChatArg(0)
  364.         floor(position1,position2,block1)
  365.         player.say("§9§lFloor made")
  366.     } else {
  367.         player.say("§4§lPositions must be set first!")
  368.     }
  369. })
  370.  
  371. player.onChat(";ceiling", function (num:Number) {
  372.     if (position1 != null && position2 != null) {
  373.         pos1place = false
  374.         pos2place = false
  375.         let block1:string = player.getChatArg(0)
  376.         ceiling(position1,position2,block1)
  377.         player.say("§9§lCeling made")
  378.     } else {
  379.         player.say("§4§lPositions must be set first!")
  380.     }
  381. })
  382.  
  383. player.onChat(";box", function (num:Number) {
  384.     if (position1 != null && position2 != null) {
  385.         pos1place = false
  386.         pos2place = false
  387.         let block1:string = player.getChatArg(0)
  388.         walls(position1,position2,block1)
  389.         floor(position1,position2,block1)
  390.         ceiling(position1,position2,block1)
  391.         player.say("§9§lBox made")
  392.     } else {
  393.         player.say("§4§lPositions must be set first!")
  394.     }
  395. })
  396.  
  397. player.onChat(";removenodes", function () {
  398.     if (position1 != null && position2 != null) {
  399.         pos1place = false
  400.         pos2place = false
  401.         blocks.place(AIR, position1)
  402.         blocks.place(AIR, position2)
  403.         player.say("§9§lNodes destroyed")
  404.     } else {
  405.         player.say("§4§lPositions must be set first!")
  406.     }
  407. })
  408.  
  409. player.onChat(";node1", function () {
  410.     if (position1 != null && position2 != null) {
  411.         pos1place = false
  412.         pos2place = false
  413.         player.teleport(position1.add(pos(0,2,0)))
  414.         player.say("§9§lTeleported to Position 1")
  415.     } else {
  416.         player.say("§4§lPositions must be set first!")
  417.     }
  418. })
  419.  
  420. player.onChat(";node2", function () {
  421.     if (position1 != null && position2 != null) {
  422.         pos1place = false
  423.         pos2place = false
  424.         player.teleport(position2.add(pos(0,2,0)))
  425.         player.say("§d§lTeleported to Position 2")
  426.     } else {
  427.         player.say("§4§lPositions must be set first!")
  428.     }
  429. })
  430.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement