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


Java ItemStack.interactWithEntity方法代码示例

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


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

示例1: processInteract

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public boolean processInteract(EntityPlayer player, EnumHand hand)
{
    ItemStack itemstack = player.getHeldItem(hand);
    boolean flag = itemstack.getItem() == Items.NAME_TAG;

    if (flag)
    {
        itemstack.interactWithEntity(player, this, hand);
        return true;
    }
    else if (!this.func_190669_a(itemstack, this.getClass()) && this.isEntityAlive() && !this.isTrading() && !this.isChild())
    {
        if (this.buyingList == null)
        {
            this.populateBuyingList();
        }

        if (hand == EnumHand.MAIN_HAND)
        {
            player.addStat(StatList.TALKED_TO_VILLAGER);
        }

        if (!this.world.isRemote && !this.buyingList.isEmpty())
        {
            this.setCustomer(player);
            player.displayVillagerTradeGui(this);
        }
        else if (this.buyingList.isEmpty())
        {
            return super.processInteract(player, hand);
        }

        return true;
    }
    else
    {
        return super.processInteract(player, hand);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:40,代码来源:EntityVillager.java

示例2: processInteract

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public boolean processInteract(EntityPlayer player, EnumHand hand)
{
    if (!super.processInteract(player, hand))
    {
        ItemStack itemstack = player.getHeldItem(hand);

        if (itemstack.getItem() == Items.NAME_TAG)
        {
            itemstack.interactWithEntity(player, this, hand);
            return true;
        }
        else if (this.getSaddled() && !this.isBeingRidden())
        {
            if (!this.world.isRemote)
            {
                player.startRiding(this);
            }

            return true;
        }
        else if (itemstack.getItem() == Items.SADDLE)
        {
            itemstack.interactWithEntity(player, this, hand);
            return true;
        }
        else
        {
            return false;
        }
    }
    else
    {
        return true;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:36,代码来源:EntityPig.java

示例3: interactWith

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public boolean interactWith(Entity p_70998_1_)
{
    if (this.isSpectator())
    {
        if (p_70998_1_ instanceof IInventory)
        {
            this.displayGUIChest((IInventory)p_70998_1_);
        }

        return false;
    }
    else
    {
        ItemStack itemstack = this.getCurrentEquippedItem();
        ItemStack itemstack1 = itemstack != null ? itemstack.copy() : null;

        if (!p_70998_1_.interactFirst(this))
        {
            if (itemstack != null && p_70998_1_ instanceof EntityLivingBase)
            {
                if (this.capabilities.isCreativeMode)
                {
                    itemstack = itemstack1;
                }

                if (itemstack.interactWithEntity(this, (EntityLivingBase)p_70998_1_))
                {
                    if (itemstack.stackSize <= 0 && !this.capabilities.isCreativeMode)
                    {
                        this.destroyCurrentEquippedItem();
                    }

                    return true;
                }
            }

            return false;
        }
        else
        {
            if (itemstack != null && itemstack == this.getCurrentEquippedItem())
            {
                if (itemstack.stackSize <= 0 && !this.capabilities.isCreativeMode)
                {
                    this.destroyCurrentEquippedItem();
                }
                else if (itemstack.stackSize < itemstack1.stackSize && this.capabilities.isCreativeMode)
                {
                    itemstack.stackSize = itemstack1.stackSize;
                }
            }

            return true;
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:57,代码来源:EntityPlayer.java

示例4: func_190775_a

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public EnumActionResult func_190775_a(Entity p_190775_1_, EnumHand p_190775_2_)
{
    if (this.isSpectator())
    {
        if (p_190775_1_ instanceof IInventory)
        {
            this.displayGUIChest((IInventory)p_190775_1_);
        }

        return EnumActionResult.PASS;
    }
    else
    {
        ItemStack itemstack = this.getHeldItem(p_190775_2_);
        ItemStack itemstack1 = itemstack.func_190926_b() ? ItemStack.field_190927_a : itemstack.copy();

        if (p_190775_1_.processInitialInteract(this, p_190775_2_))
        {
            if (this.capabilities.isCreativeMode && itemstack == this.getHeldItem(p_190775_2_) && itemstack.func_190916_E() < itemstack1.func_190916_E())
            {
                itemstack.func_190920_e(itemstack1.func_190916_E());
            }

            return EnumActionResult.SUCCESS;
        }
        else
        {
            if (!itemstack.func_190926_b() && p_190775_1_ instanceof EntityLivingBase)
            {
                if (this.capabilities.isCreativeMode)
                {
                    itemstack = itemstack1;
                }

                if (itemstack.interactWithEntity(this, (EntityLivingBase)p_190775_1_, p_190775_2_))
                {
                    if (itemstack.func_190926_b() && !this.capabilities.isCreativeMode)
                    {
                        this.setHeldItem(p_190775_2_, ItemStack.field_190927_a);
                    }

                    return EnumActionResult.SUCCESS;
                }
            }

            return EnumActionResult.PASS;
        }
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:50,代码来源:EntityPlayer.java

示例5: processInteract

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public boolean processInteract(EntityPlayer player, EnumHand hand)
{
    ItemStack itemstack = player.getHeldItem(hand);
    boolean flag = !itemstack.func_190926_b();

    if (flag && itemstack.getItem() == Items.SPAWN_EGG)
    {
        return super.processInteract(player, hand);
    }
    else if (!this.isTame())
    {
        return false;
    }
    else if (this.isChild())
    {
        return super.processInteract(player, hand);
    }
    else if (player.isSneaking())
    {
        this.openGUI(player);
        return true;
    }
    else if (this.isBeingRidden())
    {
        return super.processInteract(player, hand);
    }
    else
    {
        if (flag)
        {
            if (itemstack.getItem() == Items.SADDLE && !this.isHorseSaddled())
            {
                this.openGUI(player);
                return true;
            }

            if (itemstack.interactWithEntity(player, this, hand))
            {
                return true;
            }
        }

        this.mountTo(player);
        return true;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:47,代码来源:EntitySkeletonHorse.java

示例6: processInteract

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public boolean processInteract(EntityPlayer player, EnumHand hand)
{
    ItemStack itemstack = player.getHeldItem(hand);

    if (itemstack.getItem() == Items.SPAWN_EGG)
    {
        return super.processInteract(player, hand);
    }
    else
    {
        if (!this.isChild())
        {
            if (this.isTame() && player.isSneaking())
            {
                this.openGUI(player);
                return true;
            }

            if (this.isBeingRidden())
            {
                return super.processInteract(player, hand);
            }
        }

        if (!itemstack.func_190926_b())
        {
            boolean flag = this.func_190678_b(player, itemstack);

            if (!flag && !this.isTame())
            {
                if (itemstack.interactWithEntity(player, this, hand))
                {
                    return true;
                }

                this.func_190687_dF();
                return true;
            }

            if (!flag && !this.func_190695_dh() && itemstack.getItem() == Item.getItemFromBlock(Blocks.CHEST))
            {
                this.setChested(true);
                this.func_190697_dk();
                flag = true;
                this.initHorseChest();
            }

            if (!flag && !this.isChild() && !this.isHorseSaddled() && itemstack.getItem() == Items.SADDLE)
            {
                this.openGUI(player);
                return true;
            }

            if (flag)
            {
                if (!player.capabilities.isCreativeMode)
                {
                    itemstack.func_190918_g(1);
                }

                return true;
            }
        }

        if (this.isChild())
        {
            return super.processInteract(player, hand);
        }
        else if (itemstack.interactWithEntity(player, this, hand))
        {
            return true;
        }
        else
        {
            this.mountTo(player);
            return true;
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:80,代码来源:AbstractChestHorse.java

示例7: processInteract

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public boolean processInteract(EntityPlayer player, EnumHand hand)
{
    ItemStack itemstack = player.getHeldItem(hand);
    boolean flag = !itemstack.func_190926_b();

    if (flag && itemstack.getItem() == Items.SPAWN_EGG)
    {
        return super.processInteract(player, hand);
    }
    else if (!this.isTame())
    {
        return false;
    }
    else if (this.isChild())
    {
        return super.processInteract(player, hand);
    }
    else if (player.isSneaking())
    {
        this.openGUI(player);
        return true;
    }
    else if (this.isBeingRidden())
    {
        return super.processInteract(player, hand);
    }
    else
    {
        if (flag)
        {
            if (!this.isHorseSaddled() && itemstack.getItem() == Items.SADDLE)
            {
                this.openGUI(player);
                return true;
            }

            if (itemstack.interactWithEntity(player, this, hand))
            {
                return true;
            }
        }

        this.mountTo(player);
        return true;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:47,代码来源:EntityZombieHorse.java

示例8: processInteract

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public boolean processInteract(EntityPlayer player, EnumHand hand)
{
    ItemStack itemstack = player.getHeldItem(hand);
    boolean flag = !itemstack.func_190926_b();

    if (flag && itemstack.getItem() == Items.SPAWN_EGG)
    {
        return super.processInteract(player, hand);
    }
    else
    {
        if (!this.isChild())
        {
            if (this.isTame() && player.isSneaking())
            {
                this.openGUI(player);
                return true;
            }

            if (this.isBeingRidden())
            {
                return super.processInteract(player, hand);
            }
        }

        if (flag)
        {
            if (this.func_190678_b(player, itemstack))
            {
                if (!player.capabilities.isCreativeMode)
                {
                    itemstack.func_190918_g(1);
                }

                return true;
            }

            if (itemstack.interactWithEntity(player, this, hand))
            {
                return true;
            }

            if (!this.isTame())
            {
                this.func_190687_dF();
                return true;
            }

            boolean flag1 = HorseArmorType.getByItemStack(itemstack) != HorseArmorType.NONE;
            boolean flag2 = !this.isChild() && !this.isHorseSaddled() && itemstack.getItem() == Items.SADDLE;

            if (flag1 || flag2)
            {
                this.openGUI(player);
                return true;
            }
        }

        if (this.isChild())
        {
            return super.processInteract(player, hand);
        }
        else
        {
            this.mountTo(player);
            return true;
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:70,代码来源:EntityHorse.java

示例9: interact

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public EnumActionResult interact(Entity entityIn, @Nullable ItemStack stack, EnumHand hand)
{
    if (this.isSpectator())
    {
        if (entityIn instanceof IInventory)
        {
            this.displayGUIChest((IInventory)entityIn);
        }

        return EnumActionResult.PASS;
    }
    else
    {
        if (net.minecraftforge.common.ForgeHooks.onInteractEntity(this, entityIn, stack, hand)) return EnumActionResult.PASS;
        ItemStack itemstack = stack != null ? stack.copy() : null;

        if (!entityIn.processInitialInteract(this, stack, hand))
        {
            if (stack != null && entityIn instanceof EntityLivingBase)
            {
                if (this.capabilities.isCreativeMode)
                {
                    stack = itemstack;
                }

                if (stack.interactWithEntity(this, (EntityLivingBase)entityIn, hand))
                {
                    if (stack.stackSize <= 0 && !this.capabilities.isCreativeMode)
                    {
                        net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, stack, hand);
                        this.setHeldItem(hand, (ItemStack)null);
                    }

                    return EnumActionResult.SUCCESS;
                }
            }

            return EnumActionResult.PASS;
        }
        else
        {
            if (stack != null && stack == this.getHeldItem(hand))
            {
                if (stack.stackSize <= 0 && !this.capabilities.isCreativeMode)
                {
                    net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, stack, hand);
                    this.setHeldItem(hand, (ItemStack)null);
                }
                else if (stack.stackSize < itemstack.stackSize && this.capabilities.isCreativeMode)
                {
                    stack.stackSize = itemstack.stackSize;
                }
            }

            return EnumActionResult.SUCCESS;
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:59,代码来源:EntityPlayer.java


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