| 1 | package net.minecraft.client.renderer.tileentity;
|
| 2 |
|
| 3 | import com.mojang.authlib.GameProfile;
|
| 4 | import java.util.UUID;
|
| 5 | import net.minecraft.block.Block;
|
| 6 | import net.minecraft.client.renderer.GlStateManager;
|
| 7 | import net.minecraft.init.Blocks;
|
| 8 | import net.minecraft.init.Items;
|
| 9 | import net.minecraft.item.ItemStack;
|
| 10 | import net.minecraft.nbt.NBTTagCompound;
|
| 11 | import net.minecraft.nbt.NBTUtil;
|
| 12 | import net.minecraft.tileentity.TileEntityBanner;
|
| 13 | import net.minecraft.tileentity.TileEntityChest;
|
| 14 | import net.minecraft.tileentity.TileEntityEnderChest;
|
| 15 | import net.minecraft.tileentity.TileEntitySkull;
|
| 16 | import net.minecraft.util.EnumFacing;
|
| 17 |
|
| 18 | public class TileEntityItemStackRenderer
|
| 19 | {
|
| 20 | public static TileEntityItemStackRenderer instance = new TileEntityItemStackRenderer();
|
| 21 | private TileEntityChest field_147717_b = new TileEntityChest(0);
|
| 22 | private TileEntityChest field_147718_c = new TileEntityChest(1);
|
| 23 | private TileEntityEnderChest enderChest = new TileEntityEnderChest();
|
| 24 | private TileEntityBanner banner = new TileEntityBanner();
|
| 25 | private TileEntitySkull skull = new TileEntitySkull();
|
| 26 |
|
| 27 | public void renderByItem(ItemStack itemStackIn)
|
| 28 | {
|
| 29 | if (itemStackIn.getItem() == Items.banner)
|
| 30 | {
|
| 31 | this.banner.setItemValues(itemStackIn);
|
| 32 | TileEntityRendererDispatcher.instance.renderTileEntityAt(this.banner, 0.0D, 0.0D, 0.0D, 0.0F);
|
| 33 | }
|
| 34 | else if (itemStackIn.getItem() == Items.skull)
|
| 35 | {
|
| 36 | GameProfile gameprofile = null;
|
| 37 |
|
| 38 | if (itemStackIn.hasTagCompound())
|
| 39 | {
|
| 40 | NBTTagCompound nbttagcompound = itemStackIn.getTagCompound();
|
| 41 |
|
| 42 | if (nbttagcompound.hasKey("SkullOwner", 10))
|
| 43 | {
|
| 44 | gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
|
| 45 | }
|
| 46 | else if (nbttagcompound.hasKey("SkullOwner", 8) && nbttagcompound.getString("SkullOwner").length() > 0)
|
| 47 | {
|
| 48 | gameprofile = new GameProfile((UUID)null, nbttagcompound.getString("SkullOwner"));
|
| 49 | gameprofile = TileEntitySkull.updateGameprofile(gameprofile);
|
| 50 | nbttagcompound.removeTag("SkullOwner");
|
| 51 | nbttagcompound.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
|
| 52 | }
|
| 53 | }
|
| 54 |
|
| 55 | if (TileEntitySkullRenderer.instance != null)
|
| 56 | {
|
| 57 | GlStateManager.pushMatrix();
|
| 58 | GlStateManager.translate(-0.5F, 0.0F, -0.5F);
|
| 59 | GlStateManager.scale(2.0F, 2.0F, 2.0F);
|
| 60 | GlStateManager.disableCull();
|
| 61 | TileEntitySkullRenderer.instance.renderSkull(0.0F, 0.0F, 0.0F, EnumFacing.UP, 0.0F, itemStackIn.getMetadata(), gameprofile, -1);
|
| 62 | GlStateManager.enableCull();
|
| 63 | GlStateManager.popMatrix();
|
| 64 | }
|
| 65 | }
|
| 66 | else
|
| 67 | {
|
| 68 | Block block = Block.getBlockFromItem(itemStackIn.getItem());
|
| 69 |
|
| 70 | if (block == Blocks.ender_chest)
|
| 71 | {
|
| 72 | TileEntityRendererDispatcher.instance.renderTileEntityAt(this.enderChest, 0.0D, 0.0D, 0.0D, 0.0F);
|
| 73 | }
|
| 74 | else if (block == Blocks.trapped_chest)
|
| 75 | {
|
| 76 | TileEntityRendererDispatcher.instance.renderTileEntityAt(this.field_147718_c, 0.0D, 0.0D, 0.0D, 0.0F);
|
| 77 | }
|
| 78 | else
|
| 79 | {
|
| 80 | TileEntityRendererDispatcher.instance.renderTileEntityAt(this.field_147717_b, 0.0D, 0.0D, 0.0D, 0.0F);
|
| 81 | }
|
| 82 | }
|
| 83 | }
|
| 84 | }
|
| 85 |
|