Advertisement
TitanChase

Untitled

Mar 11th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. public abstract class CoreTileEntityBlock extends CoreBlock
  2. {
  3. public static final PropertyDirection FACING = PropertyDirection.create(Names.NBT.Direction, EnumFacing.Plane.HORIZONTAL);
  4.  
  5. public CoreTileEntityBlock(Material material, String Name)
  6. {
  7. super(material, Name);
  8. this.setDefaultState(this.blockState.getBaseState());
  9. }
  10.  
  11. public CoreTileEntityBlock(String Name)
  12. {
  13. super(Name);
  14. this.setDefaultState(this.blockState.getBaseState());
  15. }
  16.  
  17. @Override
  18. public abstract TileEntity createTileEntity(World world, IBlockState state);
  19.  
  20. public <T extends CoreTileEntity> T GetTileEntity(IBlockAccess world, BlockPos pos)
  21. {
  22. return (T) world.getTileEntity(pos);
  23. }
  24.  
  25. @Override
  26. public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
  27. {
  28. world.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);
  29. }
  30.  
  31. @Override
  32. public IBlockState getStateFromMeta(int meta)
  33. {
  34. return getDefaultState().withProperty(FACING, EnumFacing.getFront((meta & 3) + 2));
  35. }
  36.  
  37. @Override
  38. public int getMetaFromState(IBlockState state)
  39. {
  40. return state.getValue(FACING).getIndex() - 2;
  41. }
  42.  
  43. @Override
  44. protected BlockStateContainer createBlockState()
  45. {
  46. return new BlockStateContainer(this, FACING);
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement