Advertisement
Guest User

Untitled

a guest
Nov 8th, 2015
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. The point of this code is to render the block differently based on it's surrounding (namely rotate it).
  2. hasNextBlock checks if the block adiacent to the main one on the given direction (I do it for every direction in the horizontal plane)
  3. is an instance of itself. if it's any other kind of block, the boolean is true.
  4.  
  5. I can't try it yet cause I need to tweak the jsons and I'll probably have to ask about those as well, but is this a proper use of BlockPos?
  6.  
  7. public static final PropertyBool NORTH = PropertyBool.create("north")
  8. public static final PropertyBool SOUTH = PropertyBool.create("south")
  9. public static final PropertyBool EAST = PropertyBool.create("east")
  10. public static final PropertyBool WEST = PropertyBool.create("west")
  11.  
  12. public Boolean hasNextBlock(IBlockAccess worldIn, BlockPos pos) {
  13. Block b = worldIn.getBlockState(pos).getBlock();
  14. if(!(b.instanceof(BlockFountain)) { return true } else { return false }
  15. }
  16.  
  17. @Override
  18. public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
  19. return state.withProperty(NORTH, hasNextBlock(worldIn, pos.north())).withProperty(SOUTH, hasNextBlock(worldIn, pos.south())).withProperty(EAST, hasNextBlock(worldIn, pos.east())).withProperty(WEST, hasNextBlock(worldIn, pos.west()));
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement