From befdd2c10a856e7c03292a293a86f86974333b3c Mon Sep 17 00:00:00 2001 From: paulevsGitch Date: Sun, 4 Jul 2021 02:02:34 +0300 Subject: [PATCH] Missing biome registry crash fix --- gradle.properties | 2 +- src/main/java/ru/bclib/api/BiomeAPI.java | 3 +++ src/main/java/ru/bclib/mixin/common/ServerLevelMixin.java | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 0c0d9645..d0cceeac 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ yarn_mappings=6 loader_version=0.11.3 # Mod Properties -mod_version = 0.1.44 +mod_version = 0.1.45 maven_group = ru.bclib archives_base_name = bclib diff --git a/src/main/java/ru/bclib/api/BiomeAPI.java b/src/main/java/ru/bclib/api/BiomeAPI.java index ef927ef8..0a1cb7b5 100644 --- a/src/main/java/ru/bclib/api/BiomeAPI.java +++ b/src/main/java/ru/bclib/api/BiomeAPI.java @@ -91,6 +91,9 @@ public class BiomeAPI { * @return {@link BCLBiome} or {@code BiomeAPI.EMPTY_BIOME}. */ public static BCLBiome getFromBiome(Biome biome) { + if (biomeRegistry == null) { + return EMPTY_BIOME; + } return ID_MAP.getOrDefault(biomeRegistry.getKey(biome), EMPTY_BIOME); } diff --git a/src/main/java/ru/bclib/mixin/common/ServerLevelMixin.java b/src/main/java/ru/bclib/mixin/common/ServerLevelMixin.java index bf0fa156..ef881e4d 100644 --- a/src/main/java/ru/bclib/mixin/common/ServerLevelMixin.java +++ b/src/main/java/ru/bclib/mixin/common/ServerLevelMixin.java @@ -22,6 +22,7 @@ import net.minecraft.world.level.dimension.DimensionType; import net.minecraft.world.level.storage.LevelStorageSource; import net.minecraft.world.level.storage.ServerLevelData; import net.minecraft.world.level.storage.WritableLevelData; +import ru.bclib.api.BiomeAPI; import ru.bclib.api.DataFixerAPI; import ru.bclib.api.WorldDataAPI; @@ -35,6 +36,8 @@ public abstract class ServerLevelMixin extends Level { @Inject(method = "*", at = @At("TAIL")) private void bcl_onServerWorldInit(MinecraftServer server, Executor workerExecutor, LevelStorageSource.LevelStorageAccess session, ServerLevelData properties, ResourceKey registryKey, DimensionType dimensionType, ChunkProgressListener worldGenerationProgressListener, ChunkGenerator chunkGenerator, boolean debugWorld, long l, List list, boolean bl, CallbackInfo info) { + BiomeAPI.initRegistry(server); + if (bcl_lastWorld != null && bcl_lastWorld.equals(session.getLevelId())) { return; }