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


Java EntityLiving.getSlotForItemStack方法代码示例

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


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

示例1: onItemRightClick

import net.minecraft.entity.EntityLiving; //导入方法依赖的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

示例2: dispenseArmor

import net.minecraft.entity.EntityLiving; //导入方法依赖的package包/类
public static ItemStack dispenseArmor(IBlockSource blockSource, ItemStack stack)
{
    BlockPos blockpos = blockSource.getBlockPos().offset((EnumFacing)blockSource.getBlockState().getValue(BlockDispenser.FACING));
    List<EntityLivingBase> list = blockSource.getWorld().<EntityLivingBase>getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(blockpos), Predicates.<EntityLivingBase> and (EntitySelectors.NOT_SPECTATING, new EntitySelectors.ArmoredMob(stack)));

    if (list.isEmpty())
    {
        return ItemStack.field_190927_a;
    }
    else
    {
        EntityLivingBase entitylivingbase = (EntityLivingBase)list.get(0);
        EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(stack);
        ItemStack itemstack = stack.splitStack(1);
        entitylivingbase.setItemStackToSlot(entityequipmentslot, itemstack);

        if (entitylivingbase instanceof EntityLiving)
        {
            ((EntityLiving)entitylivingbase).setDropChance(entityequipmentslot, 2.0F);
        }

        return stack;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:25,代码来源:ItemArmor.java

示例3: onItemRightClick

import net.minecraft.entity.EntityLiving; //导入方法依赖的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: dispenseArmor

import net.minecraft.entity.EntityLiving; //导入方法依赖的package包/类
public static ItemStack dispenseArmor(IBlockSource blockSource, ItemStack stack)
{
    BlockPos blockpos = blockSource.getBlockPos().offset((EnumFacing)blockSource.getBlockState().getValue(BlockDispenser.FACING));
    List<EntityLivingBase> list = blockSource.getWorld().<EntityLivingBase>getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(blockpos), Predicates.<EntityLivingBase>and(EntitySelectors.NOT_SPECTATING, new EntitySelectors.ArmoredMob(stack)));

    if (list.isEmpty())
    {
        return null;
    }
    else
    {
        EntityLivingBase entitylivingbase = (EntityLivingBase)list.get(0);
        EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(stack);
        ItemStack itemstack = stack.copy();
        itemstack.stackSize = 1;
        entitylivingbase.setItemStackToSlot(entityequipmentslot, itemstack);

        if (entitylivingbase instanceof EntityLiving)
        {
            ((EntityLiving)entitylivingbase).setDropChance(entityequipmentslot, 2.0F);
        }

        --stack.stackSize;
        return stack;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:27,代码来源:ItemArmor.java

示例5: replaceItemInInventory

import net.minecraft.entity.EntityLiving; //导入方法依赖的package包/类
public boolean replaceItemInInventory(int inventorySlot, ItemStack itemStackIn)
{
    if (inventorySlot >= 0 && inventorySlot < this.inventory.mainInventory.size())
    {
        this.inventory.setInventorySlotContents(inventorySlot, itemStackIn);
        return true;
    }
    else
    {
        EntityEquipmentSlot entityequipmentslot;

        if (inventorySlot == 100 + EntityEquipmentSlot.HEAD.getIndex())
        {
            entityequipmentslot = EntityEquipmentSlot.HEAD;
        }
        else if (inventorySlot == 100 + EntityEquipmentSlot.CHEST.getIndex())
        {
            entityequipmentslot = EntityEquipmentSlot.CHEST;
        }
        else if (inventorySlot == 100 + EntityEquipmentSlot.LEGS.getIndex())
        {
            entityequipmentslot = EntityEquipmentSlot.LEGS;
        }
        else if (inventorySlot == 100 + EntityEquipmentSlot.FEET.getIndex())
        {
            entityequipmentslot = EntityEquipmentSlot.FEET;
        }
        else
        {
            entityequipmentslot = null;
        }

        if (inventorySlot == 98)
        {
            this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, itemStackIn);
            return true;
        }
        else if (inventorySlot == 99)
        {
            this.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, itemStackIn);
            return true;
        }
        else if (entityequipmentslot == null)
        {
            int i = inventorySlot - 200;

            if (i >= 0 && i < this.theInventoryEnderChest.getSizeInventory())
            {
                this.theInventoryEnderChest.setInventorySlotContents(i, itemStackIn);
                return true;
            }
            else
            {
                return false;
            }
        }
        else
        {
            if (!itemStackIn.func_190926_b())
            {
                if (!(itemStackIn.getItem() instanceof ItemArmor) && !(itemStackIn.getItem() instanceof ItemElytra))
                {
                    if (entityequipmentslot != EntityEquipmentSlot.HEAD)
                    {
                        return false;
                    }
                }
                else if (EntityLiving.getSlotForItemStack(itemStackIn) != entityequipmentslot)
                {
                    return false;
                }
            }

            this.inventory.setInventorySlotContents(entityequipmentslot.getIndex() + this.inventory.mainInventory.size(), itemStackIn);
            return true;
        }
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:79,代码来源:EntityPlayer.java

示例6: applyPlayerInteraction

import net.minecraft.entity.EntityLiving; //导入方法依赖的package包/类
/**
 * Applies the given player interaction to this Entity.
 */
public EnumActionResult applyPlayerInteraction(EntityPlayer player, Vec3d vec, EnumHand stack)
{
    ItemStack itemstack = player.getHeldItem(stack);

    if (!this.hasMarker() && itemstack.getItem() != Items.NAME_TAG)
    {
        if (!this.world.isRemote && !player.isSpectator())
        {
            EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(itemstack);

            if (itemstack.func_190926_b())
            {
                EntityEquipmentSlot entityequipmentslot1 = this.func_190772_a(vec);
                EntityEquipmentSlot entityequipmentslot2 = this.isDisabled(entityequipmentslot1) ? entityequipmentslot : entityequipmentslot1;

                if (this.func_190630_a(entityequipmentslot2))
                {
                    this.swapItem(player, entityequipmentslot2, itemstack, stack);
                }
            }
            else
            {
                if (this.isDisabled(entityequipmentslot))
                {
                    return EnumActionResult.FAIL;
                }

                if (entityequipmentslot.getSlotType() == EntityEquipmentSlot.Type.HAND && !this.getShowArms())
                {
                    return EnumActionResult.FAIL;
                }

                this.swapItem(player, entityequipmentslot, itemstack, stack);
            }

            return EnumActionResult.SUCCESS;
        }
        else
        {
            return EnumActionResult.SUCCESS;
        }
    }
    else
    {
        return EnumActionResult.PASS;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:51,代码来源:EntityArmorStand.java

示例7: transferStackInSlot

import net.minecraft.entity.EntityLiving; //导入方法依赖的package包/类
/**
 * Take a stack from the specified inventory slot.
 */
@Override
@Nullable
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
	ItemStack itemstack = ItemStack.EMPTY;
	Slot slot = this.inventorySlots.get(index);

	if (slot != null && slot.getHasStack()) {
		ItemStack itemstack1 = slot.getStack();
		itemstack = itemstack1.copy();
		EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(itemstack);

		if (index >= 0 && index < 4) {
			if (!this.mergeItemStack(itemstack1, 8, 44, false))
				return ItemStack.EMPTY;
		} else if (index >= 4 && index < 7) {
			if (!this.mergeItemStack(itemstack1, 8, 44, false))
				return ItemStack.EMPTY;
		} else if (entityequipmentslot.getSlotType() == EntityEquipmentSlot.Type.ARMOR
				&& !this.inventorySlots.get(4 - entityequipmentslot.getIndex()).getHasStack()) {
			int i = 4 - entityequipmentslot.getIndex();

			if (!this.mergeItemStack(itemstack1, i, i + 1, false))
				return ItemStack.EMPTY;
		} else if (entityequipmentslot == EntityEquipmentSlot.OFFHAND
				&& !this.inventorySlots.get(44).getHasStack()) {
			if (!this.mergeItemStack(itemstack1, 44, 45, false))
				return ItemStack.EMPTY;
		} else if (itemstack1.getItem() instanceof ItemAmmoBelt
				&& !this.inventorySlots.get(7).getHasStack()) {
			if (!this.mergeItemStack(itemstack1, 7, 8, false))
				return ItemStack.EMPTY;
		} else if (itemstack1.getItem() instanceof ItemWearable && index >= 8) {
			if (!this.mergeItemStack(itemstack1, 4, 7, false))
				return ItemStack.EMPTY;
		} else if (itemstack1.getItem() instanceof ItemAmmo && ammoBelt && index < 44) {
			if (!this.mergeItemStack(itemstack1, 45, 54, false))
				return ItemStack.EMPTY;
		} else if (index >= 8 && index < 35) {
			if (!this.mergeItemStack(itemstack1, 35, 44, false))
				return ItemStack.EMPTY;
		} else if (index >= 35 && index < 44) {
			if (!this.mergeItemStack(itemstack1, 8, 35, false))
				return ItemStack.EMPTY;
		} else if (!this.mergeItemStack(itemstack1, 8, 44, false))
			return ItemStack.EMPTY;

		if (itemstack1.isEmpty())
			slot.putStack(ItemStack.EMPTY);
		else
			slot.onSlotChanged();

		if (itemstack1.getCount() ==itemstack.getCount())
			return ItemStack.EMPTY;

		slot.onTake(playerIn, itemstack1);
	}

	return itemstack;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:63,代码来源:ContainerWearables.java

示例8: transferStackInSlot

import net.minecraft.entity.EntityLiving; //导入方法依赖的package包/类
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
{
    ItemStack itemstack = ItemStack.EMPTY;
    Slot slot = this.inventorySlots.get(index);

    if (slot != null && slot.getHasStack())
    {
        ItemStack itemstack1 = slot.getStack();
        itemstack = itemstack1.copy();
        EntityEquipmentSlot equip = EntityLiving.getSlotForItemStack(itemstack);
        
        if (index == 2)
        {
            if (!this.mergeItemStack(itemstack1, 3, 39, true))
            {
                return ItemStack.EMPTY;
            }

            slot.onSlotChange(itemstack1, itemstack);
        }
        else if (index != 0 && index != 1)
        {
        	if (equip.getSlotType() == EntityEquipmentSlot.Type.ARMOR && !(index >= 40 && index < 44)) {
        		if(!this.mergeItemStack(itemstack1, 43-equip.getIndex(), 44-equip.getIndex(), false))
        			return ItemStack.EMPTY;
        	}
        	else if (itemstack1.getItem() instanceof ItemUsable && !(index >= 44 && index < 47) ) {
        		for(int i = 0; i < 3; i++) {
        			if(!this.getSlot(i + 44).isItemValid(itemstack1) || !this.mergeItemStack(itemstack1, i + 44, i + 45, false))
        				return ItemStack.EMPTY;
        		}
        	}
        	else if (index >= 3 && index < 30)
            {
                if (!this.mergeItemStack(itemstack1, 30, 39, false))
                {
                    return ItemStack.EMPTY;
                }
            }
            else if (index >= 30 && index < 39 && !this.mergeItemStack(itemstack1, 3, 30, false))
            {
                return ItemStack.EMPTY;
            }
        }
        else if (!this.mergeItemStack(itemstack1, 3, 39, false))
        {
            return ItemStack.EMPTY;
        }

        if (itemstack1.isEmpty())
        {
            slot.putStack(ItemStack.EMPTY);
        }
        else
        {
            slot.onSlotChanged();
        }

        if (itemstack1.getCount() == itemstack.getCount())
        {
            return ItemStack.EMPTY;
        }

        slot.onTake(playerIn, itemstack1);
    }

    return itemstack;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:69,代码来源:ContainerMercenary.java

示例9: replaceItemInInventory

import net.minecraft.entity.EntityLiving; //导入方法依赖的package包/类
public boolean replaceItemInInventory(int inventorySlot, ItemStack itemStackIn)
{
    if (inventorySlot >= 0 && inventorySlot < this.inventory.mainInventory.length)
    {
        this.inventory.setInventorySlotContents(inventorySlot, itemStackIn);
        return true;
    }
    else
    {
        EntityEquipmentSlot entityequipmentslot;

        if (inventorySlot == 100 + EntityEquipmentSlot.HEAD.getIndex())
        {
            entityequipmentslot = EntityEquipmentSlot.HEAD;
        }
        else if (inventorySlot == 100 + EntityEquipmentSlot.CHEST.getIndex())
        {
            entityequipmentslot = EntityEquipmentSlot.CHEST;
        }
        else if (inventorySlot == 100 + EntityEquipmentSlot.LEGS.getIndex())
        {
            entityequipmentslot = EntityEquipmentSlot.LEGS;
        }
        else if (inventorySlot == 100 + EntityEquipmentSlot.FEET.getIndex())
        {
            entityequipmentslot = EntityEquipmentSlot.FEET;
        }
        else
        {
            entityequipmentslot = null;
        }

        if (inventorySlot == 98)
        {
            this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, itemStackIn);
            return true;
        }
        else if (inventorySlot == 99)
        {
            this.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, itemStackIn);
            return true;
        }
        else if (entityequipmentslot == null)
        {
            int i = inventorySlot - 200;

            if (i >= 0 && i < this.theInventoryEnderChest.getSizeInventory())
            {
                this.theInventoryEnderChest.setInventorySlotContents(i, itemStackIn);
                return true;
            }
            else
            {
                return false;
            }
        }
        else
        {
            if (itemStackIn != null && itemStackIn.getItem() != null)
            {
                if (!(itemStackIn.getItem() instanceof ItemArmor) && !(itemStackIn.getItem() instanceof ItemElytra))
                {
                    if (entityequipmentslot != EntityEquipmentSlot.HEAD)
                    {
                        return false;
                    }
                }
                else if (EntityLiving.getSlotForItemStack(itemStackIn) != entityequipmentslot)
                {
                    return false;
                }
            }

            this.inventory.setInventorySlotContents(entityequipmentslot.getIndex() + this.inventory.mainInventory.length, itemStackIn);
            return true;
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:79,代码来源:EntityPlayer.java


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