Skip to content

Commit

Permalink
chore: update Minestom version & reader
Browse files Browse the repository at this point in the history
  • Loading branch information
mworzala committed Feb 28, 2024
1 parent 6610395 commit a356d62
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
metadata.format.version = "1.1"

[versions]
minestom = "7320437640"
minestom = "aad7bdab0f"
zstd = "1.5.5-3"
fastutil = "8.5.12"

Expand Down
14 changes: 8 additions & 6 deletions src/main/java/net/hollowcube/polar/PolarReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
import net.minestom.server.network.NetworkBuffer;
import net.minestom.server.utils.NamespaceID;
import net.minestom.server.utils.chunk.ChunkUtils;
import net.minestom.server.utils.validate.Check;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jglrxavpok.hephaistos.nbt.CompressedProcesser;
import org.jglrxavpok.hephaistos.nbt.NBT;
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
import org.jglrxavpok.hephaistos.nbt.NBTReader;

Expand All @@ -20,6 +18,10 @@
@SuppressWarnings("UnstableApiUsage")
public class PolarReader {
private static final boolean FORCE_LEGACY_NBT = Boolean.getBoolean("polar.debug.force-legacy-nbt");
private static final int MAX_BLOCK_ENTITIES = Integer.MAX_VALUE;
private static final int MAX_CHUNKS = Integer.MAX_VALUE;
private static final int MAX_BLOCK_PALETTE_SIZE = 16*16*16;
private static final int MAX_BIOME_PALETTE_SIZE = 8*8*8;

private PolarReader() {}

Expand Down Expand Up @@ -48,7 +50,7 @@ private PolarReader() {}
if (version > PolarWorld.VERSION_WORLD_USERDATA)
userData = buffer.read(BYTE_ARRAY);

var chunks = buffer.readCollection(b -> readChunk(version, b, maxSection - minSection + 1));
var chunks = buffer.readCollection(b -> readChunk(version, b, maxSection - minSection + 1), MAX_CHUNKS);

return new PolarWorld(version, compression, minSection, maxSection, userData, chunks);
}
Expand All @@ -62,7 +64,7 @@ private PolarReader() {}
sections[i] = readSection(version, buffer);
}

var blockEntities = buffer.readCollection(b -> readBlockEntity(version, b));
var blockEntities = buffer.readCollection(b -> readBlockEntity(version, b), MAX_BLOCK_ENTITIES);

var heightmaps = new byte[PolarChunk.HEIGHTMAP_BYTE_SIZE][PolarChunk.HEIGHTMAPS.length];
int heightmapMask = buffer.read(INT);
Expand Down Expand Up @@ -91,7 +93,7 @@ private PolarReader() {}
// If section is empty exit immediately
if (buffer.read(BOOLEAN)) return new PolarSection();

var blockPalette = buffer.readCollection(STRING).toArray(String[]::new);
var blockPalette = buffer.readCollection(STRING, MAX_BLOCK_PALETTE_SIZE).toArray(String[]::new);
if (version <= PolarWorld.VERSION_SHORT_GRASS) {
for (int i = 0; i < blockPalette.length; i++) {
String strippedID = blockPalette[i].split("\\[")[0];
Expand All @@ -108,7 +110,7 @@ private PolarReader() {}
PaletteUtil.unpack(blockData, rawBlockData, bitsPerEntry);
}

var biomePalette = buffer.readCollection(STRING).toArray(String[]::new);
var biomePalette = buffer.readCollection(STRING, MAX_BIOME_PALETTE_SIZE).toArray(String[]::new);
int[] biomeData = null;
if (biomePalette.length > 1) {
biomeData = new int[PolarSection.BIOME_PALETTE_SIZE];
Expand Down

0 comments on commit a356d62

Please sign in to comment.