Dont crash if key is null
This commit is contained in:
@@ -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<WorldEngine> cachedEngineObject;
|
||||
|
||||
public WorldIdentifier(RegistryKey<World> key, long biomeSeed, @Nullable RegistryKey<DimensionType> dimension) {
|
||||
public WorldIdentifier(@NotNull RegistryKey<World> key, long biomeSeed, @Nullable RegistryKey<DimensionType> dimension) {
|
||||
if (key == null) {
|
||||
throw new IllegalStateException("Key cannot be null");
|
||||
}
|
||||
dimension = dimension==null?NULL_DIM_KEY:dimension;
|
||||
this.key = key;
|
||||
this.biomeSeed = biomeSeed;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user