@Nullable private ResourceLocation getBannerResourceLocation(TileEntityBanner bannerObj) { return BannerTextures.BANNER_DESIGNS.getResourceLocation(bannerObj.getPatternResourceLocation(), bannerObj.getPatternList(), bannerObj.getColorList()); }
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); } }
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); } } }