Muzze77

Emerald_to_U-Solar

Jun 27th, 2022 (edited)
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.76 KB | None | 0 0
  1. p = peripheral.wrap("bottom")
  2. shell.run("clear")
  3. if not fs.exists("api") then
  4.     shell.run("pastebin get QMct3H9x api")
  5. else
  6.     shell.run("delete api")
  7.     shell.run("pastebin get QMct3H9x api")
  8. end
  9.  
  10.  
  11.  
  12.  
  13. while true do
  14. id = p.getPeripheralWorldID()
  15. w = p.getWorld(id)
  16.  
  17. x ,y ,z = p.getPeripheralPos()
  18.  
  19.  
  20. buffer = {}
  21. for a = -20,20,1 do
  22.     for b = -20,20,1 do
  23.         for c = -3,3,1 do
  24.         blockID = w.getBlockID(x+a,y+b,z+c)
  25.        
  26.             if blockID == 2915 then
  27.                 table.insert(buffer,{blockID,x+a,y+b,z+c})
  28.             end
  29.         end
  30.     end
  31. end
  32.  
  33.  
  34. f = os.loadAPI("api")
  35.  
  36. for n,data in pairs(buffer) do
  37.  
  38.      te = w.getTileEntity(data[2],data[3],data[4])
  39.      nbt = readTileNBT(te)
  40.      tab = nbt.value.Items.value
  41.      for v,k in pairs(tab) do
  42.            
  43.             print("###")
  44.             tag = k.value.tag
  45.             if tag == nil then
  46.             else
  47.                 if tag.value.ench == nil then
  48.                 else
  49.                     name = tag.value.display.value.Name.value
  50.                     ench = 0
  51.                     enchName = ""
  52.                     enchLvl = 0
  53.                     for index,ent in pairs(tag.value.ench.value) do
  54.                            
  55.                             ench = ent.value.id.value
  56.                             enchLvl = ent.value.lvl.value
  57.                             if ench == 35 and enchLvl == 5 then
  58.                             enchName = "Fortune V"
  59.                             end
  60.                     end
  61.                    
  62.                     meta = k.value.Damage.value
  63.                     count = k.value.Count.value
  64.                     slot = k.value.Slot.value
  65.                    
  66.                     item  = k.value.id.value
  67.                    
  68.                    
  69.                     print(name)
  70.                     print(enchName)
  71.                    
  72.                    
  73.                     if enchName == "Fortune V" and name == "Upgraded Emerald" and item == 388 then
  74.                         print("FOUND")
  75.                         k.value.id.value = 194
  76.                         k.value.Damage.value = 2
  77.                         tag.value.ench = nil
  78.                         tag.value.display.value.Name.value = "InMeGames U-SOLAR"
  79.                         writeTileNBT(te,nbt)
  80.                     end
  81.                     print("")
  82.                    
  83.                    
  84.                    
  85.                 end
  86.             end
  87.     end
  88. end
  89.  
  90. sleep(1)
  91. end
Add Comment
Please, Sign In to add comment