Java 类net.minecraftforge.event.entity.player.PlayerDestroyItemEvent 实例源码

项目:4Space-5    文件:PlayerControllerMP.java   
public boolean sendUseItem(EntityPlayer p_78769_1_, World p_78769_2_, ItemStack p_78769_3_)
{
    syncCurrentPlayItem();
    this.netClientHandler.addToSendQueue(new C08PacketPlayerBlockPlacement(-1, -1, -1, 255, p_78769_1_.inventory.getCurrentItem(), 0.0F, 0.0F, 0.0F));
    int i = p_78769_3_.stackSize;
    ItemStack itemstack1 = p_78769_3_.useItemRightClick(p_78769_2_, p_78769_1_);
    if ((itemstack1 == p_78769_3_) && ((itemstack1 == null) || (itemstack1.stackSize == i))) {
        return false;
    }
    p_78769_1_.inventory.mainInventory[p_78769_1_.inventory.currentItem] = itemstack1;
    if (itemstack1.stackSize <= 0)
    {
        p_78769_1_.inventory.mainInventory[p_78769_1_.inventory.currentItem] = null;
        MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(p_78769_1_, itemstack1));
    }
    return true;
}
项目:MyMod    文件:CraftingHandler.java   
@SubscribeEvent
public void onPlayerItemCrafted(PlayerEvent.ItemCraftedEvent event) {

    if (event.crafting.isItemEqual(new ItemStack(ModItems.ammo))) {
        for (int i = 0; i < event.craftMatrix.getSizeInventory(); i++) {
            ItemStack stack = event.craftMatrix.getStackInSlot(i);
            if (stack != null && stack.isItemStackDamageable()) {

                if (stack.getItemDamage() <= stack.getMaxDamage() - 1) {
                    stack.setItemDamage(stack.getItemDamage() + 1);
                    stack.stackSize++;
                } else {
                    event.craftMatrix.setInventorySlotContents(i, null);
                    MinecraftForge.EVENT_BUS
                            .post(new PlayerDestroyItemEvent(event.player,
                                    stack));
                }
            }
        }
    }
}
项目:4Space-1.7    文件:PlayerControllerMP.java   
public boolean sendUseItem(EntityPlayer p_78769_1_, World p_78769_2_, ItemStack p_78769_3_)
{
    syncCurrentPlayItem();
    this.netClientHandler.addToSendQueue(new C08PacketPlayerBlockPlacement(-1, -1, -1, 255, p_78769_1_.inventory.getCurrentItem(), 0.0F, 0.0F, 0.0F));
    int i = p_78769_3_.stackSize;
    ItemStack itemstack1 = p_78769_3_.useItemRightClick(p_78769_2_, p_78769_1_);
    if ((itemstack1 == p_78769_3_) && ((itemstack1 == null) || (itemstack1.stackSize == i))) {
        return false;
    }
    p_78769_1_.inventory.mainInventory[p_78769_1_.inventory.currentItem] = itemstack1;
    if (itemstack1.stackSize <= 0)
    {
        p_78769_1_.inventory.mainInventory[p_78769_1_.inventory.currentItem] = null;
        MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(p_78769_1_, itemstack1));
    }
    return true;
}
项目:Cauldron    文件:PlayerControllerMP.java   
public boolean sendUseItem(EntityPlayer p_78769_1_, World p_78769_2_, ItemStack p_78769_3_)
{
    this.syncCurrentPlayItem();
    this.netClientHandler.addToSendQueue(new C08PacketPlayerBlockPlacement(-1, -1, -1, 255, p_78769_1_.inventory.getCurrentItem(), 0.0F, 0.0F, 0.0F));
    int i = p_78769_3_.stackSize;
    ItemStack itemstack1 = p_78769_3_.useItemRightClick(p_78769_2_, p_78769_1_);

    if (itemstack1 == p_78769_3_ && (itemstack1 == null || itemstack1.stackSize == i))
    {
        return false;
    }
    else
    {
        p_78769_1_.inventory.mainInventory[p_78769_1_.inventory.currentItem] = itemstack1;

        if (itemstack1.stackSize <= 0)
        {
            p_78769_1_.inventory.mainInventory[p_78769_1_.inventory.currentItem] = null;
            MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(p_78769_1_, itemstack1));
        }

        return true;
    }
}
项目:Cauldron    文件:PlayerControllerMP.java   
public boolean sendUseItem(EntityPlayer p_78769_1_, World p_78769_2_, ItemStack p_78769_3_)
{
    this.syncCurrentPlayItem();
    this.netClientHandler.addToSendQueue(new C08PacketPlayerBlockPlacement(-1, -1, -1, 255, p_78769_1_.inventory.getCurrentItem(), 0.0F, 0.0F, 0.0F));
    int i = p_78769_3_.stackSize;
    ItemStack itemstack1 = p_78769_3_.useItemRightClick(p_78769_2_, p_78769_1_);

    if (itemstack1 == p_78769_3_ && (itemstack1 == null || itemstack1.stackSize == i))
    {
        return false;
    }
    else
    {
        p_78769_1_.inventory.mainInventory[p_78769_1_.inventory.currentItem] = itemstack1;

        if (itemstack1.stackSize <= 0)
        {
            p_78769_1_.inventory.mainInventory[p_78769_1_.inventory.currentItem] = null;
            MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(p_78769_1_, itemstack1));
        }

        return true;
    }
}
项目:ShadowsOfPhysis    文件:ItemDestructionHandler.java   
@SubscribeEvent
public void OnItemDestruction(PlayerDestroyItemEvent event) {
    if (event.entity == null) { return; }
    if (event.entity.worldObj.isRemote) { return; }

    Random rand = event.entityPlayer.getRNG();

    ItemStack stack = event.original;
    EntityPlayer player = event.entityPlayer;
    if (PhysisArtifacts.canItemAcceptSockets(stack)) {
        for(Socket socket : SocketIterator.triggers(stack)) {
            if(socket.tag != null) {
                if (rand.nextDouble() < 0.75) {
                    ItemStack socketable = ItemStack.loadItemStackFromNBT(socket.tag);

                    TileUtilities.dropItemInWorld(event.entityPlayer.worldObj, socketable, player.posX, player.posY - 0.3 + player.getEyeHeight(), player.posZ);
                }
            }
        }
    }
}
项目:RuneCraftery    文件:PlayerControllerMP.java   
/**
 * Notifies the server of things like consuming food, etc...
 */
public boolean sendUseItem(EntityPlayer par1EntityPlayer, World par2World, ItemStack par3ItemStack)
{
    this.syncCurrentPlayItem();
    this.netClientHandler.addToSendQueue(new Packet15Place(-1, -1, -1, 255, par1EntityPlayer.inventory.getCurrentItem(), 0.0F, 0.0F, 0.0F));
    int i = par3ItemStack.stackSize;
    ItemStack itemstack1 = par3ItemStack.useItemRightClick(par2World, par1EntityPlayer);

    if (itemstack1 == par3ItemStack && (itemstack1 == null || itemstack1.stackSize == i))
    {
        return false;
    }
    else
    {
        par1EntityPlayer.inventory.mainInventory[par1EntityPlayer.inventory.currentItem] = itemstack1;

        if (itemstack1.stackSize <= 0)
        {
            par1EntityPlayer.inventory.mainInventory[par1EntityPlayer.inventory.currentItem] = null;
            MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(par1EntityPlayer, itemstack1));
        }

        return true;
    }
}
项目:ModularArmour    文件:InventoryUtil.java   
public static void decrementItemStack(EntityPlayer player, IInventory inventory, int index) {

        ItemStack stack = inventory.getStackInSlot(index);

        if (stack != null) {
            inventory.decrStackSize(index, 1);

            if (stack.getItem().hasContainerItem(stack)) {
                ItemStack itemstack2 = stack.getItem().getContainerItem(stack);

                if (itemstack2 != null && itemstack2.isItemStackDamageable() && itemstack2.getItemDamage() > itemstack2.getMaxDamage()) {
                    MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, itemstack2));
                    return;
                }

                if (!stack.getItem().doesContainerItemLeaveCraftingGrid(stack) || !player.inventory.addItemStackToInventory(itemstack2)) {
                    if (inventory.getStackInSlot(index) == null) {
                        inventory.setInventorySlotContents(index, itemstack2);
                    } else {
                        player.dropPlayerItemWithRandomChoice(itemstack2, false);
                    }
                }
            }
        }
    }
项目:BetterNutritionMod    文件:PlayerControllerMP.java   
/**
 * Notifies the server of things like consuming food, etc...
 */
