Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let item: Item = WOODEN_PICKAXE
- let numbe: Number = 0
- let position1: Position
- let position2: Position
- let pos1place = true
- let pos2place = true
- let copy1: Position
- let copy2: Position
- function filler(num1:Position,num2:Position,blocktype:string) {
- let max = 30
- let distanceX = Math.abs(num1.getValue(Axis.X) - num2.getValue(Axis.X))
- let distanceY = Math.abs(num1.getValue(Axis.Y) - num2.getValue(Axis.Y))
- let distanceZ = Math.abs(num1.getValue(Axis.Z) - num2.getValue(Axis.Z))
- let iX = Math.floor(distanceX/max) + 1
- let iXR = distanceX%max
- let iY = Math.floor(distanceY/max) + 1
- let iYR = distanceY%max
- let iZ = Math.floor(distanceZ/max) + 1
- let iZR = distanceZ%max
- let yNegative = (num1.getValue(Axis.Y) > num2.getValue(Axis.Y))
- let xNegative = (num1.getValue(Axis.X) > num2.getValue(Axis.X))
- let zNegative = (num1.getValue(Axis.Z) > num2.getValue(Axis.Z))
- let yCurrent = num1.getValue(Axis.Y)
- let xCurrent = num1.getValue(Axis.X)
- let zCurrent = num1.getValue(Axis.Z)
- let yPast = yCurrent
- let xPast = xCurrent
- let zPast = zCurrent
- for (let y = 0; y < iY; y++) {
- yPast = yCurrent
- if (Math.abs(yCurrent - num2.getValue(Axis.Y)) >= max) {
- if (yNegative == false) {
- yCurrent += max
- } else {
- yCurrent -= max
- }
- } else {
- yCurrent = num2.getValue(Axis.Y)
- }
- for (let x = 0; x < iX; x++) {
- xPast = xCurrent
- if (Math.abs(xCurrent - num2.getValue(Axis.X)) >= max) {
- if (xNegative == false) {
- xCurrent += max
- } else {
- xCurrent -= max
- }
- } else {
- xCurrent = num2.getValue(Axis.X)
- }
- for (let z = 0; z < iZ; z++) {
- zPast = zCurrent
- if (Math.abs(zCurrent - num2.getValue(Axis.Z)) >= max) {
- if (zNegative == false) {
- zCurrent += max
- } else {
- zCurrent -= max
- }
- } else {
- zCurrent = num2.getValue(Axis.Z)
- }
- builder.teleportTo(world(xPast,yPast,zPast))
- builder.mark()
- builder.teleportTo(world(xCurrent,yCurrent,zCurrent))
- builder.fill(blocks.blockByName(blocktype))
- }
- zCurrent = num1.getValue(Axis.Z)
- zPast = zCurrent
- }
- xCurrent = num1.getValue(Axis.X)
- xPast = xCurrent
- }
- }
- function replace(num1:Position,num2:Position,blocktype1:string,blocktype2:string) {
- let max = 30
- let distanceX = Math.abs(num1.getValue(Axis.X) - num2.getValue(Axis.X))
- let distanceY = Math.abs(num1.getValue(Axis.Y) - num2.getValue(Axis.Y))
- let distanceZ = Math.abs(num1.getValue(Axis.Z) - num2.getValue(Axis.Z))
- let iX = Math.floor(distanceX/max) + 1
- let iXR = distanceX%max
- let iY = Math.floor(distanceY/max) + 1
- let iYR = distanceY%max
- let iZ = Math.floor(distanceZ/max) + 1
- let iZR = distanceZ%max
- let yNegative = (num1.getValue(Axis.Y) > num2.getValue(Axis.Y))
- let xNegative = (num1.getValue(Axis.X) > num2.getValue(Axis.X))
- let zNegative = (num1.getValue(Axis.Z) > num2.getValue(Axis.Z))
- let yCurrent = num1.getValue(Axis.Y)
- let xCurrent = num1.getValue(Axis.X)
- let zCurrent = num1.getValue(Axis.Z)
- let yPast = yCurrent
- let xPast = xCurrent
- let zPast = zCurrent
- for (let y = 0; y < iY; y++) {
- yPast = yCurrent
- if (Math.abs(yCurrent - num2.getValue(Axis.Y)) >= max) {
- if (yNegative == false) {
- yCurrent += max
- } else {
- yCurrent -= max
- }
- } else {
- yCurrent = num2.getValue(Axis.Y)
- }
- for (let x = 0; x < iX; x++) {
- xPast = xCurrent
- if (Math.abs(xCurrent - num2.getValue(Axis.X)) >= max) {
- if (xNegative == false) {
- xCurrent += max
- } else {
- xCurrent -= max
- }
- } else {
- xCurrent = num2.getValue(Axis.X)
- }
- for (let z = 0; z < iZ; z++) {
- zPast = zCurrent
- if (Math.abs(zCurrent - num2.getValue(Axis.Z)) >= max) {
- if (zNegative == false) {
- zCurrent += max
- } else {
- zCurrent -= max
- }
- } else {
- zCurrent = num2.getValue(Axis.Z)
- }
- blocks.replace(blocks.blockByName(blocktype2), blocks.blockByName(blocktype1), world(xPast,yPast,zPast), world(xCurrent,yCurrent,zCurrent))
- }
- zCurrent = num1.getValue(Axis.Z)
- zPast = zCurrent
- }
- xCurrent = num1.getValue(Axis.X)
- xPast = xCurrent
- }
- }
- function walls(num1:Position,num2:Position,blocktype:string) {
- let pos1 = world(num2.getValue(Axis.X),num2.getValue(Axis.Y),num1.getValue(Axis.Z)) // orange
- let pos2 = world(num1.getValue(Axis.X),num1.getValue(Axis.Y),num2.getValue(Axis.Z)) // yellow
- let pos3 = world(num1.getValue(Axis.X),num2.getValue(Axis.Y),num1.getValue(Axis.Z)) // green
- let pos4 = world(num2.getValue(Axis.X),num1.getValue(Axis.Y),num2.getValue(Axis.Z)) // purple
- filler(num1,pos1,blocktype)
- filler(pos1,pos4,blocktype)
- filler(num2,pos2,blocktype)
- filler(pos2,pos3,blocktype)
- }
- function floor(num1:Position,num2:Position,blocktype:string) {
- let gag:any = null
- if (num1.getValue(Axis.Y) <= num2.getValue(Axis.Y)) {
- gag = num1.getValue(Axis.Y)
- } else {
- gag = num2.getValue(Axis.Y)
- }
- filler(world(num1.getValue(Axis.X),gag,num1.getValue(Axis.Z)),world(num2.getValue(Axis.X),gag,num2.getValue(Axis.Z)),blocktype)
- }
- function ceiling(num1:Position,num2:Position,blocktype:string) {
- let gag:any = null
- if (num1.getValue(Axis.Y) >= num2.getValue(Axis.Y)) {
- gag = num1.getValue(Axis.Y)
- } else {
- gag = num2.getValue(Axis.Y)
- }
- filler(world(num1.getValue(Axis.X),gag,num1.getValue(Axis.Z)),world(num2.getValue(Axis.X),gag,num2.getValue(Axis.Z)),blocktype)
- }
- function filler2(num1:Position,num2:Position,blocktype:Block) {
- blocks.fill(blocktype, num1, num2, FillOperation.Replace)
- }
- function copypaste(num1:Position,num2:Position) {
- blocks.clone(num1, num2, player.position().add(pos(0,-1,0)), CloneMask.Replace, CloneMode.Normal)
- }
- function volumer() {
- let x1 = position1.getValue(Axis.X)
- let y1 = position1.getValue(Axis.Y)
- let z1 = position1.getValue(Axis.Z)
- let x2 = position2.getValue(Axis.X)
- let y2 = position2.getValue(Axis.Y)
- let z2 = position2.getValue(Axis.Z)
- let x = (x1-x2)+1
- let y = (y1-y2)+1
- let z = (z1-z2)+1
- let volume = (x*z)*y
- if (volume < 0) {
- volume = volume * -1
- }
- return (volume)
- }
- player.onItemInteracted(item, function () {
- if (numbe == 0) {
- numbe = 1
- if (position1 != null) {
- if (pos1place == true) {
- filler(position1,position1,"AIR")
- } else {
- pos1place = true
- }
- position1 = player.position().add(pos(0,-1,0))
- filler2(position1,position1,BLUE_STAINED_GLASS)
- player.say("§9§lPosition 1 set: §f("+position1+")")
- } else {
- position1 = player.position().add(pos(0,-1,0))
- filler2(position1,position1,BLUE_STAINED_GLASS)
- player.say("§9§lPosition 1 set: §f("+position1+")")
- }
- } else {
- numbe = 0
- if (position2 != null) {
- if (pos2place == true) {
- filler(position2,position2,"AIR")
- } else {
- pos2place = true
- }
- position2 = player.position().add(pos(0,-1,0))
- filler2(position2,position2,MAGENTA_STAINED_GLASS)
- player.say("§d§lPosition 2 set: §f("+position2+")")
- } else {
- position2 = player.position().add(pos(0,-1,0))
- filler2(position2,position2,MAGENTA_STAINED_GLASS)
- player.say("§d§lPosition 2 set: §f("+position2+")")
- }
- }
- })
- player.onChat(";fill", function (num1:Number) {
- if (position1 != null && position2 != null) {
- pos1place = false
- pos2place = false
- let block:string = player.getChatArg(0)
- let volume = volumer()
- if (volume < 0) {
- volume = volume * -1
- }
- if (volume > 3600*5) {
- if (volume != 1) {
- player.say("§9§lFilling §7"+volume+"§9 blocks...")
- } else {
- player.say("§9§lFilling §7"+volume+"§9 block...")
- }
- filler(position1,position2,block)
- player.say("§a§lDone!")
- } else {
- filler(position1,position2,block)
- if (volume != 1) {
- player.say("§9§lFilled §7"+volume+"§9 blocks")
- } else {
- player.say("§9§lFilled §7"+volume+"§9 block")
- }
- }
- } else {
- player.say("§4§lPositions must be set first!")
- }
- })
- player.onChat(";replace", function (num1:Number,num2:Number) {
- if (position1 != null && position2 != null) {
- pos1place = false
- pos2place = false
- let block1:string = player.getChatArg(0)
- let block2:string = player.getChatArg(1)
- let volume = volumer()
- if (volume < 0) {
- volume = volume * -1
- }
- if (volume > 3600*5) {
- if (volume != 1) {
- player.say("§9§lReplacing §7"+volume+"§9 blocks...")
- } else {
- player.say("§9§lReplacing §7"+volume+"§9 block...")
- }
- replace(position1,position2,block1,block2)
- player.say("§a§lDone!")
- } else {
- replace(position1,position2,block1,block2)
- if (volume != 1) {
- player.say("§9§lReplaced §7"+volume+"§9 blocks")
- } else {
- player.say("§9§lReplaced §7"+volume+"§9 block")
- }
- }
- } else {
- player.say("§4§lPositions must be set first!")
- }
- })
- player.onChat(";copy", function () {
- if (position1 != null && position2 != null) {
- copy1 = position1
- copy2 = position2
- let volume = volumer()
- if (volume != 1) {
- player.say("§9§lCopied a zone of §7"+volume+"§9 blocks")
- } else {
- player.say("§9§lCopied a zone of §7"+volume+"§9 block")
- }
- } else {
- player.say("§4§lPositions must be set first!")
- }
- })
- player.onChat(";paste", function () {
- if (copy1 != null) {
- blocks.place(blocks.blockByName("AIR"), position1)
- blocks.place(blocks.blockByName("AIR"), position2)
- copypaste(copy1,copy2)
- player.say("§9§lZone pasted")
- } else {
- player.say("§4§lYou must copy a selection first!")
- }
- })
- player.onChat(";destroy", function () {
- if (position1 != null && position2 != null) {
- pos1place = false
- pos2place = false
- let volume = volumer()
- if (volume < 0) {
- volume = volume * -1
- }
- if (volume > 3600*5) {
- if (volume != 1) {
- player.say("§9§lDestroying §7"+volume+"§9 blocks...")
- } else {
- player.say("§9§lDestroying §7"+volume+"§9 block...")
- }
- filler(position1,position2,"AIR")
- player.say("§a§lDone!")
- } else {
- filler(position1,position2,"AIR")
- if (volume != 1) {
- player.say("§9§lDestroyed §7"+volume+"§9 blocks")
- } else {
- player.say("§9§lDestroyed §7"+volume+"§9 block")
- }
- }
- } else {
- player.say("§4§lPositions must be set first!")
- }
- })
- player.onChat(";walls", function (num:Number) {
- if (position1 != null && position2 != null) {
- pos1place = false
- pos2place = false
- let block1:string = player.getChatArg(0)
- walls(position1,position2,block1)
- player.say("§9§lWalls made")
- } else {
- player.say("§4§lPositions must be set first!")
- }
- })
- player.onChat(";floor", function (num:Number) {
- if (position1 != null && position2 != null) {
- pos1place = false
- pos2place = false
- let block1:string = player.getChatArg(0)
- floor(position1,position2,block1)
- player.say("§9§lFloor made")
- } else {
- player.say("§4§lPositions must be set first!")
- }
- })
- player.onChat(";ceiling", function (num:Number) {
- if (position1 != null && position2 != null) {
- pos1place = false
- pos2place = false
- let block1:string = player.getChatArg(0)
- ceiling(position1,position2,block1)
- player.say("§9§lCeling made")
- } else {
- player.say("§4§lPositions must be set first!")
- }
- })
- player.onChat(";box", function (num:Number) {
- if (position1 != null && position2 != null) {
- pos1place = false
- pos2place = false
- let block1:string = player.getChatArg(0)
- walls(position1,position2,block1)
- floor(position1,position2,block1)
- ceiling(position1,position2,block1)
- player.say("§9§lBox made")
- } else {
- player.say("§4§lPositions must be set first!")
- }
- })
- player.onChat(";removenodes", function () {
- if (position1 != null && position2 != null) {
- pos1place = false
- pos2place = false
- blocks.place(AIR, position1)
- blocks.place(AIR, position2)
- player.say("§9§lNodes destroyed")
- } else {
- player.say("§4§lPositions must be set first!")
- }
- })
- player.onChat(";node1", function () {
- if (position1 != null && position2 != null) {
- pos1place = false
- pos2place = false
- player.teleport(position1.add(pos(0,2,0)))
- player.say("§9§lTeleported to Position 1")
- } else {
- player.say("§4§lPositions must be set first!")
- }
- })
- player.onChat(";node2", function () {
- if (position1 != null && position2 != null) {
- pos1place = false
- pos2place = false
- player.teleport(position2.add(pos(0,2,0)))
- player.say("§d§lTeleported to Position 2")
- } else {
- player.say("§4§lPositions must be set first!")
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement