Guest User

Untitled

a guest
Mar 30th, 2014
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. function removeItem(Inventory, Material, Amount)
  2. local Contents = Inventory:getContents()
  3. for i = 0, Contents.length do
  4. local Item = Contents[i]
  5. if Item and Item:getType():equals(Material) then
  6. local Remove = Item:getAmount() - Amount
  7. if Remove <= 0 then
  8. Contents[i] = nil
  9. Inventory:setContents(Contents)
  10. break
  11. else
  12. Item:setAmount(Remove)
  13. break
  14. end
  15. end
  16. end
  17. end
  18.  
  19. function getPosition(Entity)
  20. local Location = Entity:getLocation()
  21. return Location:getX(), Location:getY(), Location:getZ()
  22. end
  23.  
  24. events.add("projectileHit",
  25. function(Event)
  26. local Projectile = Event:getEntity()
  27. local World = Projectile:getWorld()
  28. local X, Y, Z = getPosition(Projectile)
  29. World:createExplosion(X, Y, Z, 0.5, false, false)
  30. end
  31. )
  32.  
  33. events.add("playerInteract",
  34. function(Event)
  35. local Player = Event:getPlayer()
  36. local Inventory = Player:getInventory()
  37.  
  38. if Player:getItemInHand():getType() == material.DIAMOND_HOE and Inventory:contains(material.SNOW_BALL) then
  39. Player:launchProjectile(luajava.bindClass("org.bukkit.entity.Snowball"))
  40. removeItem(Inventory, material.SNOW_BALL, 1)
  41. Player:updateInventory()
  42. end
  43. end
  44. )
Advertisement
Add Comment
Please, Sign In to add comment