Advertisement
Barteks2x

Untitled

Oct 11th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.13 KB | None | 0 0
  1.     public Cube(Chunk column, int cubeY, CubePrimer primer) {
  2.         this(column, cubeY);
  3.  
  4.         int miny = cubeToMinBlock(cubeY);
  5.         IHeightMap opindex = ((IColumn) column).getOpacityIndex();
  6.  
  7.         for (int x = 0; x < Cube.SIZE; x++) {
  8.             for (int z = 0; z < Cube.SIZE; z++) {
  9.  
  10.                 for (int y = Cube.SIZE - 1; y >= 0; y--) {
  11.                     IBlockState newstate = primer.getBlockState(x, y, z);
  12.  
  13.                     if (newstate.getMaterial() != Material.AIR) {
  14.                         if (storage == NULL_STORAGE) {
  15.                             newStorage();
  16.                         }
  17.                         storage.set(x, y, z, newstate);
  18.  
  19.                         //int opacity = newstate.getLightOpacity();
  20.                         //if (false || opacity != 0) {
  21.                         //    column.setModified(true); //TODO: this is a bit of am abstraction leak... maybe ServerHeightMap needs its own isModified
  22.                         //    opindex.onOpacityChange(x, miny | y, z, opacity);
  23.                         //}
  24.                     }
  25.                 }
  26.             }
  27.         }
  28.         isSurfaceTracked = true;
  29.         isModified = true;
  30.     }
  31.  
  32.     private void newStorage() {
  33.         storage = new ExtendedBlockStorage(cubeToMinBlock(getY()), world.provider.hasSkyLight());
  34.     }
  35.  
  36. CubePrimer:
  37.  
  38. public class CubePrimer {
  39.     public static final IBlockState DEFAULT_STATE = Blocks.AIR.getDefaultState();
  40.  
  41.     private final char[] data = new char[4096];
  42.  
  43.     public IBlockState getBlockState(int x, int y, int z) {
  44.         @SuppressWarnings("deprecation")
  45.         IBlockState iblockstate = Block.BLOCK_STATE_IDS.getByValue(this.data[getBlockIndex(x, y, z)]);
  46.         return iblockstate == null ? DEFAULT_STATE : iblockstate;
  47.     }
  48.  
  49.     public void setBlockState(int x, int y, int z, @Nonnull IBlockState state) {
  50.         @SuppressWarnings("deprecation")
  51.         char value = (char) Block.BLOCK_STATE_IDS.get(state);
  52.         this.data[getBlockIndex(x, y, z)] = value;
  53.     }
  54.  
  55.     private static int getBlockIndex(int x, int y, int z) {
  56.         return x << 8 | z << 4 | y;
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement