Missing biome registry crash fix

This commit is contained in:
paulevsGitch 2021-07-04 02:02:34 +03:00
parent 64c27a10b7
commit befdd2c10a
3 changed files with 7 additions and 1 deletions

View file

@ -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

View file

@ -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);
}

View file

@ -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 = "<init>*", at = @At("TAIL"))
private void bcl_onServerWorldInit(MinecraftServer server, Executor workerExecutor, LevelStorageSource.LevelStorageAccess session, ServerLevelData properties, ResourceKey<Level> registryKey, DimensionType dimensionType, ChunkProgressListener worldGenerationProgressListener, ChunkGenerator chunkGenerator, boolean debugWorld, long l, List<CustomSpawner> list, boolean bl, CallbackInfo info) {
BiomeAPI.initRegistry(server);
if (bcl_lastWorld != null && bcl_lastWorld.equals(session.getLevelId())) {
return;
}