当前位置: 首页>>代码示例>>Java>>正文


Java EntityPlayer.destroyCurrentEquippedItem方法代码示例

本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.destroyCurrentEquippedItem方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.destroyCurrentEquippedItem方法的具体用法?Java EntityPlayer.destroyCurrentEquippedItem怎么用?Java EntityPlayer.destroyCurrentEquippedItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.entity.player.EntityPlayer的用法示例。


在下文中一共展示了EntityPlayer.destroyCurrentEquippedItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: damageItem

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * 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;
            }
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:36,代码来源:ItemStack.java

示例2: breakWeapon

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
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);
}
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:29,代码来源:Seedling.java


注:本文中的net.minecraft.entity.player.EntityPlayer.destroyCurrentEquippedItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。