diff --git a/src/main/java/ru/bclib/api/BiomeAPI.java b/src/main/java/ru/bclib/api/BiomeAPI.java index f4464e74..1e0de06a 100644 --- a/src/main/java/ru/bclib/api/BiomeAPI.java +++ b/src/main/java/ru/bclib/api/BiomeAPI.java @@ -1,6 +1,7 @@ package ru.bclib.api; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; @@ -497,7 +498,7 @@ public class BiomeAPI { public static void addBiomeMobSpawn(Biome biome, EntityType entityType, int weight, int minGroupCount, int maxGroupCount) { MobCategory category = entityType.getCategory(); SpawnSettingsAccessor accessor = (SpawnSettingsAccessor) biome.getMobSettings(); - Map> spawners = accessor.fabric_getSpawners(); + Map> spawners = getMutableMap(accessor.fabric_getSpawners()); List mobs = spawners.containsKey(category) ? getMutableList(spawners.get(category).unwrap()) : Lists.newArrayList(); mobs.add(new SpawnerData(entityType, weight, minGroupCount, maxGroupCount)); spawners.put(category, WeightedRandomList.create(mobs)); @@ -510,4 +511,11 @@ public class BiomeAPI { } return input; } + + private static Map getMutableMap(Map input) { + if (input instanceof ImmutableMap) { + return Maps.newHashMap(input); + } + return input; + } }