<commit_before>package pixlepix.minechem.particlephysics.tile;

import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import pixlepix.minechem.api.core.EnumElement;
import pixlepix.minechem.api.core.EnumMolecule;
import pixlepix.minechem.common.MinechemItems;
import pixlepix.minechem.common.items.ItemMolecule;
import pixlepix.minechem.particlephysics.api.BaseParticle;
import pixlepix.minechem.particlephysics.blocks.InfiniteEmitter;
import pixlepix.minechem.particlephysics.entity.*;

public class EmitterTileEntity extends TileEntity implements IInventory {

    public int interval = 40;
    public ItemStack[] inventory = new ItemStack[7];

    public int fuelType;

    public int fuelMeta;
    public int fuelStored = 0;

	public int getMaxFuelFromItems(){
		if(this.inventory[0]!=null && this.inventory[0].getItem() instanceof ItemMolecule){
			return 100*ItemMolecule.getMolecule(this.inventory[0]).getSize();
		}else{
			return 100;
		}
	}

    public void updateEntity() {
        if (!worldObj.isRemote && worldObj.getTotalWorldTime() % ((20 * interval) + 20) == 0) {
            if (fuelStored < 1) {
                if (this.inventory != null) {
                    if (this.inventory[0] != null && isValidFuel(this.inventory[0].itemID)) {

	                    this.fuelStored=this.getMaxFuelFromItems();

                        this.fuelType = this.inventory[0].itemID;
                        this.fuelMeta = this.inventory[0].getItemDamage();
                        this.decrStackSize(0, 1);
                        if (this.inventory[0] == null) {
                            for (int i = 1; i < getSizeInventory(); i++) {
                                ItemStack item = getStackInSlot(i);
                                if (item != null && this.isValidFuel(item.itemID)) {
                                    this.setInventorySlotContents(0, item);
                                    this.setInventorySlotContents(i, null);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            if (fuelStored > 0) {
                if (!(Block.blocksList[worldObj.getBlockId(xCoord, yCoord, zCoord)] instanceof InfiniteEmitter && getStackInSlot(0).stackSize >= 63)) {
                    this.fuelStored--;
                }
                ForgeDirection[] outputDirections = {ForgeDirection.SOUTH, ForgeDirection.NORTH, ForgeDirection.WEST, ForgeDirection.EAST};
                for (ForgeDirection dir : outputDirections) {

                    BaseParticle particle = getParticleFromFuel(fuelType, fuelMeta);
                    if (particle == null) {
                        return;
                    }
                    particle.addVelocity(dir.offsetX, dir.offsetY, dir.offsetZ);
                    particle.setPosition(xCoord + dir.offsetX + 0.375, yCoord + dir.offsetY + 0.375, zCoord + dir.offsetZ + 0.375);
                    worldObj.spawnEntityInWorld(particle);
<commit_msg>Fixed Infinite emitter tile entity crash<commit_after>package pixlepix.minechem.particlephysics.tile;

import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import pixlepix.minechem.api.core.EnumElement;
import pixlepix.minechem.api.core.EnumMolecule;
import pixlepix.minechem.common.MinechemItems;
import pixlepix.minechem.common.items.ItemMolecule;
import pixlepix.minechem.particlephysics.api.BaseParticle;
import pixlepix.minechem.particlephysics.blocks.InfiniteEmitter;
import pixlepix.minechem.particlephysics.entity.*;

public class EmitterTileEntity extends TileEntity implements IInventory {

    public int interval = 40;
    public ItemStack[] inventory = new ItemStack[7];

    public int fuelType;

    public int fuelMeta;
    public int fuelStored = 0;

	public int getMaxFuelFromItems(){
		if(this.inventory[0]!=null && this.inventory[0].getItem() instanceof ItemMolecule){
			return 100*ItemMolecule.getMolecule(this.inventory[0]).getSize();
		}else{
			return 100;
		}
	}

    public void updateEntity() {
        if (!worldObj.isRemote && worldObj.getTotalWorldTime() % ((20 * interval) + 20) == 0) {
            if (fuelStored < 1) {
                if (this.inventory != null) {
                    if (this.inventory[0] != null && isValidFuel(this.inventory[0].itemID)) {

	                    this.fuelStored=this.getMaxFuelFromItems();

                        this.fuelType = this.inventory[0].itemID;
                        this.fuelMeta = this.inventory[0].getItemDamage();
                        this.decrStackSize(0, 1);
                        if (this.inventory[0] == null) {
                            for (int i = 1; i < getSizeInventory(); i++) {
                                ItemStack item = getStackInSlot(i);
                                if (item != null && this.isValidFuel(item.itemID)) {
                                    this.setInventorySlotContents(0, item);
                                    this.setInventorySlotContents(i, null);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            if (fuelStored > 0) {
	            if (!(Block.blocksList[worldObj.getBlockId(xCoord, yCoord, zCoord)] instanceof InfiniteEmitter && getStackInSlot(0) != null && getStackInSlot(0).stackSize >= 63)) {
		            this.fuelStored--;
                }
                ForgeDirection[] outputDirections = {ForgeDirection.SOUTH, ForgeDirection.NORTH, ForgeDirection.WEST, ForgeDirection.EAST};
                for (ForgeDirection dir : outputDirections) {

                    BaseParticle particle = getParticleFromFuel(fuelType, fuelMeta);
                    if (particle == null) {
                        return;
                    }
                    particle.addVelocity(dir.offsetX, dir.offsetY, dir.offsetZ);
                    particle.setPosition(xCoord + dir.offsetX + 0.375, yCoord + dir.offsetY + 0.375, zCoord + dir.offsetZ + 0.375);
                    worldObj.spawnEntityInWorld(particle);

{'fraction_non_alphanumeric': 0.10198300283286119, 'fraction_numerical': 0.013269718204860594, 'mean_word_length': 2.00672344240251, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6002332', 'n_tokens_mistral': 2027, 'n_tokens_neox': 1844, 'n_words': 331}