shane020482

face rot

Jun 13th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. public class BlockFaceRotBase extends BlockBase implements IHasModel
  2. {
  3. public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
  4.  
  5. public BlockFaceRotBase(String name, Material material, float hardness, float resistance, String tool, int level, CreativeTabs tabs, SoundType sound)
  6. {
  7. super(tool, material, resistance, resistance, tool, level, tabs, sound);
  8.  
  9.  
  10. BlocksBrickInit.BLOCKS.add(this);
  11. BlockMetalInit.BLOCKS.add(this);
  12. ItemInit.ITEMS.add(new ItemBlock(this).setRegistryName(this.getRegistryName()));
  13.  
  14. this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
  15. }
  16.  
  17.  
  18. @Override
  19. public void registerModels()
  20. {
  21. CustomBlocks.proxy.registerItemRenderer(Item.getItemFromBlock(this), 0, "inventory");
  22.  
  23. }
  24.  
  25. @Override
  26. public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
  27. {
  28. IBlockState state = super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer);
  29. state = state.withProperty(FACING, placer.getHorizontalFacing().getOpposite());
  30. return state;
  31. }
  32.  
  33. @Override
  34. public IBlockState getStateFromMeta(int meta)
  35. { return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta)); }
  36.  
  37. @Override
  38. public int getMetaFromState(IBlockState state)
  39. { return ((EnumFacing) state.getValue(FACING)).getHorizontalIndex(); }
  40.  
  41. @Override
  42. protected BlockStateContainer createBlockState()
  43. { return new BlockStateContainer(this, new IProperty[] { FACING }); }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment