本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.setItemInUse方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.setItemInUse方法的具体用法?Java EntityPlayer.setItemInUse怎么用?Java EntityPlayer.setItemInUse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.player.EntityPlayer
的用法示例。
在下文中一共展示了EntityPlayer.setItemInUse方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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 (isSplash(itemStackIn.getMetadata()))
{
if (!playerIn.capabilities.isCreativeMode)
{
--itemStackIn.stackSize;
}
worldIn.playSoundAtEntity(playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!worldIn.isRemote)
{
worldIn.spawnEntityInWorld(new EntityPotion(worldIn, playerIn, itemStackIn));
}
playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
return itemStackIn;
}
else
{
playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
return itemStackIn;
}
}
示例2: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public ItemStack onItemRightClick(ItemStack is, World world, EntityPlayer player)
{
ArrowNockEvent event = new ArrowNockEvent(player, is);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled())
return event.result;
if (player.capabilities.isCreativeMode || player.inventory.hasItem(ModItems.itemSharpStone) || player.inventory.hasItem(ModItems.itemHardStone) || player.inventory.hasItem(ModItems.itemSoftStone) )
player.setItemInUse(is, this.getMaxItemUseDuration(is));
return is;
}
示例3: 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.canEat(this.alwaysEdible))
{
playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
}
return itemStackIn;
}
示例4: 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.capabilities.isCreativeMode || playerIn.inventory.hasItem(Items.arrow))
{
playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
}
return itemStackIn;
}
示例5: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
ArrowNockEvent event = new ArrowNockEvent(player, stack);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled()) { return event.result; }
if (player.capabilities.isCreativeMode || player.inventory.hasItemStack( new ItemStack(Items.arrow) ) )
{
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
this.playerName = player.getDisplayName(); // Recording the player name here, so only they can see the projectile
}
return stack;
}
示例6: 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)
{
playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
return itemStackIn;
}
示例7: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
ArrowNockEvent event = new ArrowNockEvent(player, stack);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled()) { return event.result; }
// Are there any arrows in the quiver?
if (this.getDamage(stack) < this.getMaxDamage()) { player.setItemInUse(stack, this.getMaxItemUseDuration(stack)); }
return stack;
}