本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.swingItem方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.swingItem方法的具体用法?Java EntityPlayer.swingItem怎么用?Java EntityPlayer.swingItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.player.EntityPlayer
的用法示例。
在下文中一共展示了EntityPlayer.swingItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: interact
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
protected boolean interact(EntityPlayer player)
{
ItemStack itemstack = player.inventory.getCurrentItem();
if (itemstack != null && itemstack.getItem() == Items.flint_and_steel)
{
this.worldObj.playSoundEffect(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D, "fire.ignite", 1.0F, this.rand.nextFloat() * 0.4F + 0.8F);
player.swingItem();
if (!this.worldObj.isRemote)
{
this.ignite();
itemstack.damageItem(1, player);
return true;
}
}
return super.interact(player);
}
示例2: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
if (playerIn.fishEntity != null)
{
int i = playerIn.fishEntity.handleHookRetraction();
itemStackIn.damageItem(i, playerIn);
playerIn.swingItem();
}
else
{
worldIn.playSoundAtEntity(playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!worldIn.isRemote)
{
worldIn.spawnEntityInWorld(new EntityFishHook(worldIn, playerIn));
}
playerIn.swingItem();
playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
}
return itemStackIn;
}
示例3: feedBaby
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
private void feedBaby(EntityAnimal animal, EntityPlayer player, ItemStack stack) {
int currentAge = animal.getGrowingAge();
int age = (int) (-currentAge * 0.1F);
animal.setGrowingAge(currentAge + age);
player.swingItem();
Random itemRand = animal.worldObj.rand;
for (int i = 0; i < 3; i++) {
double d0 = itemRand.nextGaussian() * 0.02D;
double d1 = itemRand.nextGaussian() * 0.02D;
double d2 = itemRand.nextGaussian() * 0.02D;
animal.worldObj.spawnParticle("happyVillager", animal.posX + itemRand.nextFloat() * 0.5, animal.posY + 0.5 + itemRand.nextFloat() * 0.5, animal.posZ + itemRand.nextFloat() * 0.5, d0, d1, d2);
}
if (!player.capabilities.isCreativeMode)
if (--stack.stackSize <= 0)
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}