package hmggirlfront.block.tile;

import hmggirlfront.mod_GirlFront;
import hmggirlfront.gui.GFBlockContainerInventory;
import hmggirlfront.items.ItemDollCore;
import hmggirlfront.network.GFClientMessageKeyPressed;
import hmggirlfront.network.GFPacketHandler;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Items;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.inventory.ItemStackHelper;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntityLockable;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraft.util.NonNullList;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.datafix.DataFixer;
import net.minecraft.util.datafix.FixTypes;
import net.minecraft.util.datafix.walkers.ItemStackDataLists;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class TileEntityM_Crafting extends TileEntityLockable implements ITickable, ISidedInventory
{
    private static final int[] SLOTS_TOP = new int[] {0};
    private static final int[] SLOTS_BOTTOM = new int[] {2, 1};
    private static final int[] SLOTS_SIDES = new int[] {1};
    /** The ItemStacks that hold the items currently being used in the furnace */
    public NonNullList<ItemStack> furnaceItemStacks = NonNullList.<ItemStack>withSize(8, ItemStack.EMPTY);
    /** The number of ticks that the furnace will keep burning */
    private int furnaceBurnTime;
    /** The number of ticks that a fresh copy of the currently-burning item would keep the furnace burning for */
    private int currentItemBurnTime;
    private int cookTime;
    private int totalCookTime;
    private String furnaceCustomName;
    
    public  boolean cancraft;
    public  int crafttime;
    
    public int gui_id = 0;
    
    public static boolean start;

    /**
     * Returns the number of slots in the inventory.
     */
    public int getSizeInventory()
    {
        return this.furnaceItemStacks.size();
    }

    public boolean isEmpty()
    {
        for (ItemStack itemstack : this.furnaceItemStacks)
        {
            if (!itemstack.isEmpty())
            {
                return false;
            }
        }

        return true;
    }

    /**
     * Returns the stack in the given slot.
     */
    public ItemStack getStackInSlot(int index)
    {
        return this.furnaceItemStacks.get(index);
    }

    /**
     * Removes up to a specified number of items from an inventory slot and returns them in a new stack.
     */
    public ItemStack decrStackSize(int index, int count)
    {
        return ItemStackHelper.getAndSplit(this.furnaceItemStacks, index, count);
    }

    /**
     * Removes a stack from the given slot and returns it.
     */
    public ItemStack removeStackFromSlot(int index)
    {
        return ItemStackHelper.getAndRemove(this.furnaceItemStacks, index);
    }

    /**
     * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
     */
    public void setInventorySlotContents(int index, ItemStack stack)
    {
        ItemStack itemstack = this.furnaceItemStacks.get(index);
        boolean flag = !stack.isEmpty() && stack.isItemEqual(itemstack) && ItemStack.areItemStackTagsEqual(stack, itemstack);
        this.furnaceItemStacks.set(index, stack);

        if (stack.getCount() > this.getInventoryStackLimit())
        {
            stack.setCount(this.getInventoryStackLimit());
        }

        if (index == 0 && !flag)
        {
            this.totalCookTime = this.getCookTime(stack);
            this.cookTime = 0;
            this.markDirty();
        }
    }

    /**
     * Get the name of this object. For players this returns their username
     */
    public String getName()
    {
        //return this.hasCustomName() ? this.furnaceCustomName : "container.furnace";
    	return this.hasCustomName() ? this.furnaceCustomName : "hmggirlfront.container.crafting_m.name";
    }

    /**
     * Returns true if this thing is named
     */
    public boolean hasCustomName()
    {
        return this.furnaceCustomName != null && !this.furnaceCustomName.isEmpty();
    }

    public void setCustomInventoryName(String p_145951_1_)
    {
        this.furnaceCustomName = p_145951_1_;
    }

    public static void registerFixesFurnace(DataFixer fixer)
    {
        fixer.registerWalker(FixTypes.BLOCK_ENTITY, new ItemStackDataLists(TileEntityM_Crafting.class, new String[] {"Items"}));
    }

    public void readFromNBT(NBTTagCompound compound)
    {
        super.readFromNBT(compound);
        this.furnaceItemStacks = NonNullList.<ItemStack>withSize(this.getSizeInventory(), ItemStack.EMPTY);
        ItemStackHelper.loadAllItems(compound, this.furnaceItemStacks);
        this.furnaceBurnTime = compound.getInteger("BurnTime");
        this.cookTime = compound.getInteger("CookTime");
        this.totalCookTime = compound.getInteger("CookTimeTotal");
       // this.currentItemBurnTime = getItemBurnTime(this.furnaceItemStacks.get(1));

        this.cancraft = compound.getBoolean("cancraft");
        this.crafttime = compound.getInteger("crafttime");
        
        if (compound.hasKey("CustomName", 8))
        {
            this.furnaceCustomName = compound.getString("CustomName");
        }
    }

    public NBTTagCompound writeToNBT(NBTTagCompound compound)
    {
        super.writeToNBT(compound);
        //compound.setInteger("BurnTime", (short)this.furnaceBurnTime);
        compound.setInteger("CookTime", (short)this.cookTime);
        compound.setInteger("CookTimeTotal", (short)this.totalCookTime);
        ItemStackHelper.saveAllItems(compound, this.furnaceItemStacks);

        compound.setBoolean("cancraft", this.cancraft);
        compound.setInteger("crafttime", this.crafttime);
        
        if (this.hasCustomName())
        {
            compound.setString("CustomName", this.furnaceCustomName);
        }

        return compound;
    }

    /**
     * Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended.
     */
    public int getInventoryStackLimit()
    {
        return 64;
    }

    /**
     * Furnace isBurning
     */
    public boolean isBurning()
    {
        return this.furnaceBurnTime > 0;
    }

    @SideOnly(Side.CLIENT)
    public static boolean isBurning(IInventory inventory)
    {
        return inventory.getField(0) > 0;
    }

    @SideOnly(Side.CLIENT)
    public static int getClientCrafttime(TileEntityM_Crafting inv)
    {
        return inv.crafttime;
    }
    
    public EntityItem entityDropItem(ItemStack stack, float offsetY)
    {
        if (stack.isEmpty())
        {
            return null;
        }
        else
        {
        	BlockPos pos = this.pos;
            EntityItem entityitem = new EntityItem(this.world, pos.getX(), pos.getY() + (double)offsetY, pos.getZ(), stack);
            entityitem.setDefaultPickupDelay();
              this.world.spawnEntity(entityitem);
            return entityitem;
        }
    }
    /**
     * Like the old updateEntity(), except more generic.
     */
    public void update()
    {
    	{
    		ItemStack hp = (ItemStack)this.furnaceItemStacks.get(0);
            ItemStack bullet = (ItemStack)this.furnaceItemStacks.get(1);
            ItemStack food = (ItemStack)this.furnaceItemStacks.get(2);
            ItemStack parts = (ItemStack)this.furnaceItemStacks.get(3);
            
            ItemStack kaisoku = (ItemStack)this.furnaceItemStacks.get(4);
            if(!kaisoku.isEmpty()) {
            	if(!hp.isEmpty() && !bullet.isEmpty() && !food.isEmpty() && !parts.isEmpty()) {
            		if(!this.world.isRemote)this.furnaceItemStacks.set(7, new ItemStack(this.getCraftID(hp, bullet, food, parts)));
            		this.furnaceItemStacks.set(0, new ItemStack((Item)null));
            		this.furnaceItemStacks.set(1, new ItemStack((Item)null));
            		this.furnaceItemStacks.set(2, new ItemStack((Item)null));
            		this.furnaceItemStacks.set(3, new ItemStack((Item)null));
            		 ItemStack k = (ItemStack)this.furnaceItemStacks.get(4);
            		 k.shrink(1);
            		 if(k.getCount() > 0) {
            			 this.furnaceItemStacks.set(4, k);
            		 }else {
            			 this.furnaceItemStacks.set(4, new ItemStack((Item)null));
            		 }
            		 ItemStack output = (ItemStack)this.furnaceItemStacks.get(6);
            		 if(!output.isEmpty()) {
            			 if(!this.world.isRemote)this.entityDropItem(output, 0.0F);
            			 this.furnaceItemStacks.set(6, new ItemStack((Item)null));
            		 }
            	}
            }
            int ct = 1;
            ItemStack off = (ItemStack)this.furnaceItemStacks.get(7);
            if(!off.isEmpty()) {
            	//this.cancraft = true;
            	if(off.getItem() instanceof ItemDollCore) {
            		ItemDollCore core = (ItemDollCore) off.getItem();
            		ct = core.craft_time;
            	}
            	if(!this.world.isRemote)++this.crafttime;
            	ItemStack rapid = (ItemStack)this.furnaceItemStacks.get(5);
            	if(!rapid.isEmpty() && rapid.getItem() == mod_GirlFront.idoll_doll_rapidcontract) {
            		ItemStack k = (ItemStack)this.furnaceItemStacks.get(5);
           		    k.shrink(1);
           		     if(k.getCount() > 0) {
           			    this.furnaceItemStacks.set(5, k);
           		     }else {
           			    this.furnaceItemStacks.set(5, new ItemStack((Item)null));
           		     }
            		this.crafttime = ct;
            	}
            	if(this.crafttime >= ct) {
            		this.furnaceItemStacks.set(6, off);
            		this.furnaceItemStacks.set(7, new ItemStack((Item)null));
            		//this.playSound(SoundEvents.ENTITY_PLAYER_LEVELUP, 1.0F, 1.0F);
            		BlockPos pos = this.pos;
            		this.world.playSound((EntityPlayer)null, pos.getX(), pos.getY(), pos.getZ(), 
            				SoundEvents.ENTITY_PLAYER_LEVELUP, SoundCategory.NEUTRAL, 1, 1);
            	}
            }else {
            	this.crafttime = 0;
        		this.cancraft = false;
            }
            
            /*if(this.cancraft && !off.isEmpty()) {
            	
            }
            if(off.isEmpty()) {
            	this.crafttime = 0;
        		this.cancraft = false;
            }*/
            if(FMLCommonHandler.instance().getMinecraftServerInstance() != null) {
				for (EntityPlayerMP player : FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayers())
	            {
					GFPacketHandler.INSTANCE2.sendTo(new GFClientMessageKeyPressed(201, crafttime,
		    				this.getPos().getX(), this.getPos().getY(), this.getPos().getZ()), player);
	            }
            }
            
    	}
    }

    
    public Item getCraftID(ItemStack hp, ItemStack bullet, ItemStack food, ItemStack parts) {
    	Item item = this.getHG();
    	
    	int hpc = hp.getCount();
    	int bulletc = bullet.getCount();
    	int foodc = food.getCount();
    	int partsc = parts.getCount();
    	if(mod_GirlFront.isDebug) {
    		if((hpc == 1 && bulletc == 1 && foodc == 1 && partsc == 1)) {
    			item = this.getHG();
    		}
    		else if((hpc == 2 && bulletc == 2 && foodc == 2 && partsc == 2)) {
    			item = this.getAR();
    		}else if((hpc == 3 && bulletc == 3 && foodc == 3 && partsc == 3)) {
    			item = this.getSMG();
    		}else if((hpc == 4 && bulletc == 4 && foodc == 4 && partsc == 4)) {
    			item = this.getRF();
    		}else if((hpc == 5 && bulletc == 5 && foodc == 5 && partsc == 5)) {
    			item = this.getMG();
    		}else if((hpc == 6 && bulletc == 6 && foodc == 6 && partsc == 6)) {
			    item = this.getSG();
			}else if((hpc == 7 && bulletc == 7 && foodc == 7 && partsc == 7)) {
			    item = this.getGL();
			}
    		
    	}else {
    		if((hpc >= 10 && hpc <= 40 )) {
        		if((bulletc >= 10 && bulletc <= 20 )) {
    				if((foodc >= 10 && foodc <= 20 )) {
    					if((partsc >= 21 && partsc <= 32 )) {
    						item = this.getRF();
    					}else if((partsc >= 10 && partsc <= 20 )){
    						item = this.getAR();
    					}else {
    						item = this.getSMG();
    					}
    				}
    				else if((foodc >= 21 && foodc <= 40 )) {
    					item = this.getAR();
    				}
    			}else if((bulletc >= 21 && bulletc <= 40 )) {
    				if((foodc >= 10 && foodc <= 40 )) {
    					item = this.getAR();
    				}else {
    					item = this.getSMG();
    				}
    			}
        	}else if((hpc >= 41)) {
        		if(bulletc >= 30 && bulletc < 50) {
        			item = this.getSG();
        		}else {
        			if(partsc >= 63) {
        				item = this.getGL();
        			}else {
        				item = this.getMG();
        			}
        		}
        	}
    	}
    	if(hpc == 10 && bulletc == 30 && foodc == 30  && partsc == 27) {
    		item = mod_GirlFront.core_t97;
    	}
    	if(hpc == 30 && bulletc == 20 && foodc == 15  && partsc == 25) {
    		item = mod_GirlFront.core_t100;
    	}
    	if(hpc == 10 && bulletc == 10 && foodc == 10  && partsc == 15) {
    		item = mod_GirlFront.core_vector;
    	}
    	if(hpc == 9 && bulletc == 9 && foodc == 9  && partsc == 9) {
    		item = mod_GirlFront.core_g36;
    	}
    	if(hpc == 1 && bulletc == 11 && foodc == 3  && partsc == 6) {
    		item = mod_GirlFront.core_mg36;
    	}
    	if(hpc == 1 && bulletc == 3 && foodc == 2  && partsc == 1) {
    		item = mod_GirlFront.core_mg36;
    	}
    	return item;
    }
    
    public Item getHG() {
    	Item item = mod_GirlFront.core_m1911;
		/*int ra = this.world.rand.nextInt(2);
		if (ra == 0) {
			item = mod_GirlFront.core_p38;
		}*/
    	for(int i = 0; i < mod_GirlFront.hg_item.length; ++i) {
    		if(mod_GirlFront.hg_item.length > 0) {
    			int ne = this.world.rand.nextInt(mod_GirlFront.hg_item.length);
    			if(mod_GirlFront.hg_rare[ne] > 0) {
    				int ra = this.world.rand.nextInt(mod_GirlFront.hg_rare[ne]);
            		if (ra == 0 && mod_GirlFront.hg_item[ne] != null) {
            			item = mod_GirlFront.hg_item[ne];
            			break;
            		} 
    			}
    		}
    		/*if(mod_GirlFront.hg_rare[i] > 0) {
    			int ra = this.world.rand.nextInt(mod_GirlFront.hg_rare[i]);
        		if (ra == 0 && mod_GirlFront.hg_item[i] != null) {
        			item = mod_GirlFront.hg_item[i];
        			break;
        		} 
    		}*/
    	}
    	return item;
    }
    public Item getSMG() {
    	Item item = mod_GirlFront.core_idw;
    	/*int ra = this.world.rand.nextInt(10);
		if (ra == 0 || ra == 1 || ra == 2 || ra == 3 || ra == 4 || ra == 5) {
			item = mod_GirlFront.core_mp40;
		} 
		else if (ra == 6) {
			item = mod_GirlFront.core_t100;
		}*/
    	for(int i = 0; i < mod_GirlFront.smg_item.length; ++i) {
    		/*if(mod_GirlFront.smg_rare[i] > 0) {
    			int ra = this.world.rand.nextInt(mod_GirlFront.smg_rare[i]);
        		if (ra == 0 && mod_GirlFront.smg_item[i] != null) {
        			item = mod_GirlFront.smg_item[i];
        			break;
        		} 
    		}*/
    		if(mod_GirlFront.smg_item.length > 0) {
    			int ne = this.world.rand.nextInt(mod_GirlFront.smg_item.length);
    			if(mod_GirlFront.smg_rare[ne] > 0) {
    				int ra = this.world.rand.nextInt(mod_GirlFront.smg_rare[ne]);
            		if (ra == 0 && mod_GirlFront.smg_item[ne] != null) {
            			item = mod_GirlFront.smg_item[ne];
            			break;
            		} 
    			}
    		}
    	}
    	return item;
    }
    public Item getAR() {
    	Item item = mod_GirlFront.core_galil;
    	/*int ra = this.world.rand.nextInt(10);
		if (ra == 0) {
			item = mod_GirlFront.core_m4a1;
		} 
		else if (ra == 4) {
			item = mod_GirlFront.core_t97;
		}*/
    	for(int i = 0; i < mod_GirlFront.ar_item.length; ++i) {
    		/*if(mod_GirlFront.ar_rare[i] > 0) {
    			int ra = this.world.rand.nextInt(mod_GirlFront.ar_rare[i]);
        		if (ra == 0 && mod_GirlFront.ar_item[i] != null) {
        			item = mod_GirlFront.ar_item[i];
        			break;
        		} 
    		}*/
    		if(mod_GirlFront.ar_item.length > 0) {
    			int ne = this.world.rand.nextInt(mod_GirlFront.ar_item.length);
    			if(mod_GirlFront.ar_rare[ne] > 0) {
    				int ra = this.world.rand.nextInt(mod_GirlFront.ar_rare[ne]);
            		if (ra == 0 && mod_GirlFront.ar_item[ne] != null) {
            			item = mod_GirlFront.ar_item[ne];
            			break;
            		} 
    			}
    		}
    	}
    	return item;
    }
    public Item getRF() {
    	Item item = mod_GirlFront.core_fn49;
    	/*int ra = this.world.rand.nextInt(10);
		if (ra == 0) {
			item = mod_GirlFront.core_m14;
		} 
		else if (ra == 4) {
			item = mod_GirlFront.core_m14;
		}*/
    	for(int i = 0; i < mod_GirlFront.rf_item.length; ++i) {
    		/*if(mod_GirlFront.rf_rare[i] > 0) {
    			int ra = this.world.rand.nextInt(mod_GirlFront.rf_rare[i]);
        		if (ra == 0 && mod_GirlFront.rf_item[i] != null) {
        			item = mod_GirlFront.rf_item[i];
        			break;
        		} 
    		}*/
    		if(mod_GirlFront.rf_item.length > 0) {
    			int ne = this.world.rand.nextInt(mod_GirlFront.rf_item.length);
    			if(mod_GirlFront.rf_rare[ne] > 0) {
    				int ra = this.world.rand.nextInt(mod_GirlFront.rf_rare[ne]);
            		if (ra == 0 && mod_GirlFront.rf_item[ne] != null) {
            			item = mod_GirlFront.rf_item[ne];
            			break;
            		} 
    			}
    		}
    	}
    	return item;
    }
    public Item getMG() {
    	Item item = mod_GirlFront.core_mg34;
    	/*int ra = this.world.rand.nextInt(10);
		if (ra == 0) {
			item = mod_GirlFront.core_idw;
		} 
		else if (ra == 4) {
			item = mod_GirlFront.core_idw;
		}*/
    	for(int i = 0; i < mod_GirlFront.lmg_item.length; ++i) {
    		/*if(mod_GirlFront.lmg_rare[i] > 0) {
    			int ra = this.world.rand.nextInt(mod_GirlFront.lmg_rare[i]);
        		if (ra == 0 && mod_GirlFront.lmg_item[i] != null) {
        			item = mod_GirlFront.lmg_item[i];
        			break;
        		} 
    		}*/
    		if(mod_GirlFront.lmg_item.length > 0) {
    			int ne = this.world.rand.nextInt(mod_GirlFront.lmg_item.length);
    			if(mod_GirlFront.lmg_rare[ne] > 0) {
    				int ra = this.world.rand.nextInt(mod_GirlFront.lmg_rare[ne]);
            		if (ra == 0 && mod_GirlFront.lmg_item[ne] != null) {
            			item = mod_GirlFront.lmg_item[ne];
            			break;
            		} 
    			}
    		}
    	}
    	return item;
    }
    public Item getSG() {
    	Item item = mod_GirlFront.core_idw;
    	for(int i = 0; i < mod_GirlFront.sg_item.length; ++i) {
    		if(mod_GirlFront.sg_item.length > 0) {
    			int ne = this.world.rand.nextInt(mod_GirlFront.sg_item.length);
    			if(mod_GirlFront.sg_rare[ne] > 0) {
    				int ra = this.world.rand.nextInt(mod_GirlFront.sg_rare[ne]);
            		if (ra == 0 && mod_GirlFront.sg_item[ne] != null) {
            			item = mod_GirlFront.sg_item[ne];
            			break;
            		} 
    			}
    		}
    	}
    	return item;
    }
    public Item getGL() {
    	Item item = mod_GirlFront.core_mg34;
    	for(int i = 0; i < mod_GirlFront.gl_item.length; ++i) {
    		if(mod_GirlFront.gl_item.length > 0) {
    			int ne = this.world.rand.nextInt(mod_GirlFront.gl_item.length);
    			if(mod_GirlFront.gl_rare[ne] > 0) {
    				int ra = this.world.rand.nextInt(mod_GirlFront.gl_rare[ne]);
            		if (ra == 0 && mod_GirlFront.gl_item[ne] != null) {
            			item = mod_GirlFront.gl_item[ne];
            			break;
            		} 
    			}
    		}
    	}
    	return item;
    }
    
    
    
    public int getCookTime(ItemStack stack)
    {
        return 200;
    }

    

    /**
     * Don't rename this method to canInteractWith due to conflicts with Container
     */
    public boolean isUsableByPlayer(EntityPlayer player)
    {
        if (this.world.getTileEntity(this.pos) != this)
        {
            return false;
        }
        else
        {
            return player.getDistanceSq((double)this.pos.getX() + 0.5D, (double)this.pos.getY() + 0.5D, (double)this.pos.getZ() + 0.5D) <= 64.0D;
        }
    }

    public void openInventory(EntityPlayer player)
    {
    }

    public void closeInventory(EntityPlayer player)
    {
    }

    /**
     * Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot. For
     * guis use Slot.isItemValid
     */
    public boolean isItemValidForSlot(int index, ItemStack stack)
    {
        if (index == 2)
        {
            return false;
        }
        else if (index != 1)
        {
            return true;
        }
        else
        {
            ItemStack itemstack = this.furnaceItemStacks.get(1);
            //return isItemFuel(stack) || SlotFurnaceFuel.isBucket(stack) && itemstack.getItem() != Items.BUCKET;
            return false;
        }
    }

    public int[] getSlotsForFace(EnumFacing side)
    {
        if (side == EnumFacing.DOWN)
        {
            return SLOTS_BOTTOM;
        }
        else
        {
            return side == EnumFacing.UP ? SLOTS_TOP : SLOTS_SIDES;
        }
    }

    /**
     * Returns true if automation can insert the given item in the given slot from the given side.
     */
    public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction)
    {
        return this.isItemValidForSlot(index, itemStackIn);
    }

    /**
     * Returns true if automation can extract the given item in the given slot from the given side.
     */
    public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction)
    {
        if (direction == EnumFacing.DOWN && index == 1)
        {
            Item item = stack.getItem();

            if (item != Items.WATER_BUCKET && item != Items.BUCKET)
            {
                return false;
            }
        }

        return true;
    }

    public String getGuiID()
    {
        return "minecraft:furnace";
    }

    public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
    {
        return new GFBlockContainerInventory(playerInventory, this);
    }

    public int getField(int id)
    {
        switch (id)
        {
            case 0:
                return this.furnaceBurnTime;
            case 1:
                return this.currentItemBurnTime;
            case 2:
                return this.cookTime;
            case 3:
                return this.totalCookTime;
            default:
                return 0;
        }
    }

    public void setField(int id, int value)
    {
        switch (id)
        {
            case 0:
                this.furnaceBurnTime = value;
                break;
            case 1:
                this.currentItemBurnTime = value;
                break;
            case 2:
                this.cookTime = value;
                break;
            case 3:
                this.totalCookTime = value;
        }
    }

    public int getFieldCount()
    {
        return 4;
    }

    public void clear()
    {
        this.furnaceItemStacks.clear();
    }
}