Java Code Examples for net.minecraft.init.Items.BANNER

The following are Jave code examples for showing how to use BANNER of the net.minecraft.init.Items class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: CustomWorldGen   File: BlockBanner.java   View Source Code Vote up 6 votes
@Nullable
private ItemStack getTileDataItemStack(World worldIn, BlockPos pos, IBlockState state)
{
    TileEntity tileentity = worldIn.getTileEntity(pos);

    if (tileentity instanceof TileEntityBanner)
    {
        ItemStack itemstack = new ItemStack(Items.BANNER, 1, ((TileEntityBanner)tileentity).getBaseColor());
        NBTTagCompound nbttagcompound = tileentity.writeToNBT(new NBTTagCompound());
        nbttagcompound.removeTag("x");
        nbttagcompound.removeTag("y");
        nbttagcompound.removeTag("z");
        nbttagcompound.removeTag("id");
        itemstack.setTagInfo("BlockEntityTag", nbttagcompound);
        return itemstack;
    }
    else
    {
        return null;
    }
}
 
Example 2
Project: CustomWorldGen   File: BlockBanner.java   View Source Code Vote up 6 votes
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, @Nullable ItemStack stack)
{
    if (te instanceof TileEntityBanner)
    {
        TileEntityBanner tileentitybanner = (TileEntityBanner)te;
        ItemStack itemstack = new ItemStack(Items.BANNER, 1, ((TileEntityBanner)te).getBaseColor());
        NBTTagCompound nbttagcompound = new NBTTagCompound();
        TileEntityBanner.setBaseColorAndPatterns(nbttagcompound, tileentitybanner.getBaseColor(), tileentitybanner.getPatterns());
        itemstack.setTagInfo("BlockEntityTag", nbttagcompound);
        spawnAsEntity(worldIn, pos, itemstack);
    }
    else
    {
        super.harvestBlock(worldIn, player, pos, state, (TileEntity)null, stack);
    }
}
 
Example 3
Project: CustomWorldGen   File: BlockBanner.java   View Source Code Vote up 6 votes
@Override
public java.util.List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
{
    TileEntity te = world.getTileEntity(pos);

    java.util.List<ItemStack> ret = new java.util.ArrayList<ItemStack>();
    if (te instanceof TileEntityBanner)
    {
        TileEntityBanner banner = (TileEntityBanner)te;
        ItemStack item = new ItemStack(Items.BANNER, 1, banner.getBaseColor());
        NBTTagCompound nbt = new NBTTagCompound();
        TileEntityBanner.setBaseColorAndPatterns(nbt, banner.getBaseColor(), banner.getPatterns());
        item.setTagInfo("BlockEntityTag", nbt);
        ret.add(item);
    }
    else
    {
        ret.add(new ItemStack(Items.BANNER, 1, 0));
    }
    return ret;
}
 
Example 4
Project: Backmemed   File: ItemBanner.java   View Source Code Vote up 5 votes
public static ItemStack func_190910_a(EnumDyeColor p_190910_0_, @Nullable NBTTagList p_190910_1_)
{
    ItemStack itemstack = new ItemStack(Items.BANNER, 1, p_190910_0_.getDyeDamage());

    if (p_190910_1_ != null && !p_190910_1_.hasNoTags())
    {
        itemstack.func_190925_c("BlockEntityTag").setTag("Patterns", p_190910_1_.copy());
    }

    return itemstack;
}
 
Example 5
Project: Backmemed   File: RecipesBanners.java   View Source Code Vote up 5 votes
public boolean matches(InventoryCrafting inv, World worldIn)
{
    boolean flag = false;

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

        if (itemstack.getItem() == Items.BANNER)
        {
            if (flag)
            {
                return false;
            }

            if (TileEntityBanner.getPatterns(itemstack) >= 6)
            {
                return false;
            }

            flag = true;
        }
    }

    if (!flag)
    {
        return false;
    }
    else
    {
        return this.func_190933_c(inv) != null;
    }
}
 
Example 6
Project: Backmemed   File: ShieldRecipes.java   View Source Code Vote up 5 votes
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;
    }
}
 
Example 7
Project: CustomWorldGen   File: RecipesBanners.java   View Source Code Vote up 5 votes
/**
 * Used to check if a recipe matches current crafting inventory
 */
public boolean matches(InventoryCrafting inv, World worldIn)
{
    boolean flag = false;

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

        if (itemstack != null && itemstack.getItem() == Items.BANNER)
        {
            if (flag)
            {
                return false;
            }

            if (TileEntityBanner.getPatterns(itemstack) >= 6)
            {
                return false;
            }

            flag = true;
        }
    }

    if (!flag)
    {
        return false;
    }
    else
    {
        return this.matchPatterns(inv) != null;
    }
}
 
