Biome registry init changes

This commit is contained in:
paulevsGitch 2021-12-03 14:26:12 +03:00
parent db07cd1887
commit 14451494ff
7 changed files with 26 additions and 4 deletions

View file

@ -86,8 +86,8 @@ public class BiomeAPI {
*
* @param server - {@link MinecraftServer}
*/
public static void initRegistry(MinecraftServer server) {
biomeRegistry = server.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY);
public static void initRegistry( Registry<Biome> biomeRegistry) {
BiomeAPI.biomeRegistry = biomeRegistry;
CLIENT.clear();
}

View file

@ -56,7 +56,7 @@ public class MinecraftServerMixin {
@Inject(method = "loadLevel", at = @At(value = "RETURN"), cancellable = true)
private void bclib_loadLevel(CallbackInfo info) {
bclib_injectRecipes();
BiomeAPI.initRegistry(MinecraftServer.class.cast(this));
//BiomeAPI.initRegistry(MinecraftServer.class.cast(this));
}
private void bclib_injectRecipes() {

View file

@ -38,7 +38,7 @@ public abstract class ServerLevelMixin extends Level {
ServerLevel world = ServerLevel.class.cast(this);
LifeCycleAPI._runLevelLoad(world, server, executor, levelStorageAccess, serverLevelData, resourceKey, dimensionType, chunkProgressListener, chunkGenerator, bl, l, list, bl2);
BiomeAPI.initRegistry(server);
//BiomeAPI.initRegistry(server);
BiomeAPI.applyModifications(ServerLevel.class.cast(this));
if (bclib_lastWorld != null && bclib_lastWorld.equals(levelStorageAccess.getLevelId())) {

View file

@ -0,0 +1,19 @@
package ru.bclib.mixin.common;
import net.minecraft.client.gui.screens.worldselection.WorldPreset;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
import net.minecraft.world.level.levelgen.WorldGenSettings;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import ru.bclib.api.biomes.BiomeAPI;
@Mixin(WorldPreset.class)
public class WorldPresetMixin {
@Inject(method = "create", at = @At("HEAD"))
private void create(RegistryAccess.RegistryHolder registryHolder, long l, boolean bl, boolean bl2, CallbackInfoReturnable<WorldGenSettings> info) {
BiomeAPI.initRegistry(registryHolder.registryOrThrow(Registry.BIOME_REGISTRY));
}
}

View file

@ -50,6 +50,7 @@ public class BCLibEndBiomeSource extends BiomeSource {
public BCLibEndBiomeSource(Registry<Biome> biomeRegistry, long seed) {
super(getBiomes(biomeRegistry));
BiomeAPI.initRegistry(biomeRegistry);
BiomeAPI.END_LAND_BIOME_PICKER.clearMutables();
BiomeAPI.END_VOID_BIOME_PICKER.clearMutables();

View file

@ -52,6 +52,7 @@ public class BCLibNetherBiomeSource extends BiomeSource {
public BCLibNetherBiomeSource(Registry<Biome> biomeRegistry, long seed) {
super(getBiomes(biomeRegistry));
BiomeAPI.initRegistry(biomeRegistry);
BiomeAPI.NETHER_BIOME_PICKER.clearMutables();
this.possibleBiomes().forEach(biome -> {

View file

@ -30,6 +30,7 @@
"shears.SheepMixin",
"PortalShapeMixin",
"ServerLevelMixin",
"WorldPresetMixin",
"AnvilBlockMixin",
"AnvilMenuMixin",
"TagLoaderMixin",