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


Java ItemStack.func_190918_g方法代码示例

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


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

示例1: smeltItem

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Turn one item from the furnace source stack into the appropriate smelted item in the furnace result stack
 */
public void smeltItem()
{
    if (this.canSmelt())
    {
        ItemStack itemstack = (ItemStack)this.furnaceItemStacks.get(0);
        ItemStack itemstack1 = FurnaceRecipes.instance().getSmeltingResult(itemstack);
        ItemStack itemstack2 = (ItemStack)this.furnaceItemStacks.get(2);

        if (itemstack2.func_190926_b())
        {
            this.furnaceItemStacks.set(2, itemstack1.copy());
        }
        else if (itemstack2.getItem() == itemstack1.getItem())
        {
            itemstack2.func_190917_f(1);
        }

        if (itemstack.getItem() == Item.getItemFromBlock(Blocks.SPONGE) && itemstack.getMetadata() == 1 && !((ItemStack)this.furnaceItemStacks.get(1)).func_190926_b() && ((ItemStack)this.furnaceItemStacks.get(1)).getItem() == Items.BUCKET)
        {
            this.furnaceItemStacks.set(1, new ItemStack(Items.WATER_BUCKET));
        }

        itemstack.func_190918_g(1);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:29,代码来源:TileEntityFurnace.java

示例2: processInitialInteract

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

    if (itemstack.getItem() == Items.COAL && this.fuel + 3600 <= 32000)
    {
        if (!player.capabilities.isCreativeMode)
        {
            itemstack.func_190918_g(1);
        }

        this.fuel += 3600;
    }

    this.pushX = this.posX - player.posX;
    this.pushZ = this.posZ - player.posZ;
    return true;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:19,代码来源:EntityMinecartFurnace.java

示例3: processInteract

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

    if (itemstack.getItem() == Items.BUCKET && !player.capabilities.isCreativeMode && !this.isChild())
    {
        player.playSound(SoundEvents.ENTITY_COW_MILK, 1.0F, 1.0F);
        itemstack.func_190918_g(1);

        if (itemstack.func_190926_b())
        {
            player.setHeldItem(hand, new ItemStack(Items.MILK_BUCKET));
        }
        else if (!player.inventory.addItemStackToInventory(new ItemStack(Items.MILK_BUCKET)))
        {
            player.dropItem(new ItemStack(Items.MILK_BUCKET), false);
        }

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

示例4: onBlockActivated

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY)
{
    ItemStack itemstack = playerIn.getHeldItem(hand);

    if (!itemstack.func_190926_b() && (itemstack.getItem() == Items.FLINT_AND_STEEL || itemstack.getItem() == Items.FIRE_CHARGE))
    {
        this.explode(worldIn, pos, state.withProperty(EXPLODE, Boolean.valueOf(true)), playerIn);
        worldIn.setBlockState(pos, Blocks.AIR.getDefaultState(), 11);

        if (itemstack.getItem() == Items.FLINT_AND_STEEL)
        {
            itemstack.damageItem(1, playerIn);
        }
        else if (!playerIn.capabilities.isCreativeMode)
        {
            itemstack.func_190918_g(1);
        }

        return true;
    }
    else
    {
        return super.onBlockActivated(worldIn, pos, state, playerIn, hand, heldItem, side, hitX, hitY);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:26,代码来源:BlockTNT.java

示例5: swapItem

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private void swapItem(EntityPlayer player, EntityEquipmentSlot p_184795_2_, ItemStack p_184795_3_, EnumHand hand)
{
    ItemStack itemstack = this.getItemStackFromSlot(p_184795_2_);

    if (itemstack.func_190926_b() || (this.disabledSlots & 1 << p_184795_2_.getSlotIndex() + 8) == 0)
    {
        if (!itemstack.func_190926_b() || (this.disabledSlots & 1 << p_184795_2_.getSlotIndex() + 16) == 0)
        {
            if (player.capabilities.isCreativeMode && itemstack.func_190926_b() && !p_184795_3_.func_190926_b())
            {
                ItemStack itemstack2 = p_184795_3_.copy();
                itemstack2.func_190920_e(1);
                this.setItemStackToSlot(p_184795_2_, itemstack2);
            }
            else if (!p_184795_3_.func_190926_b() && p_184795_3_.func_190916_E() > 1)
            {
                if (itemstack.func_190926_b())
                {
                    ItemStack itemstack1 = p_184795_3_.copy();
                    itemstack1.func_190920_e(1);
                    this.setItemStackToSlot(p_184795_2_, itemstack1);
                    p_184795_3_.func_190918_g(1);
                }
            }
            else
            {
                this.setItemStackToSlot(p_184795_2_, p_184795_3_);
                player.setHeldItem(hand, itemstack);
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:33,代码来源:EntityArmorStand.java

示例6: func_190628_d

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private boolean func_190628_d(DamageSource p_190628_1_)
{
    if (p_190628_1_.canHarmInCreative())
    {
        return false;
    }
    else
    {
        boolean flag = false;

        for (EnumHand enumhand : EnumHand.values())
        {
            ItemStack itemstack = this.getHeldItem(enumhand);

            if (itemstack.getItem() == Items.field_190929_cY)
            {
                itemstack.func_190918_g(1);
                flag = true;
                break;
            }
        }

        if (flag)
        {
            if (this instanceof EntityPlayer)
            {
                ((EntityPlayer)this).addStat(StatList.getObjectUseStats(Items.field_190929_cY));
            }

            this.setHealth(1.0F);
            this.clearActivePotions();
            this.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 900, 1));
            this.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 100, 1));
            this.world.setEntityState(this, (byte)35);
        }

        return flag;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:40,代码来源:EntityLivingBase.java

示例7: consumeItemFromStack

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Decreases ItemStack size by one
 */
protected void consumeItemFromStack(EntityPlayer player, ItemStack stack)
{
    if (!player.capabilities.isCreativeMode)
    {
        stack.func_190918_g(1);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:11,代码来源:EntityAnimal.java

示例8: 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)
    {
        if (!this.world.isRemote)
        {
            Class <? extends Entity > oclass = (Class)EntityList.field_191308_b.getObject(ItemMonsterPlacer.func_190908_h(itemstack));

            if (oclass != null && this.getClass() == oclass)
            {
                EntityAgeable entityageable = this.createChild(this);

                if (entityageable != null)
                {
                    entityageable.setGrowingAge(-24000);
                    entityageable.setLocationAndAngles(this.posX, this.posY, this.posZ, 0.0F, 0.0F);
                    this.world.spawnEntityInWorld(entityageable);

                    if (itemstack.hasDisplayName())
                    {
                        entityageable.setCustomNameTag(itemstack.getDisplayName());
                    }

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

        return true;
    }
    else
    {
        return false;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:41,代码来源:EntityAgeable.java

示例9: dispenseStack

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
{
    EnumFacing enumfacing = (EnumFacing)source.getBlockState().getValue(BlockDispenser.FACING);
    World world = source.getWorld();
    double d0 = source.getX() + (double)((float)enumfacing.getFrontOffsetX() * 1.125F);
    double d1 = source.getY() + (double)((float)enumfacing.getFrontOffsetY() * 1.125F);
    double d2 = source.getZ() + (double)((float)enumfacing.getFrontOffsetZ() * 1.125F);
    BlockPos blockpos = source.getBlockPos().offset(enumfacing);
    Material material = world.getBlockState(blockpos).getMaterial();
    double d3;

    if (Material.WATER.equals(material))
    {
        d3 = 1.0D;
    }
    else
    {
        if (!Material.AIR.equals(material) || !Material.WATER.equals(world.getBlockState(blockpos.down()).getMaterial()))
        {
            return this.dispenseBehavior.dispense(source, stack);
        }

        d3 = 0.0D;
    }

    EntityBoat entityboat = new EntityBoat(world, d0, d1 + d3, d2);
    entityboat.setBoatType(this.boatType);
    entityboat.rotationYaw = enumfacing.getHorizontalAngle();
    world.spawnEntityInWorld(entityboat);
    stack.func_190918_g(1);
    return stack;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:33,代码来源:Bootstrap.java

示例10: insertStack

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Insert the specified stack to the specified inventory and return any leftover items
 */
private static ItemStack insertStack(IInventory inventoryIn, IInventory stack, ItemStack index, int side, EnumFacing p_174916_4_)
{
    ItemStack itemstack = stack.getStackInSlot(side);

    if (canInsertItemInSlot(stack, index, side, p_174916_4_))
    {
        boolean flag = false;
        boolean flag1 = stack.func_191420_l();

        if (itemstack.func_190926_b())
        {
            stack.setInventorySlotContents(side, index);
            index = ItemStack.field_190927_a;
            flag = true;
        }
        else if (canCombine(itemstack, index))
        {
            int i = index.getMaxStackSize() - itemstack.func_190916_E();
            int j = Math.min(index.func_190916_E(), i);
            index.func_190918_g(j);
            itemstack.func_190917_f(j);
            flag = j > 0;
        }

        if (flag)
        {
            if (flag1 && stack instanceof TileEntityHopper)
            {
                TileEntityHopper tileentityhopper1 = (TileEntityHopper)stack;

                if (!tileentityhopper1.mayTransfer())
                {
                    int k = 0;

                    if (inventoryIn != null && inventoryIn instanceof TileEntityHopper)
                    {
                        TileEntityHopper tileentityhopper = (TileEntityHopper)inventoryIn;

                        if (tileentityhopper1.field_190578_g >= tileentityhopper.field_190578_g)
                        {
                            k = 1;
                        }
                    }

                    tileentityhopper1.setTransferCooldown(8 - k);
                }
            }

            stack.markDirty();
        }
    }

    return index;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:58,代码来源:TileEntityHopper.java

示例11: addItem

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public ItemStack addItem(ItemStack stack)
{
    ItemStack itemstack = stack.copy();

    for (int i = 0; i < this.slotsCount; ++i)
    {
        ItemStack itemstack1 = this.getStackInSlot(i);

        if (itemstack1.func_190926_b())
        {
            this.setInventorySlotContents(i, itemstack);
            this.markDirty();
            return ItemStack.field_190927_a;
        }

        if (ItemStack.areItemsEqual(itemstack1, itemstack))
        {
            int j = Math.min(this.getInventoryStackLimit(), itemstack1.getMaxStackSize());
            int k = Math.min(itemstack.func_190916_E(), j - itemstack1.func_190916_E());

            if (k > 0)
            {
                itemstack1.func_190917_f(k);
                itemstack.func_190918_g(k);

                if (itemstack.func_190926_b())
                {
                    this.markDirty();
                    return ItemStack.field_190927_a;
                }
            }
        }
    }

    if (itemstack.func_190916_E() != stack.func_190916_E())
    {
        this.markDirty();
    }

    return itemstack;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:42,代码来源:InventoryBasic.java

示例12: clearMatchingItems

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Removes matching items from the inventory.
 * @param itemIn The item to match, null ignores.
 * @param metadataIn The metadata to match, -1 ignores.
 * @param removeCount The number of items to remove. If less than 1, removes all matching items.
 * @param itemNBT The NBT data to match, null ignores.
 * @return The number of items removed from the inventory.
 */
public int clearMatchingItems(@Nullable Item itemIn, int metadataIn, int removeCount, @Nullable NBTTagCompound itemNBT)
{
    int i = 0;

    for (int j = 0; j < this.getSizeInventory(); ++j)
    {
        ItemStack itemstack = this.getStackInSlot(j);

        if (!itemstack.func_190926_b() && (itemIn == null || itemstack.getItem() == itemIn) && (metadataIn <= -1 || itemstack.getMetadata() == metadataIn) && (itemNBT == null || NBTUtil.areNBTEquals(itemNBT, itemstack.getTagCompound(), true)))
        {
            int k = removeCount <= 0 ? itemstack.func_190916_E() : Math.min(removeCount - i, itemstack.func_190916_E());
            i += k;

            if (removeCount != 0)
            {
                itemstack.func_190918_g(k);

                if (itemstack.func_190926_b())
                {
                    this.setInventorySlotContents(j, ItemStack.field_190927_a);
                }

                if (removeCount > 0 && i >= removeCount)
                {
                    return i;
                }
            }
        }
    }

    if (!this.itemStack.func_190926_b())
    {
        if (itemIn != null && this.itemStack.getItem() != itemIn)
        {
            return i;
        }

        if (metadataIn > -1 && this.itemStack.getMetadata() != metadataIn)
        {
            return i;
        }

        if (itemNBT != null && !NBTUtil.areNBTEquals(itemNBT, this.itemStack.getTagCompound(), true))
        {
            return i;
        }

        int l = removeCount <= 0 ? this.itemStack.func_190916_E() : Math.min(removeCount - i, this.itemStack.func_190916_E());
        i += l;

        if (removeCount != 0)
        {
            this.itemStack.func_190918_g(l);

            if (this.itemStack.func_190926_b())
            {
                this.itemStack = ItemStack.field_190927_a;
            }

            if (removeCount > 0 && i >= removeCount)
            {
                return i;
            }
        }
    }

    return i;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:77,代码来源:InventoryPlayer.java

示例13: processInteract

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

    if (itemstack.getItem() == Items.BOWL && this.getGrowingAge() >= 0 && !player.capabilities.isCreativeMode)
    {
        itemstack.func_190918_g(1);

        if (itemstack.func_190926_b())
        {
            player.setHeldItem(hand, new ItemStack(Items.MUSHROOM_STEW));
        }
        else if (!player.inventory.addItemStackToInventory(new ItemStack(Items.MUSHROOM_STEW)))
        {
            player.dropItem(new ItemStack(Items.MUSHROOM_STEW), false);
        }

        return true;
    }
    else if (itemstack.getItem() == Items.SHEARS && this.getGrowingAge() >= 0)
    {
        this.setDead();
        this.world.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.posX, this.posY + (double)(this.height / 2.0F), this.posZ, 0.0D, 0.0D, 0.0D, new int[0]);

        if (!this.world.isRemote)
        {
            EntityCow entitycow = new EntityCow(this.world);
            entitycow.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
            entitycow.setHealth(this.getHealth());
            entitycow.renderYawOffset = this.renderYawOffset;

            if (this.hasCustomName())
            {
                entitycow.setCustomNameTag(this.getCustomNameTag());
            }

            this.world.spawnEntityInWorld(entitycow);

            for (int i = 0; i < 5; ++i)
            {
                this.world.spawnEntityInWorld(new EntityItem(this.world, this.posX, this.posY + (double)this.height, this.posZ, new ItemStack(Blocks.RED_MUSHROOM)));
            }

            itemstack.damageItem(1, player);
            this.playSound(SoundEvents.ENTITY_MOOSHROOM_SHEAR, 1.0F, 1.0F);
        }

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

示例14: 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

示例15: 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


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