<commit_before>package mcjty.rftools.blocks.logic.generic;

import mcjty.lib.entity.GenericTileEntity;
import mcjty.lib.tools.WorldTools;
import net.minecraft.block.state.IBlockState;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;

public class LogicTileEntity extends GenericTileEntity {

    private LogicFacing facing = LogicFacing.DOWN_TONORTH;

    protected boolean powered = false;

    public LogicFacing getFacing(IBlockState state) {
        Integer meta = state.getValue(LogicSlabBlock.META_INTERMEDIATE);
        return LogicFacing.getFacingWithMeta(facing, meta);
    }

    public void setFacing(LogicFacing facing) {
        this.facing = facing;
        markDirty();
    }

    public boolean isPowered() {
        return powered;
    }

    protected void setRedstoneState(boolean newout) {
        if (powered == newout) {
            return;
        }
        powered = newout;
        markDirty();
        EnumFacing outputSide = getFacing(getWorld().getBlockState(this.pos)).getInputSide().getOpposite();
        WorldTools.neighborChanged(getWorld(), outputSide, this.getBlockType(), this.pos);
//        getWorld().notifyNeighborsOfStateChange(this.pos, this.getBlockType());
    }

    @Override
    public void readFromNBT(NBTTagCompound tagCompound) {
        super.readFromNBT(tagCompound);
        facing = LogicFacing.values()[tagCompound.getInteger("lf")];<commit_msg>Worked around an issue with bad block (may be a sponge bug but I can protect around it easily here)<commit_after>package mcjty.rftools.blocks.logic.generic;

import mcjty.lib.entity.GenericTileEntity;
import mcjty.lib.tools.WorldTools;
import net.minecraft.block.state.IBlockState;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;

public class LogicTileEntity extends GenericTileEntity {

    private LogicFacing facing = LogicFacing.DOWN_TONORTH;

    protected boolean powered = false;

    public LogicFacing getFacing(IBlockState state) {
        // Should not be needed but apparently it sometimes is
        if (!(state.getBlock() instanceof LogicSlabBlock)) {
            return LogicFacing.DOWN_TOEAST;
        }
        Integer meta = state.getValue(LogicSlabBlock.META_INTERMEDIATE);
        return LogicFacing.getFacingWithMeta(facing, meta);
    }

    public void setFacing(LogicFacing facing) {
        this.facing = facing;
        markDirty();
    }

    public boolean isPowered() {
        return powered;
    }

    protected void setRedstoneState(boolean newout) {
        if (powered == newout) {
            return;
        }
        powered = newout;
        markDirty();
        EnumFacing outputSide = getFacing(getWorld().getBlockState(this.pos)).getInputSide().getOpposite();
        WorldTools.neighborChanged(getWorld(), outputSide, this.getBlockType(), this.pos);
//        getWorld().notifyNeighborsOfStateChange(this.pos, this.getBlockType());
    }

    @Override
    public void readFromNBT(NBTTagCompound tagCompound) {
        super.readFromNBT(tagCompound);
        facing = LogicFacing.values()[tagCompound.getInteger("lf")];
{'fraction_non_alphanumeric': 0.09667093469910372, 'fraction_numerical': 0.0, 'mean_word_length': 3.4138418079096047, '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': '3110533', 'n_tokens_mistral': 955, 'n_tokens_neox': 913, 'n_words': 183}