net.minecraft.nbt.NBTUtil Java Examples

The following examples show how to use net.minecraft.nbt.NBTUtil. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityFallTofu.java    From TofuCraftReload with MIT License 6 votes vote down vote up
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
protected void readEntityFromNBT(NBTTagCompound compound) {

    this.fallTime = compound.getInteger("Time");

    if (compound.hasKey("HurtEntities", 99)) {
        this.hurtEntities = compound.getBoolean("HurtEntities");
        this.fallHurtAmount = compound.getFloat("FallHurtAmount");
        this.fallHurtMax = compound.getInteger("FallHurtMax");
    }
    if (compound.hasKey("Owner", 10)) {
        NBTTagCompound nbttagcompound = compound.getCompoundTag("Owner");
        this.ownerUniqueId = NBTUtil.getUUIDFromTag(nbttagcompound);
    }

    if (compound.hasKey("DropItem", 99)) {
        this.shouldDropItem = compound.getBoolean("DropItem");
    }

    if (compound.hasKey("TileEntityData", 10)) {
        this.tileEntityData = compound.getCompoundTag("TileEntityData");
    }

}
 
Example #2
Source File: EntityFallTofu.java    From TofuCraftReload with MIT License 6 votes vote down vote up
/**
 * (abstract) Protected helper method to write subclass entity data to NBT.
 */
protected void writeEntityToNBT(NBTTagCompound compound) {
    if (this.owner != null) {
        NBTTagCompound nbttagcompound = NBTUtil.createUUIDTag(this.owner.getUniqueID());
        compound.setTag("Owner", nbttagcompound);
    }
    compound.setInteger("Time", this.fallTime);
    compound.setBoolean("DropItem", this.shouldDropItem);
    compound.setBoolean("HurtEntities", this.hurtEntities);
    compound.setFloat("FallHurtAmount", this.fallHurtAmount);
    compound.setInteger("FallHurtMax", this.fallHurtMax);

    if (this.tileEntityData != null) {
        compound.setTag("TileEntityData", this.tileEntityData);
    }
}
 
Example #3
Source File: RenderBlockTileEntity.java    From MiningGadgets with MIT License 6 votes vote down vote up
@Override
public CompoundNBT write(CompoundNBT tag) {
    if (renderBlock!= null)
        tag.put("renderBlock", NBTUtil.writeBlockState(renderBlock));
    tag.putInt("originalDurability", originalDurability);
    tag.putInt("priorDurability", priorDurability);
    tag.putInt("durability", durability);
    tag.putInt("ticksSinceMine", ticksSinceMine);
    if (!playerUUID.equals(null))
        tag.putUniqueId("playerUUID", playerUUID);
    tag.put("upgrades", UpgradeTools.setUpgradesNBT(gadgetUpgrades).getList("upgrades", Constants.NBT.TAG_COMPOUND));
    tag.putByte("breakType", (byte) breakType.ordinal());
    tag.put("gadgetFilters", MiningProperties.serializeItemStackList(getGadgetFilters()));
    tag.putBoolean("gadgetIsWhitelist", isGadgetIsWhitelist());
    tag.putBoolean("blockAllowed", blockAllowed);
    return super.write(tag);
}
 
Example #4
Source File: MaterialCache.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void readMapFromNBT(NBTTagCompound nbt, String tagName, IdentityHashMap<IBlockState, ItemStack> map)
{
    if (nbt.hasKey(tagName, Constants.NBT.TAG_LIST))
    {
        NBTTagList list = nbt.getTagList(tagName, Constants.NBT.TAG_COMPOUND);
        final int count = list.tagCount();

        for (int i = 0; i < count; ++i)
        {
            NBTTagCompound tag = list.getCompoundTagAt(i);

            if (tag.hasKey("Block", Constants.NBT.TAG_COMPOUND) &&
                tag.hasKey("Item", Constants.NBT.TAG_COMPOUND))
            {
                IBlockState state = NBTUtil.readBlockState(tag.getCompoundTag("Block"));

                if (state != null)
                {
                    ItemStack stack = new ItemStack(tag.getCompoundTag("Item"));
                    this.buildItemsForStates.put(state, stack);
                }
            }
        }
    }
}
 
