本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.setItemStackToSlot方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.setItemStackToSlot方法的具体用法?Java EntityPlayer.setItemStackToSlot怎么用?Java EntityPlayer.setItemStackToSlot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.player.EntityPlayer
的用法示例。
在下文中一共展示了EntityPlayer.setItemStackToSlot方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setPlayerItemStackInHand
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static void setPlayerItemStackInHand(ItemStack stack, EntityPlayer player, EnumHand hand)
{
// okay, find the itemstack
if (hand == EnumHand.MAIN_HAND)
{
player.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, stack);
}
else if (hand == EnumHand.OFF_HAND)
{
player.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, stack);
}
else
{
// uhh... what?
Util.logger.error("Found invalid EnumHand value!");
}
}
示例2: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
ItemStack itemstack = worldIn.getHeldItem(playerIn);
EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(itemstack);
ItemStack itemstack1 = worldIn.getItemStackFromSlot(entityequipmentslot);
if (itemstack1.func_190926_b())
{
worldIn.setItemStackToSlot(entityequipmentslot, itemstack.copy());
itemstack.func_190920_e(0);
return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
else
{
return new ActionResult(EnumActionResult.FAIL, itemstack);
}
}
示例3: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(itemStackIn);
ItemStack itemstack = playerIn.getItemStackFromSlot(entityequipmentslot);
if (itemstack == null)
{
playerIn.setItemStackToSlot(entityequipmentslot, itemStackIn.copy());
itemStackIn.stackSize = 0;
return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
else
{
return new ActionResult(EnumActionResult.FAIL, itemStackIn);
}
}
示例4: damageShield
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/** Fixed vanilla code */
private void damageShield(EntityPlayer owner, float damage) {
int i = 1 + MathHelper.floor(damage);
owner.getActiveItemStack().damageItem(i, owner);
if (owner.getActiveItemStack().getCount() <= 0) {
EnumHand enumhand = owner.getActiveHand();
ForgeEventFactory.onPlayerDestroyItem(owner, owner.getActiveItemStack(), enumhand);
if(enumhand == EnumHand.MAIN_HAND) {
owner.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemStack.EMPTY);
} else {
owner.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, ItemStack.EMPTY);
}
owner.resetActiveHand();
owner.playSound(SoundEvents.ITEM_SHIELD_BREAK, 0.8F, 0.8F + owner.world.rand.nextFloat() * 0.4F);
}
}