package com.mrcrayfish.furniture.blocks;
import java.util.List;
import com.mrcrayfish.furniture.init.FurnitureItems;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public abstract class BlockFirePit extends Block {
public static final PropertyInteger STAGE = PropertyInteger.create("stage", 0, 3);
private static final AxisAlignedBB BOUNDING_BOX = new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 0.1875, 1.0);
public BlockFirePit(Material materialIn)
{
super(materialIn);
this.setSoundType(SoundType.WOOD);
this.setHardness(1.0F);
}
@Override
public boolean isOpaqueCube(IBlockState state)
{
return false;
}
@Override
public boolean isFullCube(IBlockState state)
{
return false;
}
@Override
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
return worldIn.isSideSolid(pos.down(), EnumFacing.UP);
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
{
return BOUNDING_BOX;
}
@Override
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB axisAligned, List<AxisAlignedBB> axisAlignedList, Entity collidingEntity)
{
super.addCollisionBoxToList(pos, axisAligned, axisAlignedList, BOUNDING_BOX);
}
@Override
public int getMetaFromState(IBlockState state)
{
return isBurning() ? 0 : (Integer) state.getValue(STAGE);
}
@Override
public IBlockState getStateFromMeta(int meta)
{
return isBurning() ? this.getDefaultState() : this.getDefaultState().withProperty(STAGE, meta);
}
@Override
protected BlockStateContainer createBlockState()
{
return isBurning() ? super.createBlockState() : new BlockStateContainer(this, new IProperty[] { STAGE });
}
@SideOnly(Side.CLIENT)
public BlockRenderLayer getBlockLayer()
{
return BlockRenderLayer.CUTOUT;
}
@Override
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player)
{
return new ItemStack(FurnitureItems.itemLog);
}
public abstract boolean isBurning();
}