public boolean sendUseItem(EntityPlayer par1EntityPlayer, World par2World, ItemStack par3ItemStack)
{
    this.syncCurrentPlayItem();
    this.netClientHandler.addToSendQueue(new Packet15Place(-1, -1, -1, 255, par1EntityPlayer.inventory.getCurrentItem(), 0.0F, 0.0F, 0.0F));
    int i = par3ItemStack.stackSize;
    ItemStack itemstack1 = par3ItemStack.useItemRightClick(par2World, par1EntityPlayer);

    if (itemstack1 == par3ItemStack && (itemstack1 == null || itemstack1.stackSize == i))
    {
        return false;
    }
    else
    {
        par1EntityPlayer.inventory.mainInventory[par1EntityPlayer.inventory.currentItem] = itemstack1;

        if (itemstack1.stackSize <= 0)
        {
            par1EntityPlayer.inventory.mainInventory[par1EntityPlayer.inventory.currentItem] = null;
            MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(par1EntityPlayer, itemstack1));
        }

        return true;
    }
}
项目:Survivalist    文件:ItemBreakingTracker.java   
@SubscribeEvent
public void onPlayerDestroyItem(PlayerDestroyItemEvent ev)
{
    if (ev.getEntityPlayer().world.isRemote)
        return;

    ItemStack stack = ev.getOriginal();

    Item item = stack.getItem();

    if (!(item instanceof ItemTool) && !(item instanceof ItemSword))
        return;

    onItemBroken(ev.getEntityPlayer(), stack);
}
项目:Factorization    文件:HammerNet.java   
private boolean do_click(IDimensionSlice idc, WorldServer world, EntityPlayerMP player, BlockPos pos, EnumFacing sideHit, float vecX, float vecY, float vecZ) {
    // Copy of PlayerControllerMP.onPlayerRightClick
    ItemStack is = player.getHeldItem();
    if (is != null && is.getItem().onItemUseFirst(is, player, world, pos, sideHit, vecX, vecY, vecZ)) {
        return true;
    }
    boolean ret = false;

    if (!player.isSneaking() || player.getHeldItem() == null
            || player.getHeldItem().getItem().doesSneakBypassUse(world, pos, player)) {
        IBlockState state = world.getBlockState(pos);
        ret = state.getBlock().onBlockActivated(world, pos, state, player, sideHit, vecX, vecY, vecZ);
    }

    if (ret) {
        return true;
    } else if (is == null || !idc.can(DeltaCapability.BLOCK_PLACE)) {
        return false;
    } else if (PlayerUtil.isPlayerCreative(player)) {
        int j1 = is.getItemDamage();
        int i1 = is.stackSize;
        boolean flag1 = is.onItemUse(player, world, pos,
                sideHit, vecX, vecY, vecZ);
        is.setItemDamage(j1);
        is.stackSize = i1;
        return flag1;
    } else {
        if (!is.onItemUse(player, world, pos, sideHit, vecX, vecY, vecZ)) {
            return false;
        }
        if (is.stackSize <= 0) {
            MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, is));
        }
        return true;
    }
}
项目:copycore    文件:TweakAutoReplace.java   
@SubscribeEvent
public void onPlayerDestroyItem(PlayerDestroyItemEvent event) {

    if (!(event.entity instanceof EntityPlayerMP) ||
        event.entity.worldObj.isRemote) return;

    EntityPlayerMP player = (EntityPlayerMP)event.entityPlayer;
    InventoryPlayer inv = player.inventory;

    ItemStack currentItem = inv.getCurrentItem();
    if ((currentItem != null) &&
        (currentItem != event.original)) return;

    int row;
    for (row = 2; row >= 0; row--) {
        int slot = inv.currentItem + row * 9 + 9;
        ItemStack stackAbove = inv.getStackInSlot(slot);
        if (!canReplace(stackAbove, event.original)) break;
        int targetSlot = ((slot < 27) ? (slot + 9) : (slot - 27));
        inv.setInventorySlotContents(targetSlot, stackAbove);
        inv.setInventorySlotContents(slot, null);
        player.playerNetServerHandler.sendPacket(
                new S2FPacketSetSlot(0, slot + 9, stackAbove));
    }

    if (row < 2)
        player.playerNetServerHandler.sendPacket(
                new S2FPacketSetSlot(0, inv.currentItem + row * 9 + 18, null));

}
项目:ZeroQuest    文件:NileTabSlot.java   
@Override
public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack)
{
         FMLCommonHandler.instance().firePlayerCraftingEvent(par1EntityPlayer, par2ItemStack, craftMatrix);
         this.onCrafting(par2ItemStack);
         for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i)
         {
                 ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i);
                 if (itemstack1 != null)
                 {
                         this.craftMatrix.decrStackSize(i, 1);
                         if (itemstack1.getItem().hasContainerItem(itemstack1))
                         {
                                 ItemStack itemstack2 = itemstack1.getItem().getContainerItem(itemstack1);
                                 if (itemstack2.isItemStackDamageable() && itemstack2.getItemDamage() > itemstack2.getMaxDamage())
                                 {
                                         MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer, itemstack2));
                                         itemstack2 = null;
                                 }
                                 if (itemstack2 != null && (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1) || !this.thePlayer.inventory.addItemStackToInventory(itemstack2)))
                                 {
                                         if (this.craftMatrix.getStackInSlot(i) == null)
                                         {
                                                 this.craftMatrix.setInventorySlotContents(i, itemstack2);
                                         }
                                         else
                                         {
                                                 this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false);
                                         }
                                 }
                         }
                 }
         }
}
项目:ZeroQuest    文件:NileTabSlot.java   
@Override
public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack)
{
         GameRegistry.onItemCrafted(par1EntityPlayer, par2ItemStack, craftMatrix);
         this.onCrafting(par2ItemStack);
         for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i)
         {
                 ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i);
                 if (itemstack1 != null)
                 {
                         this.craftMatrix.decrStackSize(i, 1);
                         if (itemstack1.getItem().hasContainerItem())
                         {
                                 ItemStack itemstack2 = itemstack1.getItem().getContainerItemStack(itemstack1);
                                 if (itemstack2.isItemStackDamageable() && itemstack2.getItemDamage() > itemstack2.getMaxDamage())
                                 {
                                         MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer, itemstack2));
                                         itemstack2 = null;
                                 }
                                 if (itemstack2 != null && (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1) || !this.thePlayer.inventory.addItemStackToInventory(itemstack2)))
                                 {
                                         if (this.craftMatrix.getStackInSlot(i) == null)
                                         {
                                                 this.craftMatrix.setInventorySlotContents(i, itemstack2);
                                         }
                                         else
                                         {
                                                 this.thePlayer.dropPlayerItem(itemstack2);
                                         }
                                 }
                         }
                 }
         }
}
项目:GardenCollection    文件:SlotPottery.java   
@Override
public void onPickupFromSlot (EntityPlayer player, ItemStack itemStack) {
    FMLCommonHandler.instance().firePlayerCraftingEvent(player, itemStack, inputInventory);
    onCrafting(itemStack);

    ItemStack itemTarget = inputInventory.getStackInSlot(1);
    if (itemTarget != null) {
        inputInventory.decrStackSize(1, 1);

        if (itemTarget.getItem().hasContainerItem(itemTarget)) {
            ItemStack itemContainer = itemTarget.getItem().getContainerItem(itemTarget);
            if (itemContainer != null && itemContainer.isItemStackDamageable() && itemContainer.getItemDamage() > itemContainer.getMaxDamage()) {
                MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(this.player, itemContainer));
                return;
            }

            if (!itemTarget.getItem().doesContainerItemLeaveCraftingGrid(itemTarget) || !this.player.inventory.addItemStackToInventory(itemContainer)) {
                if (inputInventory.getStackInSlot(1) == null)
                    inputInventory.setInventorySlotContents(1, itemContainer);
                else
                    this.player.dropPlayerItemWithRandomChoice(itemContainer, false);
            }
        }
    }

    ItemStack itemPattern = inputInventory.getStackInSlot(0);
    if (itemPattern != null && itemPattern.getItem() == Items.dye) {
        inputInventory.decrStackSize(0, 1);
    }
}
项目:Cauldron    文件:SlotCrafting.java   
public void onPickupFromSlot(EntityPlayer p_82870_1_, ItemStack p_82870_2_)
{
    FMLCommonHandler.instance().firePlayerCraftingEvent(p_82870_1_, p_82870_2_, craftMatrix);
    this.onCrafting(p_82870_2_);

    for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i)
    {
        ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i);

        if (itemstack1 != null)
        {
            this.craftMatrix.decrStackSize(i, 1);

            if (itemstack1.getItem().hasContainerItem(itemstack1))
            {
                ItemStack itemstack2 = itemstack1.getItem().getContainerItem(itemstack1);

                if (itemstack2 != null && itemstack2.isItemStackDamageable() && itemstack2.getItemDamage() > itemstack2.getMaxDamage())
                {
                    MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer, itemstack2));
                    continue;
                }

                if (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1) || !this.thePlayer.inventory.addItemStackToInventory(itemstack2))
                {
                    if (this.craftMatrix.getStackInSlot(i) == null)
                    {
                        this.craftMatrix.setInventorySlotContents(i, itemstack2);
                    }
                    else
                    {
                        this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false);
                    }
                }
            }
        }
    }
}
项目:Cauldron    文件:ItemInWorldManager.java   
public boolean tryUseItem(EntityPlayer p_73085_1_, World p_73085_2_, ItemStack p_73085_3_)
{
    int i = p_73085_3_.stackSize;
    int j = p_73085_3_.getItemDamage();
    ItemStack itemstack1 = p_73085_3_.useItemRightClick(p_73085_2_, p_73085_1_);

    if (itemstack1 == p_73085_3_ && (itemstack1 == null || itemstack1.stackSize == i && itemstack1.getMaxItemUseDuration() <= 0 && itemstack1.getItemDamage() == j))
    {
        return false;
    }
    else
    {
        p_73085_1_.inventory.mainInventory[p_73085_1_.inventory.currentItem] = itemstack1;

        if (this.isCreative())
        {
            itemstack1.stackSize = i;

            if (itemstack1.isItemStackDamageable())
            {
                itemstack1.setItemDamage(j);
            }
        }

        if (itemstack1.stackSize == 0)
        {
            p_73085_1_.inventory.mainInventory[p_73085_1_.inventory.currentItem] = null;
            MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thisPlayerMP, itemstack1));
        }

        if (!p_73085_1_.isUsingItem())
        {
            ((EntityPlayerMP)p_73085_1_).sendContainerToPlayer(p_73085_1_.inventoryContainer);
        }

        return true;
    }
}
项目:Cauldron    文件:SlotCrafting.java   
public void onPickupFromSlot(EntityPlayer p_82870_1_, ItemStack p_82870_2_)
{
    FMLCommonHandler.instance().firePlayerCraftingEvent(p_82870_1_, p_82870_2_, craftMatrix);
    this.onCrafting(p_82870_2_);

    for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i)
    {
        ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i);

        if (itemstack1 != null)
        {
            this.craftMatrix.decrStackSize(i, 1);

            if (itemstack1.getItem().hasContainerItem(itemstack1))
            {
                ItemStack itemstack2 = itemstack1.getItem().getContainerItem(itemstack1);

                if (itemstack2 != null && itemstack2.isItemStackDamageable() && itemstack2.getItemDamage() > itemstack2.getMaxDamage())
                {
                    MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer, itemstack2));
                    continue;
                }

                if (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1) || !this.thePlayer.inventory.addItemStackToInventory(itemstack2))
                {
                    if (this.craftMatrix.getStackInSlot(i) == null)
                    {
                        this.craftMatrix.setInventorySlotContents(i, itemstack2);
                    }
                    else
                    {
                        this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false);
                    }
                }
            }
        }
    }
}
项目:Cauldron    文件:ItemInWorldManager.java   
public boolean tryUseItem(EntityPlayer p_73085_1_, World p_73085_2_, ItemStack p_73085_3_)
{
    int i = p_73085_3_.stackSize;
    int j = p_73085_3_.getItemDamage();
    ItemStack itemstack1 = p_73085_3_.useItemRightClick(p_73085_2_, p_73085_1_);

    if (itemstack1 == p_73085_3_ && (itemstack1 == null || itemstack1.stackSize == i && itemstack1.getMaxItemUseDuration() <= 0 && itemstack1.getItemDamage() == j))
    {
        return false;
    }
    else
    {
        p_73085_1_.inventory.mainInventory[p_73085_1_.inventory.currentItem] = itemstack1;

        if (this.isCreative())
        {
            itemstack1.stackSize = i;

            if (itemstack1.isItemStackDamageable())
            {
                itemstack1.setItemDamage(j);
            }
        }

        if (itemstack1.stackSize == 0)
        {
            p_73085_1_.inventory.mainInventory[p_73085_1_.inventory.currentItem] = null;
            MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thisPlayerMP, itemstack1));
        }

        if (!p_73085_1_.isUsingItem())
        {
            ((EntityPlayerMP)p_73085_1_).sendContainerToPlayer(p_73085_1_.inventoryContainer);
        }

        return true;
    }
}
项目:RuneCraftery    文件:EntityPlayer.java   
/**
 * Destroys the currently equipped item from the player's inventory.
 */
