package com.mrcrayfish.furniture.blocks; import java.util.Random; import com.mrcrayfish.furniture.init.FurnitureItems; import com.mrcrayfish.furniture.util.CollisionHelper; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.ColorizerFoliage; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class BlockWreath extends BlockFurniture { public BlockWreath(Material materialIn) { super(materialIn); this.setHardness(0.5F); this.setStepSound(Block.soundTypeGrass); } @SideOnly(Side.CLIENT) public int getBlockColor() { return ColorizerFoliage.getFoliageColorPine(); } @SideOnly(Side.CLIENT) public int getRenderColor(IBlockState state) { return ColorizerFoliage.getFoliageColorPine(); } @SideOnly(Side.CLIENT) public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) { return ColorizerFoliage.getFoliageColorPine(); } @Override public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighborBlock) { if (this.canPlaceCheck(world, pos, state)) { EnumFacing enumfacing = (EnumFacing) state.getValue(FACING); if (!world.getBlockState(pos.offset(enumfacing)).getBlock().isNormalCube()) { this.breakBlock(world, pos, state); this.dropBlockAsItem(world, pos, state, 0); world.setBlockToAir(pos); } } } @Override public boolean canPlaceBlockOnSide(World world, BlockPos pos, EnumFacing side) { if (side.getHorizontalIndex() == -1) { return false; } return true; } private boolean canPlaceCheck(World world, BlockPos pos, IBlockState state) { EnumFacing enumfacing = (EnumFacing) state.getValue(FACING); if (!this.canPlaceBlockOnSide(world, pos, enumfacing)) { this.dropBlockAsItem(world, pos, state, 0); world.setBlockToAir(pos); return false; } else { return true; } } @Override public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { return this.getDefaultState().withProperty(FACING, facing.getOpposite()); } @Override public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, BlockPos pos) { int metadata = getMetaFromState(blockAccess.getBlockState(pos)); float data[] = CollisionHelper.fixRotation(metadata, 0.8125F, 0F, 1F, 1F); setBlockBounds(data[0], 0F, data[1], data[2], 1F, data[3]); } @Override public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state) { return null; } @SideOnly(Side.CLIENT) public EnumWorldBlockLayer getBlockLayer() { return EnumWorldBlockLayer.CUTOUT; } }