<commit_before>package mcjty.deepresonance.blocks.machine;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import elec332.core.world.WorldHelper;
import mcjty.container.InventoryHelper;
import mcjty.deepresonance.DeepResonance;
import mcjty.deepresonance.blocks.ModBlocks;
import mcjty.deepresonance.blocks.base.ElecEnergyReceiverTileBase;
import mcjty.deepresonance.blocks.tank.ITankHook;
import mcjty.deepresonance.blocks.tank.TileTank;
import mcjty.deepresonance.config.ConfigMachines;
import mcjty.deepresonance.fluid.DRFluidRegistry;
import mcjty.deepresonance.fluid.LiquidCrystalFluidTagData;
import mcjty.network.Argument;
import mcjty.network.PacketRequestIntegerFromServer;
import mcjty.varia.BlockTools;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;

import java.util.Map;

/**
 * Created by Elec332 on 9-8-2015.
 */
public class SmelterTileEntity extends ElecEnergyReceiverTileBase implements ITankHook, ISidedInventory {

    public static final String CMD_GETPROGRESS = "getProgress";
    public static final String CLIENTCMD_GETPROGRESS = "getProgress";

    private InventoryHelper inventoryHelper = new InventoryHelper(this, SmelterContainer.factory, 1);

    public SmelterTileEntity() {
        super(900*ConfigMachines.Smelter.rfPerTick, 3*ConfigMachines.Smelter.rfPerTick);
        checkTanks = true;
    }

    private int totalProgress = 0;
    private int progress = 0;
    private TileTank lavaTank;
    private TileTank rclTank;
    private boolean checkTanks;
    private float finalQuality = 1.0f;  // Calculated quality based on the amount of lava in the lava tank
    private float finalPurity = 0.1f;   // Calculated quality based on the amount of lava in the lava tank

    @SideOnly(Side.CLIENT)
    private int progressPercentage = 0;

    @Override
    protected void checkStateServer() {
        if (progress > 0) {
            if (canWork()) {
                progress--;
                storage.extractEnergy(ConfigMachines.Smelter.rfPerTick, true);
                if (progress == 0) {
                    // Done!
                    stopSmelting();
                }
            }
        } else {
            int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
            int meta2;
            if (canWork() && validSlot()) {
                startSmelting();
                meta2 = BlockTools.setRedstoneSignalIn(meta, true);
            } else {
                meta2 = BlockTools.setRedstoneSignalIn(meta, false);
            }
            if (meta != meta2) {
                worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, meta2, 3);
            }
        }
    }

    @SideOnly(Side.CLIENT)
    public int getProgressPercentage() {
        return progressPercentage;
    }

    private boolean canWork() {
        if (checkTanks) {
            if (checkTanks()) {
                checkTanks = false;
            } else {
                return false;
            }
        }
        return storage.getMaxEnergyStored() >= ConfigMachines.Smelter.rfPerTick;
    }

    private boolean checkTanks(){
        return lavaTank != null && rclTank != null
                && DRFluidRegistry.getFluidFromStack(lavaTank.getFluid()) == FluidRegistry.LAVA
                && lavaTank.getFluidAmount() > lavaTank.getCapacity()*0.25f
                && rclTank.fill(ForgeDirection.UNKNOWN, new FluidStack(DRFluidRegistry.liquidCrystal, ConfigMachines.Smelter.rclPerOre), false) == ConfigMachines.Smelter.rclPerOre;
    }

    private boolean validSlot(){
        return inventoryHelper.getStackInSlot(SmelterContainer.SLOT_OREINPUT) != null && inventoryHelper.getStackInSlot(SmelterContainer.SLOT_OREINPUT).getItem() == Item.getItemFromBlock(ModBlocks.resonatingOreBlock);
    }
<commit_msg>Fixed a sync issue in the smelter gui<commit_after>package mcjty.deepresonance.blocks.machine;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import elec332.core.world.WorldHelper;
import mcjty.container.InventoryHelper;
import mcjty.deepresonance.DeepResonance;
import mcjty.deepresonance.blocks.ModBlocks;
import mcjty.deepresonance.blocks.base.ElecEnergyReceiverTileBase;
import mcjty.deepresonance.blocks.tank.ITankHook;
import mcjty.deepresonance.blocks.tank.TileTank;
import mcjty.deepresonance.config.ConfigMachines;
import mcjty.deepresonance.fluid.DRFluidRegistry;
import mcjty.deepresonance.fluid.LiquidCrystalFluidTagData;
import mcjty.network.Argument;
import mcjty.network.PacketRequestIntegerFromServer;
import mcjty.varia.BlockTools;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;

import java.util.Map;

/**
 * Created by Elec332 on 9-8-2015.
 */
public class SmelterTileEntity extends ElecEnergyReceiverTileBase implements ITankHook, ISidedInventory {

    public static final String CMD_GETPROGRESS = "getProgress";
    public static final String CLIENTCMD_GETPROGRESS = "getProgress";

    private InventoryHelper inventoryHelper = new InventoryHelper(this, SmelterContainer.factory, 1);

    public SmelterTileEntity() {
        super(900*ConfigMachines.Smelter.rfPerTick, 3*ConfigMachines.Smelter.rfPerTick);
        checkTanks = true;
    }

    private int totalProgress = 0;
    private int progress = 0;
    private TileTank lavaTank;
    private TileTank rclTank;
    private boolean checkTanks;
    private float finalQuality = 1.0f;  // Calculated quality based on the amount of lava in the lava tank
    private float finalPurity = 0.1f;   // Calculated quality based on the amount of lava in the lava tank

    @SideOnly(Side.CLIENT)
    private static int progressPercentage = 0;

    @Override
    protected void checkStateServer() {
        if (progress > 0) {
            if (canWork()) {
                progress--;
                storage.extractEnergy(ConfigMachines.Smelter.rfPerTick, true);
                if (progress == 0) {
                    // Done!
                    stopSmelting();
                }
            }
        } else {
            int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
            int meta2;
            if (canWork() && validSlot()) {
                startSmelting();
                meta2 = BlockTools.setRedstoneSignalIn(meta, true);
            } else {
                meta2 = BlockTools.setRedstoneSignalIn(meta, false);
            }
            if (meta != meta2) {
                worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, meta2, 3);
            }
        }
    }

    @SideOnly(Side.CLIENT)
    public static int getProgressPercentage() {
        return progressPercentage;
    }

    private boolean canWork() {
        if (checkTanks) {
            if (checkTanks()) {
                checkTanks = false;
            } else {
                return false;
            }
        }
        return storage.getMaxEnergyStored() >= ConfigMachines.Smelter.rfPerTick;
    }

    private boolean checkTanks(){
        return lavaTank != null && rclTank != null
                && DRFluidRegistry.getFluidFromStack(lavaTank.getFluid()) == FluidRegistry.LAVA
                && lavaTank.getFluidAmount() > lavaTank.getCapacity()*0.25f
                && rclTank.fill(ForgeDirection.UNKNOWN, new FluidStack(DRFluidRegistry.liquidCrystal, ConfigMachines.Smelter.rclPerOre), false) == ConfigMachines.Smelter.rclPerOre;
    }

    private boolean validSlot(){
        return inventoryHelper.getStackInSlot(SmelterContainer.SLOT_OREINPUT) != null && inventoryHelper.getStackInSlot(SmelterContainer.SLOT_OREINPUT).getItem() == Item.getItemFromBlock(ModBlocks.resonatingOreBlock);
    }

{'fraction_non_alphanumeric': 0.09073724007561437, 'fraction_numerical': 0.0082703213610586, 'mean_word_length': 3.0271170313986677, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '6441549', 'n_tokens_mistral': 2715, 'n_tokens_neox': 2522, 'n_words': 487}