Java Code Examples for net.minecraft.entity.player.EntityPlayer.destroyCurrentEquippedItem()

The following are Jave code examples for showing how to use destroyCurrentEquippedItem() of the net.minecraft.entity.player.EntityPlayer class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: DecompiledMinecraft   File: ItemStack.java   View Source Code Vote up 5 votes
/**
 * Damages the item in the ItemStack
 */
public void damageItem(int amount, EntityLivingBase entityIn)
{
    if (!(entityIn instanceof EntityPlayer) || !((EntityPlayer)entityIn).capabilities.isCreativeMode)
    {
        if (this.isItemStackDamageable())
        {
            if (this.attemptDamageItem(amount, entityIn.getRNG()))
            {
                entityIn.renderBrokenItemStack(this);
                --this.stackSize;

                if (entityIn instanceof EntityPlayer)
                {
                    EntityPlayer entityplayer = (EntityPlayer)entityIn;
                    entityplayer.triggerAchievement(StatList.objectBreakStats[Item.getIdFromItem(this.item)]);

                    if (this.stackSize == 0 && this.getItem() instanceof ItemBow)
                    {
                        entityplayer.destroyCurrentEquippedItem();
                    }
                }

                if (this.stackSize < 0)
                {
                    this.stackSize = 0;
                }

                this.itemDamage = 0;
            }
        }
    }
}
 
Example 2
Project: DecompiledMinecraft   File: ItemStack.java   View Source Code Vote up 5 votes
/**
 * Damages the item in the ItemStack
 */
public void damageItem(int amount, EntityLivingBase entityIn)
{
    if (!(entityIn instanceof EntityPlayer) || !((EntityPlayer)entityIn).capabilities.isCreativeMode)
    {
        if (this.isItemStackDamageable())
        {
            if (this.attemptDamageItem(amount, entityIn.getRNG()))
            {
                entityIn.renderBrokenItemStack(this);
                --this.stackSize;

                if (entityIn instanceof EntityPlayer)
                {
                    EntityPlayer entityplayer = (EntityPlayer)entityIn;
                    entityplayer.triggerAchievement(StatList.objectBreakStats[Item.getIdFromItem(this.item)]);

                    if (this.stackSize == 0 && this.getItem() instanceof ItemBow)
                    {
                        entityplayer.destroyCurrentEquippedItem();
                    }
                }

                if (this.stackSize < 0)
                {
                    this.stackSize = 0;
                }

                this.itemDamage = 0;
            }
        }
    }
}
 
Example 3
Project: BaseClient   File: ItemStack.java   View Source Code Vote up 5 votes
/**
 * Damages the item in the ItemStack
 */
public void damageItem(int amount, EntityLivingBase entityIn)
{
    if (!(entityIn instanceof EntityPlayer) || !((EntityPlayer)entityIn).capabilities.isCreativeMode)
    {
        if (this.isItemStackDamageable())
        {
            if (this.attemptDamageItem(amount, entityIn.getRNG()))
            {
                entityIn.renderBrokenItemStack(this);
                --this.stackSize;

                if (entityIn instanceof EntityPlayer)
                {
                    EntityPlayer entityplayer = (EntityPlayer)entityIn;
                    entityplayer.triggerAchievement(StatList.objectBreakStats[Item.getIdFromItem(this.item)]);

                    if (this.stackSize == 0 && this.getItem() instanceof ItemBow)
                    {
                        entityplayer.destroyCurrentEquippedItem();
                    }
                }

                if (this.stackSize < 0)
                {
                    this.stackSize = 0;
                }

                this.itemDamage = 0;
            }
        }
    }
}
 
Example 4
Project: BaseClient   File: ItemStack.java   View Source Code Vote up 5 votes
/**
 * Damages the item in the ItemStack
 */
public void damageItem(int amount, EntityLivingBase entityIn)
{
    if (!(entityIn instanceof EntityPlayer) || !((EntityPlayer)entityIn).capabilities.isCreativeMode)
    {
        if (this.isItemStackDamageable())
        {
            if (this.attemptDamageItem(amount, entityIn.getRNG()))
            {
                entityIn.renderBrokenItemStack(this);
                --this.stackSize;

                if (entityIn instanceof EntityPlayer)
                {
                    EntityPlayer entityplayer = (EntityPlayer)entityIn;
                    entityplayer.triggerAchievement(StatList.objectBreakStats[Item.getIdFromItem(this.item)]);

                    if (this.stackSize == 0 && this.getItem() instanceof ItemBow)
                    {
                        entityplayer.destroyCurrentEquippedItem();
                    }
                }

                if (this.stackSize < 0)
                {
                    this.stackSize = 0;
                }

                this.itemDamage = 0;
            }
        }
    }
}
 
Example 5
Project: minecraft-quiverbow   File: Seedling.java   View Source Code Vote up 5 votes
private void breakWeapon(World world, ItemStack stack, Entity entity)
{
	if (!(entity instanceof EntityPlayer)) // For QuiverMobs/Arms Assistants
	{
		this.setCooldown(stack, 40);
		return;
	}
	
	EntityPlayer player = (EntityPlayer) entity;
	
	player.renderBrokenItemStack(stack);
	player.destroyCurrentEquippedItem();	// Breaking
	stack.stackSize = 0;
	
	EntityItem piston = new EntityItem(world, player.posX, player.posY + 1.0F, player.posZ, new ItemStack(Blocks.piston));
	piston.delayBeforeCanPickup = 10;
	
	if (player.captureDrops) { player.capturedDrops.add(piston); }
	else { world.spawnEntityInWorld(piston); }
	
	EntityItem hook = new EntityItem(world, player.posX, player.posY + 1.0F, player.posZ, new ItemStack(Blocks.tripwire_hook));
	hook.delayBeforeCanPickup = 10;
	
	if (player.captureDrops) { player.capturedDrops.add(hook); }
	else { world.spawnEntityInWorld(hook); }
	
	world.playSoundAtEntity(player, "random.break", 1.0F, 1.5F);
}