Example 8
Project: Backmemed   File: RecipesBanners.java   View Source Code Vote up 4 votes
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)
            {
                return false;
            }

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

            EnumDyeColor enumdyecolor = ItemBanner.getBaseColor(itemstack2);
            boolean flag = TileEntityBanner.getPatterns(itemstack2) > 0;

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

                if (enumdyecolor != ItemBanner.getBaseColor(itemstack))
                {
                    return false;
                }

                itemstack1 = itemstack2;
            }
            else if (!itemstack1.func_190926_b())
            {
                if (!flag)
                {
                    return false;
                }

                if (enumdyecolor != ItemBanner.getBaseColor(itemstack1))
                {
                    return false;
                }

                itemstack = itemstack2;
            }
            else if (flag)
            {
                itemstack = itemstack2;
            }
            else
            {
                itemstack1 = itemstack2;
            }
        }
    }

    return !itemstack.func_190926_b() && !itemstack1.func_190926_b();
}
 
Example 9
Project: Backmemed   File: ShieldRecipes.java   View Source Code Vote up 4 votes
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;
    }
}
 
Example 10
Project: Backmemed   File: BlockBanner.java   View Source Code Vote up 4 votes
/**
 * Get the Item that this Block should drop when harvested.
 */
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
    return Items.BANNER;
}
 
Example 11
Project: Backmemed   File: BlockBanner.java   View Source Code Vote up 4 votes
public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state)
{
    ItemStack itemstack = this.getTileDataItemStack(worldIn, pos);
    return itemstack.func_190926_b() ? new ItemStack(Items.BANNER) : itemstack;
}
 
Example 12
Project: Backmemed   File: TileEntityItemStackRenderer.java   View Source Code Vote up 4 votes
public void renderByItem(ItemStack itemStackIn)
{
    Item item = itemStackIn.getItem();

    if (item == Items.BANNER)
    {
        this.banner.setItemValues(itemStackIn, false);
        TileEntityRendererDispatcher.instance.renderTileEntityAt(this.banner, 0.0D, 0.0D, 0.0D, 0.0F);
    }
    else if (item == Items.SHIELD)
    {
        if (itemStackIn.getSubCompound("BlockEntityTag") != null)
        {
            this.banner.setItemValues(itemStackIn, true);
            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 (item == 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) && !StringUtils.isBlank(nbttagcompound.getString("SkullOwner")))
            {
                GameProfile gameprofile1 = new GameProfile((UUID)null, nbttagcompound.getString("SkullOwner"));
                gameprofile = TileEntitySkull.updateGameprofile(gameprofile1);
                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, 180.0F, itemStackIn.getMetadata(), gameprofile, -1, 0.0F);
            GlStateManager.enableCull();
            GlStateManager.popMatrix();
        }
    }
    else if (item == Item.getItemFromBlock(Blocks.ENDER_CHEST))
    {
        TileEntityRendererDispatcher.instance.renderTileEntityAt(this.enderChest, 0.0D, 0.0D, 0.0D, 0.0F);
    }
    else if (item == Item.getItemFromBlock(Blocks.TRAPPED_CHEST))
    {
        TileEntityRendererDispatcher.instance.renderTileEntityAt(this.chestTrap, 0.0D, 0.0D, 0.0D, 0.0F);
    }
    else if (Block.getBlockFromItem(item) instanceof BlockShulkerBox)
    {
        TileEntityRendererDispatcher.instance.renderTileEntityAt(field_191274_b[BlockShulkerBox.func_190955_b(item).getMetadata()], 0.0D, 0.0D, 0.0D, 0.0F);
    }
    else
    {
        TileEntityRendererDispatcher.instance.renderTileEntityAt(this.chestBasic, 0.0D, 0.0D, 0.0D, 0.0F);
    }
}
 
Example 13
Project: CustomWorldGen   File: RecipesBanners.java   View Source Code Vote up 4 votes
/**
 * 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)
            {
                return false;
            }

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

            int j = TileEntityBanner.getBaseColor(itemstack2);
            boolean flag = TileEntityBanner.getPatterns(itemstack2) > 0;

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

                if (j != TileEntityBanner.getBaseColor(itemstack))
                {
                    return false;
                }

                itemstack1 = itemstack2;
            }
            else if (itemstack1 != null)
            {
                if (!flag)
                {
                    return false;
                }

                if (j != TileEntityBanner.getBaseColor(itemstack1))
                {
                    return false;
                }

                itemstack = itemstack2;
            }
            else if (flag)
            {
                itemstack = itemstack2;
            }
            else
            {
                itemstack1 = itemstack2;
            }
        }
    }

    return itemstack != null && itemstack1 != null;
}
 
Example 14
Project: CustomWorldGen   File: ShieldRecipes.java   View Source Code Vote up 4 votes
/**
 * 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;
    }
}
 
Example 15
Project: CustomWorldGen   File: BlockBanner.java   View Source Code Vote up 4 votes
/**
 * Get the Item that this Block should drop when harvested.
 */
@Nullable
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
    return Items.BANNER;
}
 
Example 16
Project: CustomWorldGen   File: BlockBanner.java   View Source Code Vote up 4 votes
public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state)
{
    ItemStack itemstack = this.getTileDataItemStack(worldIn, pos, state);
    return itemstack != null ? itemstack : new ItemStack(Items.BANNER);
}
 
Example 17
Project: CustomWorldGen   File: TileEntityItemStackRenderer.java   View Source Code Vote up 4 votes
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);
        }
    }
}