From bf8368b5153edbb20edfaa0078db101fba59e57b Mon Sep 17 00:00:00 2001 From: Frank Date: Mon, 29 Nov 2021 17:47:50 +0100 Subject: [PATCH] Revert "New API to hook into level loading" This reverts commit a489655ddd914043a3ca32b412654d9171a6d5a3. --- src/main/java/ru/bclib/api/LifeCycleAPI.java | 121 ------------------ .../bclib/mixin/common/ServerLevelMixin.java | 4 - 2 files changed, 125 deletions(-) delete mode 100644 src/main/java/ru/bclib/api/LifeCycleAPI.java diff --git a/src/main/java/ru/bclib/api/LifeCycleAPI.java b/src/main/java/ru/bclib/api/LifeCycleAPI.java deleted file mode 100644 index 802853dc..00000000 --- a/src/main/java/ru/bclib/api/LifeCycleAPI.java +++ /dev/null @@ -1,121 +0,0 @@ -package ru.bclib.api; - -import net.minecraft.core.Registry; -import net.minecraft.resources.ResourceKey; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.progress.ChunkProgressListener; -import net.minecraft.world.level.CustomSpawner; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.biome.Biome; -import net.minecraft.world.level.chunk.ChunkGenerator; -import net.minecraft.world.level.dimension.DimensionType; -import net.minecraft.world.level.storage.LevelStorageSource; -import net.minecraft.world.level.storage.LevelStorageSource.LevelStorageAccess; -import net.minecraft.world.level.storage.ServerLevelData; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.Executor; - -/** - * provides some lifetime hooks for a Minecraft instance - */ -public class LifeCycleAPI { - private final static List onLoadLevelBiomes = new ArrayList<>(2); - private final static List onLoadLevel = new ArrayList<>(2); - - /** - * A callback function that is used for each new ServerLevel instance - */ - public interface LevelLoadBiomesCall { - void onLoad(ServerLevel world, long seed, Registry registry); - } - - /** - * A callback function that is used for each new ServerLevel instance - */ - public interface LevelLoadCall { - void onLoad( - ServerLevel world, - MinecraftServer minecraftServer, - Executor executor, - LevelStorageSource.LevelStorageAccess levelStorageAccess, - ServerLevelData serverLevelData, - ResourceKey resourceKey, - DimensionType dimensionType, - ChunkProgressListener chunkProgressListener, - ChunkGenerator chunkGenerator, - boolean bl, - long l, - List list, - boolean bl2); - } - - /** - * Register a callback that is called when a new {@code ServerLevel is instantiated}. - * This callback will receive the world seed as well as it's biome registry. - * @param call The calbback Method - */ - public static void onLevelLoad(LevelLoadBiomesCall call){ - onLoadLevelBiomes.add(call); - } - - /** - * Register a callback that is called when a new {@code ServerLevel is instantiated}. - * This callbacl will receiv all parameters that were passed to the ServerLevel's constructor - * @param call The calbback Method - */ - public static void onLevelLoad(LevelLoadCall call){ - onLoadLevel.add(call); - } - - /** - * For internal use, You should not call this method! - * @param minecraftServer - * @param executor - * @param levelStorageAccess - * @param serverLevelData - * @param resourceKey - * @param dimensionType - * @param chunkProgressListener - * @param chunkGenerator - * @param bl - * @param l - * @param list - * @param bl2 - */ - public static void _onLevelLoad(ServerLevel world, - MinecraftServer minecraftServer, - Executor executor, - LevelStorageSource.LevelStorageAccess levelStorageAccess, - ServerLevelData serverLevelData, - ResourceKey resourceKey, - DimensionType dimensionType, - ChunkProgressListener chunkProgressListener, - ChunkGenerator chunkGenerator, - boolean bl, - long l, - List list, - boolean bl2){ - onLoadLevel.forEach(c -> c.onLoad( - world, - minecraftServer, - executor, - levelStorageAccess, - serverLevelData, - resourceKey, - dimensionType, - chunkProgressListener, - chunkGenerator, - bl, - l, - list, - bl2) - ); - - final long seed = world.getSeed(); - final Registry biomeRegistry = world.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY); - onLoadLevelBiomes.forEach(c -> c.onLoad(world, seed, biomeRegistry)); - } -} diff --git a/src/main/java/ru/bclib/mixin/common/ServerLevelMixin.java b/src/main/java/ru/bclib/mixin/common/ServerLevelMixin.java index 232e3c0f..8de68864 100644 --- a/src/main/java/ru/bclib/mixin/common/ServerLevelMixin.java +++ b/src/main/java/ru/bclib/mixin/common/ServerLevelMixin.java @@ -17,7 +17,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import ru.bclib.api.BiomeAPI; -import ru.bclib.api.LifeCycleAPI; import java.util.List; import java.util.concurrent.Executor; @@ -41,8 +40,5 @@ private void bclib_onServerWorldInit(MinecraftServer server, Executor workerExec } bclib_lastWorld = session.getLevelId(); - - ServerLevel world = ServerLevel.class.cast(this); - LifeCycleAPI._onLevelLoad(world, server, workerExecutor, session, properties, registryKey, dimensionType, worldGenerationProgressListener, chunkGenerator, debugWorld, l, list, bl); } }