SHARE
TWEET

Bounding box rotate with placing block?

SirDizarm Jul 19th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.sirdizarm.treasuremod.objects.blocks;
  2.  
  3. import com.sirdizarm.treasuremod.Main;
  4. import com.sirdizarm.treasuremod.init.BlockInit;
  5. import com.sirdizarm.treasuremod.init.ItemInit;
  6. import com.sirdizarm.treasuremod.util.interfaces.IHasModel;
  7.  
  8. import net.minecraft.block.BlockHorizontal;
  9. import net.minecraft.block.material.Material;
  10. import net.minecraft.block.properties.IProperty;
  11. import net.minecraft.block.properties.PropertyDirection;
  12. import net.minecraft.block.state.BlockStateContainer;
  13. import net.minecraft.block.state.IBlockState;
  14. import net.minecraft.entity.EntityLivingBase;
  15. import net.minecraft.item.Item;
  16. import net.minecraft.item.ItemBlock;
  17. import net.minecraft.util.EnumFacing;
  18. import net.minecraft.util.EnumHand;
  19. import net.minecraft.util.math.AxisAlignedBB;
  20. import net.minecraft.util.math.BlockPos;
  21. import net.minecraft.world.IBlockAccess;
  22. import net.minecraft.world.World;
  23.  
  24. public class DeadBirds extends BlockHorizontal implements IHasModel {
  25.     private static final AxisAlignedBB PATH_AABB = new AxisAlignedBB(0.15, 0.0, 0.2, 1.0, 0.35, 0.65);    // L-R, U-D, F-B,
  26.  
  27. public DeadBirds(String name, Material material) {
  28.     super(material);
  29. //  setSoundType(SoundType);
  30. //  setBlockUnbreakable();
  31.     setLightOpacity(0);
  32.     setCreativeTab(Main.treasuremod);
  33.     setUnlocalizedName(name);
  34.     setRegistryName(name);
  35.     setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
  36.  
  37.     BlockInit.BLOCKS.add(this);
  38.     ItemInit.ITEMS.add(new ItemBlock(this).setRegistryName(this.getRegistryName()));
  39. }
  40.  
  41. public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
  42.  
  43. @Override
  44. protected BlockStateContainer createBlockState() {
  45.     return new BlockStateContainer(this, new IProperty[] { FACING });
  46. }
  47.  
  48. //use existing getMetaFromState
  49. @Override
  50. public IBlockState getStateFromMeta(int meta)
  51. {
  52.   return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta));
  53. }
  54. @Override
  55. public int getMetaFromState(IBlockState state) {
  56.     EnumFacing facing = (EnumFacing) state.getValue(FACING);
  57.     return facing.getHorizontalIndex();
  58. }
  59.  
  60. @Override
  61. public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY,
  62.     float hitZ, int meta, EntityLivingBase placer, EnumHand hand) {
  63. return super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer, hand).withProperty(FACING, placer.getHorizontalFacing());
  64. //.getOpposite()
  65. }
  66.  
  67. public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
  68. {
  69.     return PATH_AABB;
  70. }
  71.  
  72.  
  73. @Override
  74. public void registerModels() {
  75.     Main.proxy.registerItemRenderer(Item.getItemFromBlock(this), 0, "inventory");
  76. }
  77.  
  78.  
  79. @Override
  80. public boolean isOpaqueCube(IBlockState state) {
  81.         return false;
  82.     }
  83.  
  84. @Override
  85.     public boolean isFullCube(IBlockState state) {
  86.         return false;
  87.     }
  88.  
  89. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top