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


Java ItemStack.getSubCompound方法代码示例

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


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

示例1: removeBannerData

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Removes all the banner related data from a provided instance of ItemStack.
 */
public static void removeBannerData(ItemStack stack)
{
    NBTTagCompound nbttagcompound = stack.getSubCompound("BlockEntityTag", false);

    if (nbttagcompound != null && nbttagcompound.hasKey("Patterns", 9))
    {
        NBTTagList nbttaglist = nbttagcompound.getTagList("Patterns", 10);

        if (nbttaglist.tagCount() > 0)
        {
            nbttaglist.removeTag(nbttaglist.tagCount() - 1);

            if (nbttaglist.hasNoTags())
            {
                stack.getTagCompound().removeTag("BlockEntityTag");

                if (stack.getTagCompound().hasNoTags())
                {
                    stack.setTagCompound((NBTTagCompound)null);
                }
            }
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:28,代码来源:TileEntityBanner.java

示例2: matches

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public boolean matches(InventoryCrafting inv, World worldIn) {
    int count = 0;
    boolean forge = false;
    for (int i = 0; i < inv.getSizeInventory(); i++) {
        ItemStack stack = inv.getStackInSlot(i);
        if(!stack.isEmpty()) {
            if(stack.getItem() instanceof ItemBlock && ((ItemBlock) stack.getItem()).getBlock() instanceof CraftiniumForge) {
                if(forge && !this.combining) {
                    return false;
                } else {
                    forge = true;
                    if(!stack.hasTagCompound() || stack.getSubCompound("randores") == null || !stack.getSubCompound("randores").hasKey("furnace_speed")) {
                        return false;
                    }
                }
            } else if (this.upgrades.keySet().stream().noneMatch(k -> k.apply(stack))) {
                return false;
            }
            count++;
        }
    }
    return count >= 2 && forge;
}
 
开发者ID:Randores,项目名称:Randores2,代码行数:25,代码来源:RandoresForgeUpgradeRecipe.java

示例3: removeBannerData

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Removes all the banner related data from a provided instance of ItemStack.
 */
public static void removeBannerData(ItemStack stack)
{
    NBTTagCompound nbttagcompound = stack.getSubCompound("BlockEntityTag");

    if (nbttagcompound != null && nbttagcompound.hasKey("Patterns", 9))
    {
        NBTTagList nbttaglist = nbttagcompound.getTagList("Patterns", 10);

        if (!nbttaglist.hasNoTags())
        {
            nbttaglist.removeTag(nbttaglist.tagCount() - 1);

            if (nbttaglist.hasNoTags())
            {
                stack.getTagCompound().removeTag("BlockEntityTag");

                if (stack.getTagCompound().hasNoTags())
                {
                    stack.setTagCompound((NBTTagCompound)null);
                }
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:28,代码来源:TileEntityBanner.java

示例4: hasData

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static boolean hasData(ItemStack stack) {
    if(stack.hasTagCompound()) {
        NBTTagCompound randores = stack.getSubCompound("randores");
        return randores != null && randores.hasKey("index") && randores.hasKey("idMost") && randores.hasKey("idLeast");
    }

    return false;
}
 
开发者ID:Randores,项目名称:Randores2,代码行数:9,代码来源:RandoresItemData.java

示例5: onBlockPlacedBy

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
    super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
    if (!worldIn.isRemote) {
        if (stack.getSubCompound("randores") != null && stack.getSubCompound("randores").hasKey("furnace_speed")) {
            int speed = stack.getSubCompound("randores").getInteger("furnace_speed");
            TileEntity entity = worldIn.getTileEntity(pos);
            if (entity instanceof CraftiniumForgeTileEntity) {
                ((CraftiniumForgeTileEntity) entity).setDivisor(speed);
            }
        }
    }
}
 
开发者ID:Randores,项目名称:Randores2,代码行数:14,代码来源:CraftiniumForge.java

示例6: getCraftingResult

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public ItemStack getCraftingResult(InventoryCrafting inv)
{
    ItemStack itemstack = ItemStack.field_190927_a;
    ItemStack itemstack1 = ItemStack.field_190927_a;

    for (int i = 0; i < inv.getSizeInventory(); ++i)
    {
        ItemStack itemstack2 = inv.getStackInSlot(i);

        if (!itemstack2.func_190926_b())
        {
            if (itemstack2.getItem() == Items.BANNER)
            {
                itemstack = itemstack2;
            }
            else if (itemstack2.getItem() == Items.SHIELD)
            {
                itemstack1 = itemstack2.copy();
            }
        }
    }

    if (itemstack1.func_190926_b())
    {
        return itemstack1;
    }
    else
    {
        NBTTagCompound nbttagcompound = itemstack.getSubCompound("BlockEntityTag");
        NBTTagCompound nbttagcompound1 = nbttagcompound == null ? new NBTTagCompound() : nbttagcompound.copy();
        nbttagcompound1.setInteger("Base", itemstack.getMetadata() & 15);
        itemstack1.setTagInfo("BlockEntityTag", nbttagcompound1);
        return itemstack1;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:36,代码来源:ShieldRecipes.java

示例7: handleStatusUpdate

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void handleStatusUpdate(byte id)
{
    if (id == 17 && this.world.isRemote)
    {
        ItemStack itemstack = (ItemStack)this.dataManager.get(FIREWORK_ITEM);
        NBTTagCompound nbttagcompound = itemstack.func_190926_b() ? null : itemstack.getSubCompound("Fireworks");
        this.world.makeFireworks(this.posX, this.posY, this.posZ, this.motionX, this.motionY, this.motionZ, nbttagcompound);
    }

    super.handleStatusUpdate(id);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:12,代码来源:EntityFireworkRocket.java

示例8: getBaseColor

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static int getBaseColor(ItemStack stack)
{
    NBTTagCompound nbttagcompound = stack.getSubCompound("BlockEntityTag", false);
    return nbttagcompound != null && nbttagcompound.hasKey("Base") ? nbttagcompound.getInteger("Base") : stack.getMetadata();
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:6,代码来源:TileEntityBanner.java

示例9: getPatterns

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Retrieves the amount of patterns stored on an ItemStack. If the tag does not exist this value will be 0.
 */
public static int getPatterns(ItemStack stack)
{
    NBTTagCompound nbttagcompound = stack.getSubCompound("BlockEntityTag", false);
    return nbttagcompound != null && nbttagcompound.hasKey("Patterns") ? nbttagcompound.getTagList("Patterns", 10).tagCount() : 0;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:9,代码来源:TileEntityBanner.java

示例10: matches

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Used to check if a recipe matches current crafting inventory
 */
public boolean matches(InventoryCrafting inv, World worldIn)
{
    ItemStack itemstack = null;
    ItemStack itemstack1 = null;

    for (int i = 0; i < inv.getSizeInventory(); ++i)
    {
        ItemStack itemstack2 = inv.getStackInSlot(i);

        if (itemstack2 != null)
        {
            if (itemstack2.getItem() == Items.BANNER)
            {
                if (itemstack1 != null)
                {
                    return false;
                }

                itemstack1 = itemstack2;
            }
            else
            {
                if (itemstack2.getItem() != Items.SHIELD)
                {
                    return false;
                }

                if (itemstack != null)
                {
                    return false;
                }

                if (itemstack2.getSubCompound("BlockEntityTag", false) != null)
                {
                    return false;
                }

                itemstack = itemstack2;
            }
        }
    }

    if (itemstack != null && itemstack1 != null)
    {
        return true;
    }
    else
    {
        return false;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:55,代码来源:ShieldRecipes.java

示例11: renderByItem

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void renderByItem(ItemStack itemStackIn)
{
    if (itemStackIn.getItem() == Items.BANNER)
    {
        this.banner.setItemValues(itemStackIn);
        TileEntityRendererDispatcher.instance.renderTileEntityAt(this.banner, 0.0D, 0.0D, 0.0D, 0.0F);
    }
    else if (itemStackIn.getItem() == Items.SHIELD)
    {
        if (itemStackIn.getSubCompound("BlockEntityTag", false) != null)
        {
            this.banner.setItemValues(itemStackIn);
            Minecraft.getMinecraft().getTextureManager().bindTexture(BannerTextures.SHIELD_DESIGNS.getResourceLocation(this.banner.getPatternResourceLocation(), this.banner.getPatternList(), this.banner.getColorList()));
        }
        else
        {
            Minecraft.getMinecraft().getTextureManager().bindTexture(BannerTextures.SHIELD_BASE_TEXTURE);
        }

        GlStateManager.pushMatrix();
        GlStateManager.scale(1.0F, -1.0F, -1.0F);
        this.modelShield.render();
        GlStateManager.popMatrix();
    }
    else if (itemStackIn.getItem() == Items.SKULL)
    {
        GameProfile gameprofile = null;

        if (itemStackIn.hasTagCompound())
        {
            NBTTagCompound nbttagcompound = itemStackIn.getTagCompound();

            if (nbttagcompound.hasKey("SkullOwner", 10))
            {
                gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
            }
            else if (nbttagcompound.hasKey("SkullOwner", 8) && !nbttagcompound.getString("SkullOwner").isEmpty())
            {
                GameProfile lvt_2_2_ = new GameProfile((UUID)null, nbttagcompound.getString("SkullOwner"));
                gameprofile = TileEntitySkull.updateGameprofile(lvt_2_2_);
                nbttagcompound.removeTag("SkullOwner");
                nbttagcompound.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
            }
        }

        if (TileEntitySkullRenderer.instance != null)
        {
            GlStateManager.pushMatrix();
            GlStateManager.disableCull();
            TileEntitySkullRenderer.instance.renderSkull(0.0F, 0.0F, 0.0F, EnumFacing.UP, 0.0F, itemStackIn.getMetadata(), gameprofile, -1, 0.0F);
            GlStateManager.enableCull();
            GlStateManager.popMatrix();
        }
    }
    else
    {
        Block block = Block.getBlockFromItem(itemStackIn.getItem());

        if (block == Blocks.ENDER_CHEST)
        {
            TileEntityRendererDispatcher.instance.renderTileEntityAt(this.enderChest, 0.0D, 0.0D, 0.0D, 0.0F);
        }
        else if (block == Blocks.TRAPPED_CHEST)
        {
            TileEntityRendererDispatcher.instance.renderTileEntityAt(this.chestTrap, 0.0D, 0.0D, 0.0D, 0.0F);
        }
        else if (block != Blocks.CHEST) net.minecraftforge.client.ForgeHooksClient.renderTileItem(itemStackIn.getItem(), itemStackIn.getMetadata());
        else
        {
            TileEntityRendererDispatcher.instance.renderTileEntityAt(this.chestBasic, 0.0D, 0.0D, 0.0D, 0.0F);
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:74,代码来源:TileEntityItemStackRenderer.java

示例12: func_191510_k

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private void func_191510_k()
{
    float f = 0.0F;
    ItemStack itemstack = (ItemStack)this.dataManager.get(FIREWORK_ITEM);
    NBTTagCompound nbttagcompound = itemstack.func_190926_b() ? null : itemstack.getSubCompound("Fireworks");
    NBTTagList nbttaglist = nbttagcompound != null ? nbttagcompound.getTagList("Explosions", 10) : null;

    if (nbttaglist != null && !nbttaglist.hasNoTags())
    {
        f = (float)(5 + nbttaglist.tagCount() * 2);
    }

    if (f > 0.0F)
    {
        if (this.field_191513_e != null)
        {
            this.field_191513_e.attackEntityFrom(DamageSource.field_191552_t, (float)(5 + nbttaglist.tagCount() * 2));
        }

        double d0 = 5.0D;
        Vec3d vec3d = new Vec3d(this.posX, this.posY, this.posZ);

        for (EntityLivingBase entitylivingbase : this.world.getEntitiesWithinAABB(EntityLivingBase.class, this.getEntityBoundingBox().expandXyz(5.0D)))
        {
            if (entitylivingbase != this.field_191513_e && this.getDistanceSqToEntity(entitylivingbase) <= 25.0D)
            {
                boolean flag = false;

                for (int i = 0; i < 2; ++i)
                {
                    RayTraceResult raytraceresult = this.world.rayTraceBlocks(vec3d, new Vec3d(entitylivingbase.posX, entitylivingbase.posY + (double)entitylivingbase.height * 0.5D * (double)i, entitylivingbase.posZ), false, true, false);

                    if (raytraceresult == null || raytraceresult.typeOfHit == RayTraceResult.Type.MISS)
                    {
                        flag = true;
                        break;
                    }
                }

                if (flag)
                {
                    float f1 = f * (float)Math.sqrt((5.0D - (double)this.getDistanceToEntity(entitylivingbase)) / 5.0D);
                    entitylivingbase.attackEntityFrom(DamageSource.field_191552_t, f1);
                }
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:49,代码来源:EntityFireworkRocket.java

示例13: matches

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public boolean matches(InventoryCrafting inv, World worldIn)
{
    ItemStack itemstack = ItemStack.field_190927_a;
    ItemStack itemstack1 = ItemStack.field_190927_a;

    for (int i = 0; i < inv.getSizeInventory(); ++i)
    {
        ItemStack itemstack2 = inv.getStackInSlot(i);

        if (!itemstack2.func_190926_b())
        {
            if (itemstack2.getItem() == Items.BANNER)
            {
                if (!itemstack1.func_190926_b())
                {
                    return false;
                }

                itemstack1 = itemstack2;
            }
            else
            {
                if (itemstack2.getItem() != Items.SHIELD)
                {
                    return false;
                }

                if (!itemstack.func_190926_b())
                {
                    return false;
                }

                if (itemstack2.getSubCompound("BlockEntityTag") != null)
                {
                    return false;
                }

                itemstack = itemstack2;
            }
        }
    }

    if (!itemstack.func_190926_b() && !itemstack1.func_190926_b())
    {
        return true;
    }
    else
    {
        return false;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:52,代码来源:ShieldRecipes.java


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