Skip to content

Commit 67973d4

Browse files
committed
Add extra checks for sections with a single block
Use Arrays.fill instead of for loops
1 parent d1f925a commit 67973d4

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

Diff for: src/org/jmc/Chunk.java

+3-7
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ boolean fillBlocks(TAG_Compound section) {
478478
// palette is null, section must be empty
479479
return false;
480480
}
481-
if (tagBlockStates == null) {
481+
if (tagBlockPalette.elements.length == 1 || tagBlockStates == null || tagBlockStates.data.length <= 1) {
482482
if (tagBlockPalette.elements.length >= 1) {
483483
// no state list but a palette indicates the whole section is filled with a single block
484484
TAG_Compound blockTag = (TAG_Compound)tagBlockPalette.elements[0];
@@ -489,9 +489,7 @@ boolean fillBlocks(TAG_Compound section) {
489489
}
490490

491491
BlockData block = new BlockData(NamespaceID.fromString(blockName));
492-
for (int i = 0; i < 4096; i++) {
493-
data[i] = block;
494-
}
492+
Arrays.fill(data, block);
495493
return true;
496494
}
497495
return false;
@@ -555,9 +553,7 @@ boolean fillBiomes(TAG_Compound section) {
555553
if (tagBiomePalette.elements.length >= 1) {
556554
String biomeName = ((TAG_String) tagBiomePalette.elements[0]).value;
557555
NamespaceID biome = NamespaceID.fromString(biomeName);
558-
for (int i = 0; i < 4096; i++) {
559-
biomes[i] = biome;
560-
}
556+
Arrays.fill(biomes, biome);
561557
return true;
562558
}
563559
return false;

0 commit comments

Comments
 (0)