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


Java EntityPlayer.setItemStackToSlot方法代码示例

本文整理汇总了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!");
	}

}
 
开发者ID:orbwoi,项目名称:UniversalRemote,代码行数:20,代码来源:Util.java

示例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);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:18,代码来源:ItemElytra.java

示例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);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:17,代码来源:ItemElytra.java

示例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);
	}
}
 
开发者ID:sblectric,项目名称:AdvancedCombat,代码行数:20,代码来源:CustomShieldHandler.java


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