package net.viddeno.technical.machine.tileentity;

import net.minecraft.init.Items;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.viddeno.technical.machine.BlastFurnaceMedium;
import net.viddeno.technical.machine.Tier;
import net.viddeno.technical.machine.Type;
import net.viddeno.technical.machine.recipes.BlastFurnaceRecipes;

public class TileEntityBlastFurnaceMedium extends TileEntityMachine implements ISidedInventory {

	private static final int[] slotsTop = { 0 };
	private static final int[] slotsBottom = { 2, 3, 4, 5, 6, 7, 1 };
	private static final int[] slotsSides = { 1 };
	
	public TileEntityBlastFurnaceMedium() {
		super(Type.blastFurnaceMedium, 11);
	}
	
	protected void updateBlockState(boolean active, World world, int x, int y, int z) {
		BlastFurnaceMedium.updateBlockState(active, world, x, y, z);
	}
	
	public ItemStack[] getSmeltingResult(ItemStack[] itemStacks) {
		return BlastFurnaceRecipes.smelting().getSmeltingResult(itemStacks, Tier.medium);
	}
	
	public boolean isItemUsedInRecipe(ItemStack itemStack) {
		return BlastFurnaceRecipes.isItemUsedInRecipe(itemStack);
	}

	@Override
	public int[] getAccessibleSlotsFromSide(int side) {
		return side == 0 ? slotsBottom : (side == 1 ? slotsTop : slotsSides);
	}

	@Override
	public boolean canInsertItem(int side, ItemStack itemStack, int par3) {
		return isItemValidForSlot(side, itemStack);
	}

	@Override
	public boolean canExtractItem(int side, ItemStack itemStack, int par3) {
		return par3 != 0 || side != 1 || itemStack.getItem() == Items.bucket;
	}
}