LexManos

Item Pickup handler

Feb 10th, 2012
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.35 KB | None | 0 0
  1. package net.minecraft.src.forge;
  2.  
  3. import net.minecraft.src.EntityItem;
  4. import net.minecraft.src.EntityPlayer;
  5. import net.minecraft.src.ItemStack;
  6.  
  7. public interface IPickupHandler
  8. {
  9.  
  10.     /**
  11.      * Raised when a player collides with a EntityItem.
  12.      * The handler may consume all, or part of the stack.
  13.      * The handler will only be called if the stack size is > 0
  14.      * The event may be cut part way through if the stack size
  15.      * falls to 0 or a previous handler returns false;
  16.      * Will only be called if delay before pickup is 0.
  17.      *
  18.      * The Entity will destroyed if the stack size falls to 0.
  19.      *
  20.      * @param player Player that picked up the item
  21.      * @param item Item picked up as entity. May be manipulated
  22.      * @return True If processing should continue.
  23.      */
  24.     public boolean onItemPickup(EntityPlayer player, EntityItem item);
  25.    
  26. }
  27.  
  28.  
  29.         if (delayBeforeCanPickup == 0 && !ForgeHooks.onItemPickup(entityplayer, this))
  30.         {
  31.             ModLoader.OnItemPickup(entityplayer, item);
  32.             worldObj.playSoundAtEntity(this, "random.pop", 0.2F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
  33.             entityplayer.onItemPickup(this, i);
  34.             if (item.stackSize <= 0)
  35.             {
  36.                 setEntityDead();
  37.             }
  38.         }
  39.         i = item.stackSize;
Advertisement
Add Comment
Please, Sign In to add comment