Example #5
Source File: MetaTileEntityTank.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound data) {
    super.readFromNBT(data);
    if (data.hasKey("ControllerPos")) {
        this.controllerPos = NBTUtil.getPosFromTag(data.getCompoundTag("ControllerPos"));
    } else {
        NBTTagList connectedTanks = data.getTagList("ConnectedTanks", NBT.TAG_COMPOUND);
        connectedTanks.forEach(pos -> this.connectedTanks.add(NBTUtil.getPosFromTag((NBTTagCompound) pos)));
        recomputeTankSizeNow(true);
        this.multiblockFluidTank.readFromNBT(data.getCompoundTag("FluidInventory"));
        this.lastSentFluidStack = this.multiblockFluidTank.getFluid();
        if (data.hasKey("MultiblockSize")) {
            this.multiblockSize = NBTUtil.getPosFromTag(data.getCompoundTag("MultiblockSize"));
        }
    }
}
 
Example #6
Source File: MaterialCache.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected NBTTagList writeMapToNBT(IdentityHashMap<IBlockState, ItemStack> map)
{
    NBTTagList list = new NBTTagList();

    for (Map.Entry<IBlockState, ItemStack> entry : map.entrySet())
    {
        NBTTagCompound tag = new NBTTagCompound();
        NBTTagCompound stateTag = new NBTTagCompound();
        NBTUtil.writeBlockState(stateTag, entry.getKey());

        tag.setTag("Block", stateTag);
        tag.setTag("Item", entry.getValue().writeToNBT(new NBTTagCompound()));

        list.appendTag(tag);
    }

    return list;
}
 
Example #7
Source File: CraftMetaSkull.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
@Override
void applyToItem(net.minecraft.nbt.NBTTagCompound tag) {
    super.applyToItem(tag);

    if (hasOwner()) {
        NBTTagCompound owner = new NBTTagCompound();
        NBTUtil.func_152460_a(owner, profile);
        tag.setTag(SKULL_OWNER.NBT, owner);
    }
}
 
Example #8
Source File: CraftBlock.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
public Collection<ItemStack> getDrops() {
    List<ItemStack> drops = new ArrayList<ItemStack>();

    net.minecraft.block.Block block = this.getNMSBlock();
    if (block != Blocks.air) {
        byte data = getData();
        // based on nms.Block.dropNaturally
        int count = block.quantityDroppedWithBonus(0, chunk.getHandle().worldObj.rand);
        for (int i = 0; i < count; ++i) {
            Item item = block.getItemDropped(data, chunk.getHandle().worldObj.rand, 0);
            if (item != null) {
                // Skulls are special, their data is based on the tile entity
                if (Blocks.skull == block) {
                    net.minecraft.item.ItemStack nmsStack = new net.minecraft.item.ItemStack(item, 1, block.getDamageValue(chunk.getHandle().worldObj, x, y, z));
                    TileEntitySkull tileentityskull = (TileEntitySkull) chunk.getHandle().worldObj.getTileEntity(x, y, z);

                    if (tileentityskull.func_145904_a() == 3 && tileentityskull.func_152108_a() != null) {
                        nmsStack.setTagCompound(new NBTTagCompound());
                        NBTTagCompound nbttagcompound = new NBTTagCompound();

                        NBTUtil.func_152460_a(nbttagcompound, tileentityskull.func_152108_a());
                        nmsStack.getTagCompound().setTag("SkullOwner", nbttagcompound);
                    }

                    drops.add(CraftItemStack.asBukkitCopy(nmsStack));
                    // We don't want to drop cocoa blocks, we want to drop cocoa beans.
                } else if (Blocks.cocoa == block) {
                    int dropAmount = (BlockCocoa.func_149987_c(data) >= 2 ? 3 : 1);
                    for (int j = 0; j < dropAmount; ++j) {
                        drops.add(new ItemStack(Material.INK_SACK, 1, (short) 3));
                    }
                } else {
                    drops.add(new ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), 1, (short) block.damageDropped(data)));
                }
            }
        }
    }
    return drops;
}
 
Example #9
Source File: ItemStaff.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
	ItemStack stack = player.getHeldItem(hand);
	if (player.isSneaking()) {
		for (SpellRing spellRing : SpellUtils.getAllSpellRings(stack)) {
			if ((spellRing.getModule() != null ? spellRing.getModule().getModuleClass() : null) instanceof IBlockSelectable) {
				if (player.world.isAirBlock(pos)) break;
				NBTHelper.setCompound(stack, "selected", NBTUtil.writeBlockState(new NBTTagCompound(), world.getBlockState(pos)));
				player.stopActiveHand();
				player.swingArm(hand);
				return EnumActionResult.PASS;
			}
		}
	}

	if (isCoolingDown(world, stack)) return EnumActionResult.PASS;
	if (requiresBowAction(stack)) return EnumActionResult.PASS;
	if (BaublesSupport.getItem(player, ModItems.CREATIVE_HALO, ModItems.FAKE_HALO, ModItems.REAL_HALO).isEmpty())
		return EnumActionResult.PASS;

	SpellData spell = new SpellData();
	spell.processEntity(player, true);
	spell.processBlock(pos, side, new Vec3d(pos).add(0.5, 0.5, 0.5));
	SpellUtils.runSpell(world, stack, spell);

	setCooldown(world, player, hand, stack, spell);

	return EnumActionResult.PASS;
}
 
