Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. public class ThornCarpet extends BlockBase implements IHasModel{
  2. protected static final AxisAlignedBB CARPET_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.0625D, 1.0D);
  3.  
  4. public ThornCarpet(String name, Material material) {
  5. super(name, material);
  6. setSoundType(SoundType.CLOTH);
  7. setHardness(0.8F);
  8. setHarvestLevel("shears", 0);
  9. setLightOpacity(1);
  10.  
  11. }
  12.  
  13. public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
  14. {
  15. return CARPET_AABB;
  16. }
  17.  
  18. public boolean isOpaqueCube(IBlockState state)
  19. {
  20. return false;
  21. }
  22.  
  23. public boolean isFullCube(IBlockState state)
  24. {
  25. return false;
  26. }
  27.  
  28. public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
  29. {
  30. return super.canPlaceBlockAt(worldIn, pos) && this.canBlockStay(worldIn, pos);
  31. }
  32.  
  33. public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos)
  34. {
  35. this.checkForDrop(worldIn, pos, state);
  36. }
  37.  
  38. private boolean checkForDrop(World worldIn, BlockPos pos, IBlockState state)
  39. {
  40. if (!this.canBlockStay(worldIn, pos))
  41. {
  42. this.dropBlockAsItem(worldIn, pos, state, 0);
  43. worldIn.setBlockToAir(pos);
  44. return false;
  45. }
  46. else
  47. {
  48. return true;
  49. }
  50. }
  51.  
  52. private boolean canBlockStay(World worldIn, BlockPos pos)
  53. {
  54. return !worldIn.isAirBlock(pos.down());
  55. }
  56.  
  57. @SideOnly(Side.CLIENT)
  58. public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side)
  59. {
  60. if (side == EnumFacing.UP)
  61. {
  62. return true;
  63. }
  64. else
  65. {
  66. return blockAccess.getBlockState(pos.offset(side)).getBlock() == this ? true : super.shouldSideBeRendered(blockState, blockAccess, pos, side);
  67. }
  68. }
  69.  
  70. public void getSubBlocks(CreativeTabs itemIn, NonNullList<ItemStack> items)
  71. {
  72. for (int i = 0; i < 1; ++i)
  73. {
  74. items.add(new ItemStack(this, 1, i));
  75. }
  76. }
  77.  
  78. public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face)
  79. {
  80. return face == EnumFacing.DOWN ? BlockFaceShape.SOLID : BlockFaceShape.UNDEFINED;
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement