TitanChase

Untitled

Mar 11th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 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. }
  9.  
  10. public CoreTileEntityBlock(String Name)
  11. {
  12. super(Name);
  13. }
  14.  
  15. @Override
  16. public abstract TileEntity createTileEntity(World world, IBlockState state);
  17.  
  18. public <T extends CoreTileEntity> T GetTileEntity(IBlockAccess world, BlockPos pos)
  19. {
  20. return (T) world.getTileEntity(pos);
  21. }
  22.  
  23. @Override
  24. public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
  25. {
  26. world.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);
  27. }
  28.  
  29. @Override
  30. public IBlockState getStateFromMeta(int meta)
  31. {
  32. return getDefaultState().withProperty(FACING, EnumFacing.getFront((meta & 3) + 2));
  33. }
  34.  
  35. @Override
  36. public int getMetaFromState(IBlockState state)
  37. {
  38. return state.getValue(FACING).getIndex() - 2;
  39. }
  40.  
  41. @Override
  42. protected BlockStateContainer createBlockState()
  43. {
  44. return new BlockStateContainer(this, FACING);
  45. }
  46. }
Add Comment
Please, Sign In to add comment