public void destroyCurrentEquippedItem()
{
    ItemStack orig = getCurrentEquippedItem();
    this.inventory.setInventorySlotContents(this.inventory.currentItem, (ItemStack)null);
    MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(this, orig));
}
项目:RuneCraftery    文件:ItemInWorldManager.java   
/**
 * Attempts to right-click use an item by the given EntityPlayer in the given World
 */
public boolean tryUseItem(EntityPlayer par1EntityPlayer, World par2World, ItemStack par3ItemStack)
{
    int i = par3ItemStack.stackSize;
    int j = par3ItemStack.getItemDamage();
    ItemStack itemstack1 = par3ItemStack.useItemRightClick(par2World, par1EntityPlayer);

    if (itemstack1 == par3ItemStack && (itemstack1 == null || itemstack1.stackSize == i && itemstack1.getMaxItemUseDuration() <= 0 && itemstack1.getItemDamage() == j))
    {
        return false;
    }
    else
    {
        par1EntityPlayer.inventory.mainInventory[par1EntityPlayer.inventory.currentItem] = itemstack1;

        if (this.isCreative())
        {
            itemstack1.stackSize = i;

            if (itemstack1.isItemStackDamageable())
            {
                itemstack1.setItemDamage(j);
            }
        }

        if (itemstack1.stackSize == 0)
        {
            par1EntityPlayer.inventory.mainInventory[par1EntityPlayer.inventory.currentItem] = null;
            MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thisPlayerMP, itemstack1));
        }

        if (!par1EntityPlayer.isUsingItem())
        {
            ((EntityPlayerMP)par1EntityPlayer).sendContainerToPlayer(par1EntityPlayer.inventoryContainer);
        }

        return true;
    }
}
项目:RuneCraftery    文件:SlotCrafting.java   
public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack)
{
    GameRegistry.onItemCrafted(par1EntityPlayer, par2ItemStack, craftMatrix);
    this.onCrafting(par2ItemStack);

    for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i)
    {
        ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i);

        if (itemstack1 != null)
        {
            this.craftMatrix.decrStackSize(i, 1);

            if (itemstack1.getItem().hasContainerItem())
            {
                ItemStack itemstack2 = itemstack1.getItem().getContainerItemStack(itemstack1);

                if (itemstack2.isItemStackDamageable() && itemstack2.getItemDamage() > itemstack2.getMaxDamage())
                {
                    MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer, itemstack2));
                    itemstack2 = null;
                }

                if (itemstack2 != null && (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1) || !this.thePlayer.inventory.addItemStackToInventory(itemstack2)))
                {
                    if (this.craftMatrix.getStackInSlot(i) == null)
                    {
                        this.craftMatrix.setInventorySlotContents(i, itemstack2);
                    }
                    else
                    {
                        this.thePlayer.dropPlayerItem(itemstack2);
                    }
                }
            }
        }
    }
}
项目:ForestryLegacy    文件:ItemForestryTool.java   
@ForgeSubscribe
public void onDestroyCurrentItem(PlayerDestroyItemEvent event) {
    if (event.original == null || event.original.getItem() != this)
        return;

    if (Proxies.common.isSimulating(event.entityPlayer.worldObj)) {
        EntityItem entity = new EntityItem(event.entityPlayer.worldObj, event.entityPlayer.posX, event.entityPlayer.posY, event.entityPlayer.posZ,
                remnants.copy());
        event.entityPlayer.worldObj.spawnEntityInWorld(entity);
    }
}
项目:ClockworkPhase    文件:EntityHandler.java   
@SubscribeEvent
public void onItemDestroyed(PlayerDestroyItemEvent event)
{
    ItemStack is = event.original;
    if(NBTHelper.hasTag(is, NBTTags.TEMPORAL_ITEMS))
    {
        ItemStack[] items = NBTHelper.getInventoryFromNBTTag(is, NBTTags.TEMPORAL_ITEMS);
        ItemStack[] newItems = new ItemStack[items.length - 1];
        ItemStack newItem = items[items.length - 1];
        int amountInNew = 0;

        for(int n = 0; n < newItems.length; n++)
        {
            if(items[n] != null)
            {
                newItems[n] = items[amountInNew];
                amountInNew++;
            }
        }
        NBTHelper.setNBTTagListFromInventory(newItem, NBTTags.TEMPORAL_ITEMS, newItems);
        if(event.entityPlayer.inventory.getCurrentItem() == null)
        {
            event.entityPlayer.inventory.setInventorySlotContents(event.entityPlayer.inventory.currentItem, newItem);
        }
        else if(event.entityPlayer.inventory.addItemStackToInventory(newItem))
        {
            return;
        }
        else
        {
            event.entityPlayer.worldObj.spawnEntityInWorld(new EntityItem(event.entityPlayer.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, newItem));
        }
    }
}
项目:ForgeMods    文件:SlotPottery.java   
@Override
public void onPickupFromSlot (EntityPlayer player, ItemStack itemStack) {
    FMLCommonHandler.instance().firePlayerCraftingEvent(player, itemStack, inputInventory);
    onCrafting(itemStack);

    ItemStack itemTarget = inputInventory.getStackInSlot(1);
    if (itemTarget != null) {
        inputInventory.decrStackSize(1, 1);

        if (itemTarget.getItem().hasContainerItem(itemTarget)) {
            ItemStack itemContainer = itemTarget.getItem().getContainerItem(itemTarget);
            if (itemContainer != null && itemContainer.isItemStackDamageable() && itemContainer.getItemDamage() > itemContainer.getMaxDamage()) {
                MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(this.player, itemContainer));
                return;
            }

            if (!itemTarget.getItem().doesContainerItemLeaveCraftingGrid(itemTarget) || !this.player.inventory.addItemStackToInventory(itemContainer)) {
                if (inputInventory.getStackInSlot(1) == null)
                    inputInventory.setInventorySlotContents(1, itemContainer);
                else
                    this.player.dropPlayerItemWithRandomChoice(itemContainer, false);
            }
        }
    }

    ItemStack itemPattern = inputInventory.getStackInSlot(0);
    if (itemPattern != null && itemPattern.getItem() == Items.dye) {
        inputInventory.decrStackSize(0, 1);
    }
}
项目:BetterNutritionMod    文件:EntityPlayer.java   
/**
 * Destroys the currently equipped item from the player's inventory.
 */
public void destroyCurrentEquippedItem()
{
    ItemStack orig = getCurrentEquippedItem();
    this.inventory.setInventorySlotContents(this.inventory.currentItem, (ItemStack)null);
    MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(this, orig));
}
项目:BetterNutritionMod    文件:ItemInWorldManager.java   
/**
 * Attempts to right-click use an item by the given EntityPlayer in the given World
 */
public boolean tryUseItem(EntityPlayer par1EntityPlayer, World par2World, ItemStack par3ItemStack)
{
    int i = par3ItemStack.stackSize;
    int j = par3ItemStack.getItemDamage();
    ItemStack itemstack1 = par3ItemStack.useItemRightClick(par2World, par1EntityPlayer);

    if (itemstack1 == par3ItemStack && (itemstack1 == null || itemstack1.stackSize == i && itemstack1.getMaxItemUseDuration() <= 0 && itemstack1.getItemDamage() == j))
    {
        return false;
    }
    else
    {
        par1EntityPlayer.inventory.mainInventory[par1EntityPlayer.inventory.currentItem] = itemstack1;

        if (this.isCreative())
        {
            itemstack1.stackSize = i;

            if (itemstack1.isItemStackDamageable())
            {
                itemstack1.setItemDamage(j);
            }
        }

        if (itemstack1.stackSize == 0)
        {
            par1EntityPlayer.inventory.mainInventory[par1EntityPlayer.inventory.currentItem] = null;
            MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thisPlayerMP, itemstack1));
        }

        if (!par1EntityPlayer.isUsingItem())
        {
            ((EntityPlayerMP)par1EntityPlayer).sendContainerToPlayer(par1EntityPlayer.inventoryContainer);
        }

        return true;
    }
}
项目:BetterNutritionMod    文件:SlotCrafting.java   
public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack)
{
    GameRegistry.onItemCrafted(par1EntityPlayer, par2ItemStack, craftMatrix);
    this.onCrafting(par2ItemStack);

    for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i)
    {
        ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i);

        if (itemstack1 != null)
        {
            this.craftMatrix.decrStackSize(i, 1);

            if (itemstack1.getItem().hasContainerItem())
            {
                ItemStack itemstack2 = itemstack1.getItem().getContainerItemStack(itemstack1);

                if (itemstack2.isItemStackDamageable() && itemstack2.getItemDamage() > itemstack2.getMaxDamage())
                {
                    MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer, itemstack2));
                    itemstack2 = null;
                }

                if (itemstack2 != null && (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1) || !this.thePlayer.inventory.addItemStackToInventory(itemstack2)))
                {
                    if (this.craftMatrix.getStackInSlot(i) == null)
                    {
                        this.craftMatrix.setInventorySlotContents(i, itemstack2);
                    }
                    else
                    {
                        this.thePlayer.dropPlayerItem(itemstack2);
                    }
                }
            }
        }
    }
}
项目:Veniocraft    文件:SlotComposer.java   
public void onPickupFromSlot(EntityPlayer par1EntityPlayer,ItemStack par2ItemStack){
    GameRegistry.onItemCrafted(par1EntityPlayer,par2ItemStack,craftMatrix);
    this.onCrafting(par2ItemStack);

    for(int i=0;i<this.craftMatrix.getSizeInventory();++i){
        ItemStack itemstack1=this.craftMatrix.getStackInSlot(i);

        if(itemstack1!=null){
            this.craftMatrix.decrStackSize(i,1);

            if(itemstack1.getItem().hasContainerItem()){
                ItemStack itemstack2=itemstack1.getItem().getContainerItemStack(itemstack1);

                if(itemstack2.isItemStackDamageable()&&itemstack2.getItemDamage()>itemstack2.getMaxDamage()){
                    MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer,itemstack2));
                    itemstack2=null;
                }

                if(itemstack2!=null&&(!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1)||!this.thePlayer.inventory.addItemStackToInventory(itemstack2))){
                    if(this.craftMatrix.getStackInSlot(i)==null){
                        this.craftMatrix.setInventorySlotContents(i,itemstack2);
                    }
                    else{
                        this.thePlayer.dropPlayerItem(itemstack2);
                    }
                }
            }
        }
    }
}
项目:Veniocraft    文件:SlotAssembler.java   
public void onPickupFromSlot(EntityPlayer par1EntityPlayer,ItemStack par2ItemStack){
    GameRegistry.onItemCrafted(par1EntityPlayer,par2ItemStack,craftMatrix);
    this.onCrafting(par2ItemStack);

    for(int i=0;i<this.craftMatrix.getSizeInventory();++i){
        ItemStack itemstack1=this.craftMatrix.getStackInSlot(i);

        if(itemstack1!=null){
            this.craftMatrix.decrStackSize(i,1);

            if(itemstack1.getItem().hasContainerItem()){
                ItemStack itemstack2=itemstack1.getItem().getContainerItemStack(itemstack1);

                if(itemstack2.isItemStackDamageable()&&itemstack2.getItemDamage()>itemstack2.getMaxDamage()){
                    MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer,itemstack2));
                    itemstack2=null;
                }

                if(itemstack2!=null&&(!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1)||!this.thePlayer.inventory.addItemStackToInventory(itemstack2))){
                    if(this.craftMatrix.getStackInSlot(i)==null){
                        this.craftMatrix.setInventorySlotContents(i,itemstack2);
                    }
                    else{
                        this.thePlayer.dropPlayerItem(itemstack2);
                    }
                }
            }
        }
    }
}
项目:Necromancy    文件:SlotSewing.java   
@Override
public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack) {
    GameRegistry.onItemCrafted(par1EntityPlayer, par2ItemStack, craftMatrix);
    this.onCrafting(par2ItemStack);

    for (int var3 = 0; var3 < craftMatrix.getSizeInventory(); ++var3) {
        ItemStack var4 = craftMatrix.getStackInSlot(var3);

        if (var4 != null) {
            craftMatrix.decrStackSize(var3, 1);

            if (var4.getItem().hasContainerItem()) {
                ItemStack var5 = var4.getItem().getContainerItemStack(var4);

                if (var5.isItemStackDamageable() && var5.getItemDamage() > var5.getMaxDamage()) {
                    MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer, var5));
                    var5 = null;
                }

                if (var5 != null && (!var4.getItem().doesContainerItemLeaveCraftingGrid(var4) || !thePlayer.inventory.addItemStackToInventory(var5))) {
                    if (craftMatrix.getStackInSlot(var3) == null) {
                        craftMatrix.setInventorySlotContents(var3, var5);
                    } else {
                        thePlayer.dropPlayerItem(var5);
                    }
                }
            }
        }
    }
}
项目:Soul-Forest    文件:SlotIceCrafting.java   
public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack)
{
    ItemCraftedEvent itemCrafted = new ItemCraftedEvent(thePlayer, par2ItemStack, craftMatrix);
    soul_forest.craftHandler.onCrafting(itemCrafted);

    this.onCrafting(par2ItemStack);

    for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i)
    {
        ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i);

        if (itemstack1 != null)
        {
            this.craftMatrix.decrStackSize(i, 1);

            if (itemstack1.getItem().hasContainerItem())
            {
                ItemStack itemstack2 = itemstack1.getItem().getContainerItem(itemstack1);

                if (itemstack2.isItemStackDamageable() && itemstack2.getItemDamage() > itemstack2.getMaxDamage())
                {
                    MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer, itemstack2));
                    itemstack2 = null;
                }

                if (itemstack2 != null && (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1) || !this.thePlayer.inventory.addItemStackToInventory(itemstack2)))
                {
                    if (this.craftMatrix.getStackInSlot(i) == null)
                    {
                        this.craftMatrix.setInventorySlotContents(i, itemstack2);
                    }
                    else
                    {
                        this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false);
                    }
                }
            }
        }
    }
}
项目:CustomWorldGen    文件:ForgeEventFactory.java   
public static void onPlayerDestroyItem(EntityPlayer player, ItemStack stack, EnumHand hand)
{
    MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, stack, hand));
}
项目:4Space-5    文件:EntityPlayer.java   
public void destroyCurrentEquippedItem()
{
    ItemStack orig = getCurrentEquippedItem();
    this.inventory.setInventorySlotContents(this.inventory.currentItem, (ItemStack)null);
    MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(this, orig));
}
项目:4Space-5    文件:PlayerControllerMP.java   
public boolean onPlayerRightClick(EntityPlayer p_78760_1_, World p_78760_2_, ItemStack p_78760_3_, int p_78760_4_, int p_78760_5_, int p_78760_6_, int p_78760_7_, Vec3 p_78760_8_)
{
    syncCurrentPlayItem();
    float f = (float)p_78760_8_.xCoord - p_78760_4_;
    float f1 = (float)p_78760_8_.yCoord - p_78760_5_;
    float f2 = (float)p_78760_8_.zCoord - p_78760_6_;
    boolean flag = false;
    if ((p_78760_3_ != null) && (p_78760_3_.getItem() != null) && (p_78760_3_.getItem().onItemUseFirst(p_78760_3_, p_78760_1_, p_78760_2_, p_78760_4_, p_78760_5_, p_78760_6_, p_78760_7_, f, f1, f2))) {
        return true;
    }
    if ((!p_78760_1_.isSneaking()) || (p_78760_1_.getHeldItem() == null) || (p_78760_1_.getHeldItem().getItem().doesSneakBypassUse(p_78760_2_, p_78760_4_, p_78760_5_, p_78760_6_, p_78760_1_))) {
        flag = p_78760_2_.getBlock(p_78760_4_, p_78760_5_, p_78760_6_).onBlockActivated(p_78760_2_, p_78760_4_, p_78760_5_, p_78760_6_, p_78760_1_, p_78760_7_, f, f1, f2);
    }
    if ((!flag) && (p_78760_3_ != null) && ((p_78760_3_.getItem() instanceof ItemBlock)))
    {
        ItemBlock itemblock = (ItemBlock)p_78760_3_.getItem();
        if (!itemblock.func_150936_a(p_78760_2_, p_78760_4_, p_78760_5_, p_78760_6_, p_78760_7_, p_78760_1_, p_78760_3_)) {
            return false;
        }
    }
    this.netClientHandler.addToSendQueue(new C08PacketPlayerBlockPlacement(p_78760_4_, p_78760_5_, p_78760_6_, p_78760_7_, p_78760_1_.inventory.getCurrentItem(), f, f1, f2));
    if (flag) {
        return true;
    }
    if (p_78760_3_ == null) {
        return false;
    }
    if (this.currentGameType.isCreative())
    {
        int j1 = p_78760_3_.getItemDamage();
        int i1 = p_78760_3_.stackSize;
        boolean flag1 = p_78760_3_.tryPlaceItemIntoWorld(p_78760_1_, p_78760_2_, p_78760_4_, p_78760_5_, p_78760_6_, p_78760_7_, f, f1, f2);
        p_78760_3_.setItemDamage(j1);
        p_78760_3_.stackSize = i1;
        return flag1;
    }
    if (!p_78760_3_.tryPlaceItemIntoWorld(p_78760_1_, p_78760_2_, p_78760_4_, p_78760_5_, p_78760_6_, p_78760_7_, f, f1, f2)) {
        return false;
    }
    if (p_78760_3_.stackSize <= 0) {
        MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(p_78760_1_, p_78760_3_));
    }
    return true;
}
项目:TRHS_Club_Mod_2016    文件:ForgeEventFactory.java   
public static void onPlayerDestroyItem(EntityPlayer player, ItemStack stack)
{
    MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, stack));
}
项目:Malgra    文件:Extractor.java   
@SubscribeEvent
public void onItemBroken(PlayerDestroyItemEvent event) {
    if (event.getOriginal().equals(new ItemStack(this))) {
        //TODO Broken state
    }
}
项目:ARKCraft    文件:PlayerCommonEventHandler.java   
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onDestroyItem(PlayerDestroyItemEvent event)
{
    updateWeight(event.getEntityPlayer());
}
项目:CauldronGit    文件:ForgeEventFactory.java   
public static void onPlayerDestroyItem(EntityPlayer player, ItemStack stack)
{
    MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, stack));
}
项目:morecommands    文件:CommandInfiniteitems.java   
public void onEvent2(PlayerDestroyItemEvent event) {
    this.onDestroy(event);
}