Show proper error when trying to load chunk with y range outside of dimension type

Change defaults of DimensionType to match vanilla y range of overworld
This commit is contained in:
jglrxavpok 2022-01-09 15:50:43 +01:00 committed by TheMode
parent 379ca22903
commit 98152a821d
2 changed files with 21 additions and 3 deletions

View File

@ -88,6 +88,23 @@ public class AnvilLoader implements IChunkLoader {
return CompletableFuture.completedFuture(null);
Chunk chunk = new DynamicChunk(instance, chunkX, chunkZ);
if(fileChunk.getMinY() < instance.getDimensionType().getMinY()) {
throw new AnvilException(
String.format("Trying to load chunk with minY = %d, but instance dimension type (%s) has a minY of %d",
fileChunk.getMinY(),
instance.getDimensionType().getName().asString(),
instance.getDimensionType().getMinY()
));
}
if(fileChunk.getMaxY() > instance.getDimensionType().getMaxY()) {
throw new AnvilException(
String.format("Trying to load chunk with maxY = %d, but instance dimension type (%s) has a maxY of %d",
fileChunk.getMaxY(),
instance.getDimensionType().getName().asString(),
instance.getDimensionType().getMaxY()
));
}
// TODO: Parallelize block, block entities and biome loading
if (fileChunk.getGenerationStatus().compareTo(ChunkColumn.GenerationStatus.Biomes) > 0) {

View File

@ -3,6 +3,7 @@ package net.minestom.server.world;
import net.minestom.server.utils.NamespaceID;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jglrxavpok.hephaistos.mcdata.SizesKt;
import org.jglrxavpok.hephaistos.nbt.NBT;
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
@ -258,9 +259,9 @@ public class DimensionType {
private boolean bedSafe = true;
private String effects = "minecraft:overworld";
private boolean piglinSafe = false;
private int minY = 0;
private int logicalHeight = 256;
private int height = 256;
private int minY = SizesKt.getVanillaMinY();
private int logicalHeight = SizesKt.getVanillaMaxY() - SizesKt.getVanillaMinY() + 1;
private int height = SizesKt.getVanillaMaxY() - SizesKt.getVanillaMinY() + 1;
private int coordinateScale = 1;
private NamespaceID infiniburn = NamespaceID.from("minecraft:infiniburn_overworld");