<commit_before>package net.darkhax.darkutils.tileentity;

import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;

public class TileEntitySneaky extends TileEntity {
    
    public IBlockState heldState;
    
    private void readNBT (NBTTagCompound tag) {
        
        Block heldBlock = Block.getBlockFromName(tag.getString("HeldBlockId"));
        
        if (heldBlock != null)
            heldState = heldBlock.getStateFromMeta(tag.getInteger("HeldBlockMeta"));
    }
    
    private void writeNBT (NBTTagCompound tag) {
        
        if (heldState != null) {
            
            tag.setString("HeldBlockId", Block.blockRegistry.getNameForObject(heldState.getBlock()).toString());
            tag.setInteger("HeldBlockMeta", heldState.getBlock().getMetaFromState(heldState));
        }
    }
    
    @Override
    public void readFromNBT (NBTTagCompound dataTag) {
        
        super.readFromNBT(dataTag);
        readNBT(dataTag);
    }
    
    @Override
    public void writeToNBT (NBTTagCompound dataTag) {
        
        super.writeToNBT(dataTag);
        writeNBT(dataTag);
    }
    
    @Override
    public Packet getDescriptionPacket () {
        
        NBTTagCompound dataTag = new NBTTagCompound();
        writeNBT(dataTag);
        return new S35PacketUpdateTileEntity(pos, -1337, dataTag);
    }
    
    @Override
    public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet) {
        
        super.onDataPacket(net, packet);
        worldObj.markBlockRangeForRenderUpdate(pos, pos);
        readNBT(packet.getNbtCompound());
    }
}<commit_msg>The tile now retains it's data when updated. <commit_after>package net.darkhax.darkutils.tileentity;

import net.darkhax.bookshelf.tileentity.TileEntityBasic;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;

public class TileEntitySneaky extends TileEntityBasic {
    
    public IBlockState heldState;
    
    public void readNBT (NBTTagCompound tag) {
        
        Block heldBlock = Block.getBlockFromName(tag.getString("HeldBlockId"));
        
        if (heldBlock != null)
            heldState = heldBlock.getStateFromMeta(tag.getInteger("HeldBlockMeta"));
    }
    
    public void writeNBT (NBTTagCompound tag) {
        
        if (heldState != null) {
            
            tag.setString("HeldBlockId", Block.blockRegistry.getNameForObject(heldState.getBlock()).toString());
            tag.setInteger("HeldBlockMeta", heldState.getBlock().getMetaFromState(heldState));
        }
    }
}
{'fraction_non_alphanumeric': 0.09484739087627174, 'fraction_numerical': 0.003938299967180834, 'mean_word_length': 3.0803212851405624, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1565840', 'n_tokens_mistral': 905, 'n_tokens_neox': 907, 'n_words': 151}