package com.miningmark48.pearcelmod.block; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import javax.annotation.Nullable; import java.util.List; import java.util.Random; public class BlockPearcelPlush extends Block { public static PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); private static final AxisAlignedBB BOUNDING_BOX = new AxisAlignedBB(0.1875D, 0.0D, 0.125D, 0.875D, 1.0D, 0.8125D); public BlockPearcelPlush(){ super(Material.CLOTH); setHardness(0.2F); setResistance(0.15F); setSoundType(SoundType.CLOTH); } @Override @SuppressWarnings("deprecation") public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){ return BOUNDING_BOX; } @Override @SuppressWarnings("deprecation") public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn) { super.addCollisionBoxToList(pos, entityBox, collidingBoxes, BOUNDING_BOX); } @SuppressWarnings("deprecation") public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } @Override @SuppressWarnings("deprecation") public boolean isFullCube(IBlockState state){ return false; } @Override @SuppressWarnings("deprecation") public boolean isOpaqueCube(IBlockState state){ return false; } @Override public BlockRenderLayer getBlockLayer(){ return BlockRenderLayer.CUTOUT; } @Override protected BlockStateContainer createBlockState(){ return new BlockStateContainer(this, FACING); } @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { worldIn.setBlockState(pos, this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite())); super.onBlockPlacedBy(worldIn, pos, state, placer, stack); } @Override @SuppressWarnings("deprecation") public IBlockState getStateFromMeta(int meta){ EnumFacing enumFacing = EnumFacing.getFront(meta); if (enumFacing.getAxis() == EnumFacing.Axis.Y){ enumFacing = EnumFacing.NORTH; } return this.getDefaultState().withProperty(FACING, enumFacing); } @Override public int getMetaFromState(IBlockState state){ return (state.getValue(FACING)).getIndex(); } }