Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ee.core;
- import ee.item.ItemLootBall;
- import forge.ForgeHooks;
- import forge.IPickupHandler;
- import net.minecraft.server.*;
- public class PickupHandler
- implements IPickupHandler
- {
- public PickupHandler()
- {
- }
- public boolean onItemPickup(EntityHuman ply, EntityItem item)
- {
- // Get the stack we picked up
- ItemStack stack = item.itemStack;
- // Check it's valid
- if(stack != null && stack.count > 0)
- {
- // Check if it's a loot ball
- if(!(item.itemStack.getItem() instanceof ItemLootBall))
- return true;
- // Get the list of items inside the loot ball
- ItemLootBall lootball = (ItemLootBall)stack.getItem();
- ItemStack droplist[] = lootball.getDroplist(stack);
- // Check if the items list exists
- if(droplist != null)
- {
- //EntityItem var6 = new EntityItem(ply.world, ply.locX, ply.locY, ply.locZ, null);
- // Loop through each drop stack
- int cnt = droplist.length;
- for(int i = 0; i < cnt; i++)
- {
- // Get the drop stack
- ItemStack drop = droplist[i];
- // Create a new item
- EntityItem newitem = new EntityItem(ply.world, ply.locX, ply.locY, ply.locZ, drop);
- // Drop the item at the player's foot, if not picked up
- if(ForgeHooks.onItemPickup(ply, newitem) && !ply.inventory.pickup(newitem.itemStack))
- ply.drop(newitem.itemStack);
- }
- }
- // The stack is now empty!
- stack.count = 0;
- return false;
- } else
- {
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment