package com.miningmark48.pearcelmod.block;
import com.miningmark48.pearcelmod.reference.GUIs;
import com.miningmark48.pearcelmod.reference.Reference;
import com.miningmark48.pearcelmod.tileentity.TileEntityPearcelWorkbench;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryHelper;
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.common.ForgeChunkManager;
public class BlockPearcelWorkbench extends BlockContainer{
public BlockPearcelWorkbench(){
super(Material.WOOD);
setResistance(1.25F);
setHardness(1.0F);
}
public EnumBlockRenderType getRenderType(IBlockState state)
{
return EnumBlockRenderType.MODEL;
}
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ){
if (!player.isSneaking()){
player.openGui(Reference.MOD_ID, GUIs.gui_id_pearcel_workbench, world, pos.getX(), pos.getY(), pos.getZ());
return true;
}else{
return false;
}
}
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof IInventory)
{
InventoryHelper.dropInventoryItems(worldIn, pos, (IInventory)tileentity);
worldIn.updateComparatorOutputLevel(pos, this);
}
super.breakBlock(worldIn, pos, state);
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
return new TileEntityPearcelWorkbench();
}
}