Advertisement
hargmon

minecraft cc autominer

Oct 4th, 2023 (edited)
1,039
1
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.94 KB | None | 1 0
  1. mining = true
  2. clearByValuables = true
  3. -- if this is true, it throws away everything except valuables, if false it throws away just the rubbish
  4. valuables =
  5. {"minecraft:diamond",
  6. "minecraft:redstone",
  7. "minecraft:raw_gold",
  8. "minecraft:raw_iron",
  9. "minecraft:lapis_lazuli",
  10. "minecraft:emerald",
  11. "minecraft:coal",
  12. "minecraft:quartz",
  13. "minecraft:ancient_debris",
  14. "minecraft:raw_copper",
  15. "minecraft:charcoal"}
  16. -- add whatever fuel you're using so it doesn't get thrown out
  17.  
  18. rubbish =
  19. {"minecraft:granite",
  20. "minecraft:andesite",
  21. "minecraft:diorite"}
  22.  
  23. function equip(item)
  24.     for i = 1, 16, 1 do
  25.         if turtle.getItemDetail(i) == item then
  26.             turtle.transferTo(i)
  27.             end
  28.         end
  29.     end
  30.  
  31. function sortItems()
  32.     if clearByValuables then
  33.         for i = 1, 16, 1 do
  34.             if turtle.getItemDetail(i) then
  35.                 good = false
  36.                 for key, var in pairs(valuables) do
  37.                     if var == turtle.getItemDetail(i).name then
  38.                         good = true
  39.                         break
  40.                         end
  41.                     end
  42.                 if not good then
  43.                     turtle.select(i)
  44.                     turtle.dropDown()
  45.                     end
  46.                 end
  47.             end
  48.         turtle.select(1)
  49.     else
  50.         for i = 1, 16, 1 do
  51.             if turtle.getItemDetail(i) then
  52.                 good = true
  53.                 for key, var in pairs(rubbish) do
  54.                     if var == turtle.getItemDetail(i).name then
  55.                         good = false
  56.                         break
  57.                         end
  58.                     end
  59.                 if not good then
  60.                     turtle.select(i)
  61.                     turtle.dropDown()
  62.                     end
  63.                 end
  64.             end
  65.         turtle.select(1)
  66.         end
  67.     end
  68.  
  69. function inventoryFull()
  70.     full = true
  71.     for i = 1, 16, 1 do
  72.         if not turtle.getItemDetail(i) then
  73.             full = false
  74.             break
  75.             end
  76.         end
  77.     return full
  78.     end
  79.        
  80.  
  81. while mining do
  82.     if turtle.getFuelLevel() <= 0 then
  83.         turtle.refuel()
  84.         mining = false
  85.         end
  86.    
  87.     turtle.dig()
  88.     turtle.digUp()
  89.     turtle.digDown()
  90.    
  91.     turtle.turnLeft()
  92.     turtle.dig()
  93.    
  94.     turtle.turnLeft()
  95.     turtle.turnLeft()
  96.     turtle.dig()
  97.     turtle.turnLeft()
  98.    
  99.     while not turtle.forward() do
  100.         turtle.dig()
  101.         end
  102.    
  103.     sortItems()
  104.     if inventoryFull() then
  105.         mining = false
  106.         end
  107.    
  108.     sleep(0)
  109.     end
  110.  
  111. if not mining then
  112.     turtle.turnLeft()
  113.     turtle.turnLeft()
  114.     while true do
  115.         while not turtle.forward() do
  116.                 turtle.dig()
  117.                 end
  118.         turtle.forward()
  119.        
  120.         hasBlock, data = turtle.inspect()
  121.         if data.name == "minecraft:barrel" then
  122.             break
  123.             end
  124.         sleep(0)
  125.         end
  126.     for i = 1, 16, 1 do
  127.         turtle.select(i)
  128.         turtle.drop()
  129.         end
  130.     end
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement