package uk.binarycraft.binarycraft.blocks.silos.storagesilo;

import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;
import uk.binarycraft.binarycraft.BinaryCraft;
import uk.binarycraft.binarycraft.blocks.silos.SiloBlockBase;
import uk.binarycraft.binarycraft.blocks.silos.SiloTileEntity;
import uk.binarycraft.binarycraft.gui.GuiHandler.GUI;

import static net.minecraft.item.Item.getItemFromBlock;
import static uk.binarycraft.binarycraft.items.ModItems.machineCore;


public class BlockStorageSilo extends SiloBlockBase
{

	public BlockStorageSilo()
	{
		super(Material.IRON, "storagesilo", 2.5f, null);
		//TODO: setStepSound(soundTypeMetal);
		isBlockContainer = true;
	}


	@Override
	public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState blockState, EntityPlayer player, EnumHand side, ItemStack itemStack, EnumFacing enumFacing, float p7, float p8, float p9)
	{
		player.openGui(BinaryCraft.instance, GUI.STORAGESILO.ordinal, world, blockPos.getX(), blockPos.getY(), blockPos.getZ());
		return true;
	}


	@Override
	public TileEntity createNewTileEntity(World world, int p1)
	{
		return new SiloTileEntity();
	}


	@Override
	public EnumBlockRenderType getRenderType(IBlockState blockState)
	{
		return EnumBlockRenderType.MODEL;
	}

	@Override
	public void registerCraftingRecipe()
	{
		GameRegistry.addRecipe(new ItemStack(this), "iei", "cmc", "idi",
				'i', new ItemStack(Items.IRON_INGOT),
				'e', new ItemStack(Items.ENDER_PEARL),
				'c', new ItemStack(getItemFromBlock(Blocks.CHEST)),
				'm', machineCore,
				'd', new ItemStack(Items.DIAMOND));
	}
}
