Skip to content

Commit

Permalink
Add extra checks for sections with a single block
Browse files Browse the repository at this point in the history
Use Arrays.fill instead of for loops
  • Loading branch information
mmdanggg2 committed Jul 10, 2024
1 parent d1f925a commit 67973d4
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/org/jmc/Chunk.java
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ boolean fillBlocks(TAG_Compound section) {
// palette is null, section must be empty
return false;
}
if (tagBlockStates == null) {
if (tagBlockPalette.elements.length == 1 || tagBlockStates == null || tagBlockStates.data.length <= 1) {
if (tagBlockPalette.elements.length >= 1) {
// no state list but a palette indicates the whole section is filled with a single block
TAG_Compound blockTag = (TAG_Compound)tagBlockPalette.elements[0];
Expand All @@ -489,9 +489,7 @@ boolean fillBlocks(TAG_Compound section) {
}

BlockData block = new BlockData(NamespaceID.fromString(blockName));
for (int i = 0; i < 4096; i++) {
data[i] = block;
}
Arrays.fill(data, block);
return true;
}
return false;
Expand Down Expand Up @@ -555,9 +553,7 @@ boolean fillBiomes(TAG_Compound section) {
if (tagBiomePalette.elements.length >= 1) {
String biomeName = ((TAG_String) tagBiomePalette.elements[0]).value;
NamespaceID biome = NamespaceID.fromString(biomeName);
for (int i = 0; i < 4096; i++) {
biomes[i] = biome;
}
Arrays.fill(biomes, biome);
return true;
}
return false;
Expand Down

0 comments on commit 67973d4

Please sign in to comment.