@@ -24,9 +24,11 @@ private static class BlockStateAccess3D implements BlockStateAccess {
2424 BlockStateAccess3D (DynmapBlockState bs []) {
2525 blocks = bs ;
2626 }
27+ @ Override
2728 public final DynmapBlockState getBlock (int x , int y , int z ) {
2829 return blocks [((y & 0xF ) << 8 ) | ((z & 0xF ) << 4 ) | (x & 0xF )];
2930 }
31+ @ Override
3032 public final DynmapBlockState getBlock (GenericChunkPos pos ) {
3133 return blocks [pos .soffset ];
3234 }
@@ -39,9 +41,11 @@ private static class BlockStateAccess3DPalette implements BlockStateAccess {
3941 blocks = blks ;
4042 palette = pal ;
4143 }
44+ @ Override
4245 public final DynmapBlockState getBlock (int x , int y , int z ) {
4346 return palette [blocks [((y & 0xF ) << 8 ) | ((z & 0xF ) << 4 ) | (x & 0xF )]];
4447 }
48+ @ Override
4549 public final DynmapBlockState getBlock (GenericChunkPos pos ) {
4650 return palette [blocks [pos .soffset ]];
4751 }
@@ -51,9 +55,11 @@ private static class BlockStateAccessSingle implements BlockStateAccess {
5155 BlockStateAccessSingle (DynmapBlockState bs ) {
5256 block = bs ;
5357 }
58+ @ Override
5459 public final DynmapBlockState getBlock (int x , int y , int z ) {
5560 return block ;
5661 }
62+ @ Override
5763 public final DynmapBlockState getBlock (GenericChunkPos pos ) {
5864 return block ;
5965 }
@@ -70,12 +76,15 @@ private static class BiomeAccess2D implements BiomeAccess {
7076 BiomeAccess2D (BiomeMap b []) {
7177 biomes = b ;
7278 }
79+ @ Override
7380 public final BiomeMap getBiome (int x , int y , int z ) {
7481 return biomes [((z & 0xF ) << 4 ) + (x & 0xF )];
7582 }
83+ @ Override
7684 public final BiomeMap getBiome (GenericChunkPos pos ) {
7785 return biomes [pos .soffset & 0xFF ]; // Just ZX portion
7886 }
87+ @ Override
7988 public String toString () {
8089 return String .format ("Biome2D(%s)" , Arrays .deepToString (biomes ));
8190 }
@@ -87,12 +96,15 @@ private static class BiomeAccess3D implements BiomeAccess {
8796 BiomeAccess3D (BiomeMap [] b ) {
8897 biomes = b ;
8998 }
99+ @ Override
90100 public final BiomeMap getBiome (int x , int y , int z ) {
91101 return biomes [ ((y & 0xC ) << 2 ) | (z & 0xC ) | ((x & 0xC ) >> 2 ) ];
92102 }
103+ @ Override
93104 public final BiomeMap getBiome (GenericChunkPos pos ) {
94105 return biomes [pos .sdiv4offset ];
95106 }
107+ @ Override
96108 public String toString () {
97109 return String .format ("Biome3D(%s)" , Arrays .deepToString (biomes ));
98110 }
@@ -103,12 +115,15 @@ private static class BiomeAccessSingle implements BiomeAccess {
103115 BiomeAccessSingle (BiomeMap b ) {
104116 biome = b ;
105117 }
118+ @ Override
106119 public final BiomeMap getBiome (int x , int y , int z ) {
107120 return biome ;
108121 }
122+ @ Override
109123 public final BiomeMap getBiome (GenericChunkPos pos ) {
110124 return biome ;
111125 }
126+ @ Override
112127 public String toString () {
113128 return String .format ("Biome1(%s)" , biome );
114129 }
@@ -130,9 +145,11 @@ private static class LightingAccess3D implements LightingAccess {
130145 }
131146 }
132147 }
148+ @ Override
133149 public final int getLight (int x , int y , int z ) {
134150 return 0xF & (int )(light [((y & 0xF ) << 4 ) | (z & 0xF )] >> ((x & 0xF ) << 2 ));
135151 }
152+ @ Override
136153 public final int getLight (GenericChunkPos pos ) {
137154 return 0xF & (int )(light [pos .soffset >> 4 ] >> (4 * pos .sx ));
138155 }
@@ -142,9 +159,11 @@ private static class LightingAccessSingle implements LightingAccess {
142159 LightingAccessSingle (int lig ) {
143160 light = lig & 0xF ;
144161 }
162+ @ Override
145163 public final int getLight (int x , int y , int z ) {
146164 return light ;
147165 }
166+ @ Override
148167 public final int getLight (GenericChunkPos pos ) {
149168 return light ;
150169 }
@@ -156,12 +175,13 @@ private GenericChunkSection(BlockStateAccess blks, BiomeAccess bio, LightingAcce
156175 emitted = emitac ;
157176 isEmpty = empty ;
158177 }
178+ @ Override
159179 public String toString () {
160180 return String .format ("sect(bip:%s)" , biomes );
161181 }
162- private static BiomeAccess defaultBiome = new BiomeAccessSingle (BiomeMap .NULL );
163- private static BlockStateAccess defaultBlockState = new BlockStateAccessSingle (DynmapBlockState .AIR );
164- private static LightingAccess defaultLight = new LightingAccessSingle (0 );
182+ private static final BiomeAccess defaultBiome = new BiomeAccessSingle (BiomeMap .NULL );
183+ private static final BlockStateAccess defaultBlockState = new BlockStateAccessSingle (DynmapBlockState .AIR );
184+ private static final LightingAccess defaultLight = new LightingAccessSingle (0 );
165185
166186 // Shared default empty section
167187 public static final GenericChunkSection EMPTY = new GenericChunkSection (defaultBlockState , defaultBiome , new LightingAccessSingle (15 ), defaultLight , true );
@@ -182,7 +202,7 @@ public Builder() {
182202 reset ();
183203 }
184204 // Reset builder to default state
185- public void reset () {
205+ public final void reset () {
186206 bsaccumsing = DynmapBlockState .AIR ;
187207 bsaccum = null ;
188208 baaccumsingle = BiomeMap .NULL ;
@@ -250,12 +270,16 @@ public Builder singleBlockState(DynmapBlockState block) {
250270 }
251271 // Set block state
252272 public Builder xyzBlockState (int x , int y , int z , DynmapBlockState block ) {
273+ return xyzBlockState (((y & 0xF ) << 8 ) + ((z & 0xF ) << 4 ) + (x & 0xF ), block );
274+ }
275+ // Set block state (yzx=nibble order Y<<8 | Z << 4 | X)
276+ public Builder xyzBlockState (int yzx , DynmapBlockState block ) {
253277 if (bsaccum == null ) {
254278 bsaccum = new DynmapBlockState [4096 ];
255279 Arrays .fill (bsaccum , DynmapBlockState .AIR );
256280 bsaccumsing = DynmapBlockState .AIR ;
257281 }
258- bsaccum [(( y & 0xF ) << 8 ) + (( z & 0xF ) << 4 ) + ( x & 0xF ) ] = block ;
282+ bsaccum [yzx ] = block ;
259283 empty = false ;
260284 return this ;
261285 }
@@ -269,10 +293,14 @@ public Builder xyzBlockStatePalette(DynmapBlockState[] bspalette) {
269293 }
270294 // Set block state using palette
271295 public Builder xyzBlockStateInPalette (int x , int y , int z , short palidx ) {
296+ return xyzBlockStateInPalette (((y & 0xF ) << 8 ) + ((z & 0xF ) << 4 ) + (x & 0xF ), palidx );
297+ }
298+ // Set block state using palette (yzx=nibble order Y<<8 | Z << 4 | X)
299+ public Builder xyzBlockStateInPalette (int yzx , short palidx ) {
272300 if (bsblks == null ) {
273301 bsblks = new short [4096 ];
274302 }
275- bsblks [(( y & 0xF ) << 8 ) + (( z & 0xF ) << 4 ) + ( x & 0xF ) ] = palidx ;
303+ bsblks [yzx ] = palidx ;
276304 empty = false ;
277305 return this ;
278306 }
@@ -293,8 +321,8 @@ public GenericChunkSection build() {
293321 if (bsaccum != null ) {
294322 DynmapBlockState v = bsaccum [0 ]; // Get first
295323 boolean mismatch = false ;
296- for (int i = 0 ; i < bsaccum . length ; i ++ ) {
297- if (bsaccum [ i ] != v ) {
324+ for (DynmapBlockState bsaccum1 : bsaccum ) {
325+ if (bsaccum1 != v ) {
298326 mismatch = true ;
299327 break ;
300328 }
@@ -333,8 +361,8 @@ else if (bsaccumsing == DynmapBlockState.AIR) { // Just air?
333361 if (baaccum != null ) {
334362 BiomeMap v = baaccum [0 ]; // Get first
335363 boolean mismatch = false ;
336- for (int i = 0 ; i < baaccum . length ; i ++ ) {
337- if (baaccum [ i ] != v ) {
364+ for (BiomeMap baaccum1 : baaccum ) {
365+ if (baaccum1 != v ) {
338366 mismatch = true ;
339367 break ;
340368 }
0 commit comments