<commit_before>package techreborn.tiles;

import net.minecraft.block.Block;
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;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import reborncore.common.packets.PacketHandler;
import techreborn.blocks.BlockMachineBase;

public class TileMachineBase extends TileEntity implements ITickable {

    public void syncWithAll() {
        if (!worldObj.isRemote) {
            PacketHandler.sendPacketToAllPlayers(getDescriptionPacket(),
                    worldObj);
        }
    }

    public Packet getDescriptionPacket() {
        NBTTagCompound nbtTag = new NBTTagCompound();
        writeToNBT(nbtTag);
        return new S35PacketUpdateTileEntity(this.getPos(), 1, nbtTag);
    }

    @Override
    public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
        worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(),
                getPos().getY(), getPos().getZ());
        readFromNBT(packet.getNbtCompound());
    }

    @Override
    public void update() {
        updateEntity();
    }

    @Deprecated
    public void updateEntity() {

    }

    public int getFacingInt() {
        Block block = worldObj.getBlockState(pos).getBlock();
        if(block instanceof BlockMachineBase){
            return ((BlockMachineBase) block).getFacing(worldObj.getBlockState(pos)).getIndex();
        }
        return 0;
    }

    public EnumFacing getFacingEnum() {
        Block block = worldObj.getBlockState(pos).getBlock();
        if(block instanceof BlockMachineBase){
            return ((BlockMachineBase) block).getFacing(worldObj.getBlockState(pos));
        }
        return null;
    }


    public void setFacing(EnumFacing enumFacing) {
        Block block = worldObj.getBlockState(pos).getBlock();
        if(block instanceof BlockMachineBase){
            ((BlockMachineBase) block).setFacing(enumFacing, worldObj, pos);
        }
    }

}
<commit_msg>Fixed machines loosing state<commit_after>package techreborn.tiles;

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;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraft.world.World;
import reborncore.common.packets.PacketHandler;
import techreborn.blocks.BlockMachineBase;

public class TileMachineBase extends TileEntity implements ITickable {

    public void syncWithAll() {
        if (!worldObj.isRemote) {
            PacketHandler.sendPacketToAllPlayers(getDescriptionPacket(),
                    worldObj);
        }
    }

    public Packet getDescriptionPacket() {
        NBTTagCompound nbtTag = new NBTTagCompound();
        writeToNBT(nbtTag);
        return new S35PacketUpdateTileEntity(this.getPos(), 1, nbtTag);
    }

    @Override
    public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
        worldObj.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(),
                getPos().getY(), getPos().getZ());
        readFromNBT(packet.getNbtCompound());
    }

    @Override
    public void update() {
        updateEntity();
    }

    @Deprecated
    public void updateEntity() {

    }

    public int getFacingInt() {
        Block block = worldObj.getBlockState(pos).getBlock();
        if(block instanceof BlockMachineBase){
            return ((BlockMachineBase) block).getFacing(worldObj.getBlockState(pos)).getIndex();
        }
        return 0;
    }

    public EnumFacing getFacingEnum() {
        Block block = worldObj.getBlockState(pos).getBlock();
        if(block instanceof BlockMachineBase){
            return ((BlockMachineBase) block).getFacing(worldObj.getBlockState(pos));
        }
        return null;
    }


    public void setFacing(EnumFacing enumFacing) {
        Block block = worldObj.getBlockState(pos).getBlock();
        if(block instanceof BlockMachineBase){
            ((BlockMachineBase) block).setFacing(enumFacing, worldObj, pos);
        }
    }


    //This stops the tile from getting cleared when the state is updated(rotation and on/off)
    @Override
    public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newSate) {
        if(oldState.getBlock() != newSate.getBlock()){
            return true;
        }
        return false;
    }
}

{'fraction_non_alphanumeric': 0.10392277675087287, 'fraction_numerical': 0.003286095707537482, 'mean_word_length': 3.2164502164502164, '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': '6955152', 'n_tokens_mistral': 1410, 'n_tokens_neox': 1384, 'n_words': 268}