Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function removeItem(Inventory, Material, Amount)
- local Contents = Inventory:getContents()
- for i = 0, Contents.length do
- local Item = Contents[i]
- if Item and Item:getType():equals(Material) then
- local Remove = Item:getAmount() - Amount
- if Remove <= 0 then
- Contents[i] = nil
- Inventory:setContents(Contents)
- break
- else
- Item:setAmount(Remove)
- break
- end
- end
- end
- end
- function getPosition(Entity)
- local Location = Entity:getLocation()
- return Location:getX(), Location:getY(), Location:getZ()
- end
- events.add("projectileHit",
- function(Event)
- local Projectile = Event:getEntity()
- local World = Projectile:getWorld()
- local X, Y, Z = getPosition(Projectile)
- World:createExplosion(X, Y, Z, 0.5, false, false)
- end
- )
- events.add("playerInteract",
- function(Event)
- local Player = Event:getPlayer()
- local Inventory = Player:getInventory()
- if Player:getItemInHand():getType() == material.DIAMOND_HOE and Inventory:contains(material.SNOW_BALL) then
- Player:launchProjectile(luajava.bindClass("org.bukkit.entity.Snowball"))
- removeItem(Inventory, material.SNOW_BALL, 1)
- Player:updateInventory()
- end
- end
- )
Advertisement
Add Comment
Please, Sign In to add comment