Example #10
Source File: SchematicBase.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected NBTTagList writePaletteToLitematicaFormatTag(ILitematicaBlockStatePalette palette)
{
    final int size = palette.getPaletteSize();
    List<IBlockState> list = palette.getMapping();
    NBTTagList tagList = new NBTTagList();

    for (int id = 0; id < size; ++id)
    {
        NBTTagCompound tag = new NBTTagCompound();
        NBTUtil.writeBlockState(tag, list.get(id));
        tagList.appendTag(tag);
    }

    return tagList;
}
 
Example #11
Source File: SchematicBase.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected boolean readPaletteFromLitematicaFormatTag(NBTTagList tagList, ILitematicaBlockStatePalette palette)
{
    final int size = tagList.tagCount();
    List<IBlockState> list = new ArrayList<>(size);

    for (int id = 0; id < size; ++id)
    {
        NBTTagCompound tag = tagList.getCompoundTagAt(id);
        IBlockState state = NBTUtil.readBlockState(tag);
        list.add(state);
    }

    return palette.setMapping(list);
}
 
Example #12
Source File: CraftMetaSkull.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
void applyToItem(NBTTagCompound tag) {
    super.applyToItem(tag);

    if (profile != null) {
        // Fill in textures
        profile = TileEntitySkull.updateGameprofile(profile);

        NBTTagCompound owner = new NBTTagCompound();
        NBTUtil.writeGameProfile(owner, profile);
        tag.setTag(SKULL_OWNER.NBT, owner);
    }
}
 
Example #13
Source File: CraftMetaSkull.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
void serializeInternal(final Map<String, NBTBase> internalTags) {
    if (profile != null) {
        NBTTagCompound nbtData = new NBTTagCompound();
        NBTUtil.writeGameProfile(nbtData, profile);
        internalTags.put(SKULL_PROFILE.NBT, nbtData);
    }
}
 
Example #14
Source File: CraftBlock.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public Collection<ItemStack> getDrops() {
    List<ItemStack> drops = new ArrayList<ItemStack>();

    net.minecraft.block.Block block = this.getNMSBlock();
    if (block != Blocks.AIR) {
        IBlockState data = getData0();
        // based on nms.Block.dropNaturally
        int count = block.quantityDroppedWithBonus(0, chunk.getHandle().getWorld().rand);
        for (int i = 0; i < count; ++i) {
            Item item = block.getItemDropped(data, chunk.getHandle().getWorld().rand, 0);
            if (item != Items.AIR) {
                // Skulls are special, their data is based on the tile entity
                if (Blocks.SKULL == block) {
                    net.minecraft.item.ItemStack nmsStack = new net.minecraft.item.ItemStack(item, 1, block.damageDropped(data));
                    TileEntitySkull tileentityskull = (TileEntitySkull) chunk.getHandle().getWorld().getTileEntity(new BlockPos(x, y, z));

                    if (tileentityskull.getSkullType() == 3 && tileentityskull.getPlayerProfile() != null) {
                        nmsStack.setTagCompound(new NBTTagCompound());
                        NBTTagCompound nbttagcompound = new NBTTagCompound();

                        NBTUtil.writeGameProfile(nbttagcompound, tileentityskull.getPlayerProfile());
                        nmsStack.getTagCompound().setTag("SkullOwner", nbttagcompound);
                    }

                    drops.add(CraftItemStack.asBukkitCopy(nmsStack));
                    // We don't want to drop cocoa blocks, we want to drop cocoa beans.
                } else if (Blocks.COCOA == block) {
                    int age = (Integer) data.getValue(BlockCocoa.AGE);
                    int dropAmount = (age >= 2 ? 3 : 1);
                    for (int j = 0; j < dropAmount; ++j) {
                        drops.add(new ItemStack(Material.INK_SACK, 1, (short) 3));
                    }
                } else {
                    drops.add(new ItemStack(CraftMagicNumbers.getMaterial(item), 1, (short) block.damageDropped(data)));
                }
            }
        }
    }
    return drops;
}
 
Example #15
Source File: GTTileTesseractSlave.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
	super.writeToNBT(nbt);
	if (this.targetPos != null) {
		nbt.setTag(NBT_TARGETPOS, NBTUtil.createPosTag(targetPos));
	}
	nbt.setInteger(NBT_TARGETDIM, targetDim);
	return nbt;
}
 
Example #16
Source File: GTTileTesseractSlave.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound nbt) {
	super.readFromNBT(nbt);
	if (nbt.hasKey(NBT_TARGETPOS)) {
		this.targetPos = NBTUtil.getPosFromTag(nbt.getCompoundTag(NBT_TARGETPOS));
	}
	this.targetDim = nbt.getInteger(NBT_TARGETDIM);
}
 
Example #17
Source File: GTTileDisplayScreen.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
	super.writeToNBT(nbt);
	if (this.targetPos != null) {
		nbt.setTag(NBT_TARGETPOS, NBTUtil.createPosTag(targetPos));
	}
	return nbt;
}
 
Example #18
Source File: GTTileDisplayScreen.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound nbt) {
	super.readFromNBT(nbt);
	if (nbt.hasKey(NBT_TARGETPOS)) {
		this.targetPos = NBTUtil.getPosFromTag(nbt.getCompoundTag(NBT_TARGETPOS));
	}
}
 
Example #19
Source File: GTTileEnergyTransmitter.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
	super.writeToNBT(nbt);
	if (this.targetPos != null) {
		nbt.setTag(NBT_TARGETPOS, NBTUtil.createPosTag(targetPos));
	}
	return nbt;
}
 
Example #20
Source File: GTTileEnergyTransmitter.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound nbt) {
	super.readFromNBT(nbt);
	if (nbt.hasKey(NBT_TARGETPOS)) {
		this.targetPos = NBTUtil.getPosFromTag(nbt.getCompoundTag(NBT_TARGETPOS));
	}
}
 
Example #21
Source File: GTTileRedstoneTransmitter.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
	super.writeToNBT(nbt);
	if (this.targetPos != null) {
		nbt.setTag(NBT_TARGETPOS, NBTUtil.createPosTag(targetPos));
	}
	return nbt;
}
 
Example #22
Source File: GTTileRedstoneTransmitter.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound nbt) {
	super.readFromNBT(nbt);
	if (nbt.hasKey(NBT_TARGETPOS)) {
		this.targetPos = NBTUtil.getPosFromTag(nbt.getCompoundTag(NBT_TARGETPOS));
	}
}
 
Example #23
Source File: MetaTileEntityTank.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public NBTTagCompound writeToNBT(NBTTagCompound data) {
    super.writeToNBT(data);
    if (controllerPos != null) {
        data.setTag("ControllerPos", NBTUtil.createPosTag(controllerPos));
    } else {
        data.setTag("FluidInventory", multiblockFluidTank.writeToNBT(new NBTTagCompound()));
        NBTTagList connectedTanks = new NBTTagList();
        this.connectedTanks.forEach(pos -> connectedTanks.appendTag(NBTUtil.createPosTag(pos)));
        data.setTag("ConnectedTanks", connectedTanks);
        data.setTag("MultiblockSize", NBTUtil.createPosTag(new BlockPos(multiblockSize)));
    }
    return data;
}
 
Example #24
Source File: RenderBlockTileEntity.java    From MiningGadgets with MIT License 5 votes vote down vote up
@Override
public void read(CompoundNBT tag) {
    super.read(tag);
    renderBlock = NBTUtil.readBlockState(tag.getCompound("renderBlock"));
    originalDurability = tag.getInt("originalDurability");
    priorDurability = tag.getInt("priorDurability");
    durability = tag.getInt("durability");
    ticksSinceMine = tag.getInt("ticksSinceMine");
    playerUUID = tag.getUniqueId("playerUUID");
    gadgetUpgrades = UpgradeTools.getUpgradesFromTag(tag);
    breakType = MiningProperties.BreakTypes.values()[tag.getByte("breakType")];
    gadgetFilters = MiningProperties.deserializeItemStackList(tag.getCompound("gadgetFilters"));
    gadgetIsWhitelist = tag.getBoolean("gadgetIsWhitelist");
    blockAllowed = tag.getBoolean("blockAllowed");
}
 
