skypop

[Creative] chunkCleaner

Sep 9th, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local args = {...}
  2. local range,heightLimit = 16, 126
  3. if args and #args>=1 then
  4.   if args[1]=="help" then
  5.     print([[chunkCleaner <range> <heightLimit>
  6.   <range>: (num) distance in meters (default: 16)
  7.   <heightLimit>: (num) ceil effect on vertical axis (default: 126)
  8.  
  9. Clear chunk surrounding Command computer's chunk position.
  10. Effect between Command computer Y position and <heightLimit>
  11. Skip Command computer's chunk position.
  12. Could remove bedrock. To keep nether's ceiling set heightLimit to 126.]])
  13.    return
  14.  else
  15.    range = tonumber(args[1]) or 16
  16.  end
  17. end
  18. if args and #args>=2 then
  19.  heightLimit = tonumber(args[2]) or 126
  20. end
  21.  
  22. local baseX,baseY,baseZ = commands.getBlockPosition()
  23.  
  24. local function chunkOrigin(_x,_y,_z)
  25.  return _x-(_x%16),_y-(_y%16),_z-(_z%16)
  26. end
  27.  
  28. local function clearChunk(_x,_y,_z)
  29.  local oX,oY,oZ = chunkOrigin(_x,_y,_z)
  30.  local _y = baseY
  31.  local _,cursorY = term.getCursorPos()
  32.  while _y <= heightLimit do
  33.    sleep(.1)
  34.    term.setCursorPos(1,cursorY)
  35.    term.clearLine()
  36.    term.write("y:".._y)
  37.    commands.fill(
  38.      oX,
  39.      math.min(heightLimit, _y),
  40.      oZ,
  41.      oX+15,
  42.      math.min(heightLimit, _y+63),
  43.      oZ+15,
  44.      "minecraft:air"
  45.    )
  46.    _y = _y+64
  47.  end
  48.  print("")
  49. end
  50.  
  51. local z = baseZ-range
  52. while z<baseZ+range do
  53.  local x = baseX-range
  54.  while x<baseX+range do
  55.    if  baseX >= x and baseX <= x+15
  56.    and baseZ >= z and baseZ <= z+15
  57.    then
  58.      print("Skip command chunk")
  59.    else
  60.      print(string.format("Clearing chunk x:%d, y:%d, z:%d",x,baseY,z))
  61.      clearChunk(x,baseY,z)
  62.    end
  63.    x = x + 16
  64.    sleep(.5)
  65.  end
  66.  z = z +16
  67. end
Add Comment
Please, Sign In to add comment