Skip to content

Commit

Permalink
Ensure that world min and max height is always a multiple of 16
Browse files Browse the repository at this point in the history
  • Loading branch information
Barteks2x committed Dec 26, 2023
1 parent 929d75c commit e77d3f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,21 @@ public static void sync() {

private static void validateConfigValues() {
if (!VanillaCompatibilityGeneratorProviderBase.REGISTRY.containsKey(new ResourceLocation(compatibilityGeneratorType))) {
CubicChunks.LOGGER.error("Compatibility generator type {} doesn't exist, resetting config to default", compatibilityGeneratorType);
CubicChunks.LOGGER.error("CubicChunksConfig: Compatibility generator type {} doesn't exist, resetting config to default", compatibilityGeneratorType);
compatibilityGeneratorType = VanillaCompatibilityGeneratorProviderBase.DEFAULT.toString();
}
if (!storageFormat.isEmpty() && !StorageFormatProviderBase.REGISTRY.containsKey(new ResourceLocation(storageFormat))) {
CubicChunks.LOGGER.error("Storage format {} doesn't exist, resetting config to default", storageFormat);
CubicChunks.LOGGER.error("CubicChunksConfig: Storage format {} doesn't exist, resetting config to default", storageFormat);
storageFormat = "";
}
if ((defaultMinHeight & 0xF) != 0) {
CubicChunks.LOGGER.error("CubicChunksConfig: defaultMinHeight not a multiple of 16, got {}, setting to {}", defaultMinHeight, defaultMinHeight & ~0xF);
defaultMinHeight &= ~0xF;
}
if ((defaultMaxHeight & 0xF) != 0) {
CubicChunks.LOGGER.error("CubicChunksConfig: defaultMaxHeight not a multiple of 16, got {}, setting to {}", defaultMaxHeight, defaultMaxHeight & ~0xF);
defaultMaxHeight &= ~0xF;
}
}

private static void initDimensionRanges() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public WorldSavedCubicChunksData(String name, boolean isCC, int minHeight, int m

@Override
public void readFromNBT(NBTTagCompound nbt) {
minHeight = nbt.getInteger("minHeight");
maxHeight = nbt.getInteger("maxHeight");
minHeight = nbt.getInteger("minHeight") & ~0xF; // set 4 least significant bits to zero to ensure they are always multiples of 16
maxHeight = nbt.getInteger("maxHeight") & ~0xF;
isCubicChunks = !nbt.hasKey("isCubicChunks") || nbt.getBoolean("isCubicChunks");
if(nbt.hasKey("compatibilityGeneratorType"))
compatibilityGeneratorType = new ResourceLocation(nbt.getString("compatibilityGeneratorType"));
Expand Down

0 comments on commit e77d3f2

Please sign in to comment.