Example #25
Source File: PacketDurabilitySync.java    From MiningGadgets with MIT License 5 votes vote down vote up
public static PacketDurabilitySync decode(PacketBuffer buffer) {
    CompoundNBT tag = buffer.readCompoundTag();
    ListNBT nbtList = tag.getList("list", Constants.NBT.TAG_COMPOUND);
    List<Tuple<BlockPos, Integer>> thisList = new ArrayList<>();
    for (int i = 0; i < nbtList.size(); i++) {
        CompoundNBT nbt = nbtList.getCompound(i);
        thisList.add(new Tuple<>(NBTUtil.readBlockPos(nbt.getCompound("pos")), nbt.getInt("dur")));
    }
    return new PacketDurabilitySync(thisList);
}
 
Example #26
Source File: PacketDurabilitySync.java    From MiningGadgets with MIT License 5 votes vote down vote up
public static void encode(PacketDurabilitySync msg, PacketBuffer buffer) {
    List<Tuple<BlockPos, Integer>> thisList = msg.updateList;
    CompoundNBT tag = new CompoundNBT();
    ListNBT nbtList = new ListNBT();
    for (int i = 0; i < thisList.size(); i++) {
        CompoundNBT nbt = new CompoundNBT();
        nbt.put("pos", NBTUtil.writeBlockPos(thisList.get(i).getA()));
        nbt.putInt("dur", thisList.get(i).getB());
        nbtList.add(i, nbt);
    }
    tag.put("list", nbtList);
    buffer.writeCompoundTag(tag);
}
 
Example #27
Source File: CraftMetaSkull.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
void deserializeInternal(NBTTagCompound tag) {
    if (tag.hasKey(SKULL_PROFILE.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) {
        profile = NBTUtil.readGameProfileFromNBT(tag.getCompoundTag(SKULL_PROFILE.NBT));
    }
}
 
Example #28
Source File: MixinTileEntityItemStackRenderer.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @author CCBlueX
 */
@Overwrite
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.skull) {
        GameProfile gameprofile = null;

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

            try {
                if(nbttagcompound.hasKey("SkullOwner", 10)) {
                    gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
                }else if(nbttagcompound.hasKey("SkullOwner", 8) && nbttagcompound.getString("SkullOwner").length() > 0) {
                    GameProfile lvt_2_2_ = new GameProfile(null, nbttagcompound.getString("SkullOwner"));
                    gameprofile = TileEntitySkull.updateGameprofile(lvt_2_2_);
                    nbttagcompound.removeTag("SkullOwner");
                    nbttagcompound.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
                }
            }catch(Exception ignored) {
            }
        }

        if(TileEntitySkullRenderer.instance != null) {
            GlStateManager.pushMatrix();
            GlStateManager.translate(-0.5F, 0.0F, -0.5F);
            GlStateManager.scale(2.0F, 2.0F, 2.0F);
            GlStateManager.disableCull();
            TileEntitySkullRenderer.instance.renderSkull(0.0F, 0.0F, 0.0F, EnumFacing.UP, 0.0F, itemStackIn.getMetadata(), gameprofile, -1);
            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.field_147718_c, 0.0D, 0.0D, 0.0D, 0.0F);
        }else{
            TileEntityRendererDispatcher.instance.renderTileEntityAt(this.field_147717_b, 0.0D, 0.0D, 0.0D, 0.0F);
        }
    }
}
 
Example #29
Source File: MixinTileEntityItemStackRenderer.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @author CCBlueX
 */
@Overwrite
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.skull) {
        GameProfile gameprofile = null;

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

            try {
                if(nbttagcompound.hasKey("SkullOwner", 10)) {
                    gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
                }else if(nbttagcompound.hasKey("SkullOwner", 8) && nbttagcompound.getString("SkullOwner").length() > 0) {
                    GameProfile lvt_2_2_ = new GameProfile(null, nbttagcompound.getString("SkullOwner"));
                    gameprofile = TileEntitySkull.updateGameprofile(lvt_2_2_);
                    nbttagcompound.removeTag("SkullOwner");
                    nbttagcompound.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
                }
            }catch(Exception ignored) {
            }
        }

        if(TileEntitySkullRenderer.instance != null) {
            GlStateManager.pushMatrix();
            GlStateManager.translate(-0.5F, 0.0F, -0.5F);
            GlStateManager.scale(2.0F, 2.0F, 2.0F);
            GlStateManager.disableCull();
            TileEntitySkullRenderer.instance.renderSkull(0.0F, 0.0F, 0.0F, EnumFacing.UP, 0.0F, itemStackIn.getMetadata(), gameprofile, -1);
            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.field_147718_c, 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.field_147717_b, 0.0D, 0.0D, 0.0D, 0.0F);
        }
    }
}