From 63a969e5dfd9dfb93f94561c34932597f4305570 Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Wed, 27 Aug 2025 17:30:32 +1000 Subject: [PATCH] Dont crash if key is null --- .../java/me/cortex/voxy/commonImpl/WorldIdentifier.java | 6 +++++- .../cortex/voxy/commonImpl/mixin/minecraft/MixinWorld.java | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/cortex/voxy/commonImpl/WorldIdentifier.java b/src/main/java/me/cortex/voxy/commonImpl/WorldIdentifier.java index 69650d9a..6640aaeb 100644 --- a/src/main/java/me/cortex/voxy/commonImpl/WorldIdentifier.java +++ b/src/main/java/me/cortex/voxy/commonImpl/WorldIdentifier.java @@ -6,6 +6,7 @@ import net.minecraft.registry.RegistryKeys; import net.minecraft.util.Identifier; import net.minecraft.world.World; import net.minecraft.world.dimension.DimensionType; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.lang.ref.WeakReference; @@ -21,7 +22,10 @@ public class WorldIdentifier { private final transient long hashCode; @Nullable transient WeakReference cachedEngineObject; - public WorldIdentifier(RegistryKey key, long biomeSeed, @Nullable RegistryKey dimension) { + public WorldIdentifier(@NotNull RegistryKey key, long biomeSeed, @Nullable RegistryKey dimension) { + if (key == null) { + throw new IllegalStateException("Key cannot be null"); + } dimension = dimension==null?NULL_DIM_KEY:dimension; this.key = key; this.biomeSeed = biomeSeed; diff --git a/src/main/java/me/cortex/voxy/commonImpl/mixin/minecraft/MixinWorld.java b/src/main/java/me/cortex/voxy/commonImpl/mixin/minecraft/MixinWorld.java index 885615f1..67b4c628 100644 --- a/src/main/java/me/cortex/voxy/commonImpl/mixin/minecraft/MixinWorld.java +++ b/src/main/java/me/cortex/voxy/commonImpl/mixin/minecraft/MixinWorld.java @@ -29,7 +29,11 @@ public class MixinWorld implements IWorldGetIdentifier { long seed, int maxChainedNeighborUpdates, CallbackInfo ci) { - this.identifier = new WorldIdentifier(key, seed, dimensionEntry.getKey().orElse(null)); + if (key != null) { + this.identifier = new WorldIdentifier(key, seed, dimensionEntry == null?null:dimensionEntry.getKey().orElse(null)); + } else { + this.identifier = null; + } } @Override