Use new lifetime hook for level loading
This commit is contained in:
parent
ae615748b3
commit
c90540c33e
2 changed files with 19 additions and 25 deletions
|
@ -1,21 +1,16 @@
|
|||
package ru.betterend.mixin.common;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.progress.ChunkProgressListener;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.world.level.CustomSpawner;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
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.ServerLevelData;
|
||||
import net.minecraft.world.level.storage.WritableLevelData;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
@ -25,32 +20,27 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import ru.bclib.api.BiomeAPI;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.registry.EndBiomes;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.world.generator.GeneratorOptions;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Mixin(ServerLevel.class)
|
||||
public abstract class ServerLevelMixin extends Level {
|
||||
private static String be_lastWorld = null;
|
||||
// private static String be_lastWorld = null;
|
||||
|
||||
protected ServerLevelMixin(WritableLevelData writableLevelData, ResourceKey<Level> resourceKey, DimensionType dimensionType, Supplier<ProfilerFiller> supplier, boolean bl, boolean bl2, long l) {
|
||||
super(writableLevelData, resourceKey, dimensionType, supplier, bl, bl2, l);
|
||||
}
|
||||
|
||||
@Inject(method = "<init>*", at = @At("TAIL"))
|
||||
private void be_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) {
|
||||
if (be_lastWorld != null && be_lastWorld.equals(session.getLevelId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
be_lastWorld = session.getLevelId();
|
||||
ServerLevel world = ServerLevel.class.cast(this);
|
||||
EndBiomes.onWorldLoad(world.getSeed(), world.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY));
|
||||
}
|
||||
// @Inject(method = "<init>*", at = @At("TAIL"))
|
||||
// private void be_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) {
|
||||
//// if (be_lastWorld != null && be_lastWorld.equals(session.getLevelId())) {
|
||||
//// return;
|
||||
//// }
|
||||
////
|
||||
//// be_lastWorld = session.getLevelId();
|
||||
// ServerLevel level = ServerLevel.class.cast(this);
|
||||
// EndBiomes.onWorldLoad(level, level.getSeed(), level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY));
|
||||
// }
|
||||
|
||||
@Inject(method = "getSharedSpawnPos", at = @At("HEAD"), cancellable = true)
|
||||
private void be_getSharedSpawnPos(CallbackInfoReturnable<BlockPos> info) {
|
||||
|
|
|
@ -2,8 +2,10 @@ package ru.betterend.registry;
|
|||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import ru.bclib.api.BiomeAPI;
|
||||
import ru.bclib.api.LifeCycleAPI;
|
||||
import ru.bclib.world.biomes.BCLBiome;
|
||||
import ru.bclib.world.generator.BiomeMap;
|
||||
import ru.bclib.world.generator.BiomePicker;
|
||||
|
@ -74,9 +76,11 @@ public class EndBiomes {
|
|||
public static final EndCaveBiome LUSH_AURORA_CAVE = registerCaveBiome(new LushAuroraCaveBiome());
|
||||
public static final EndCaveBiome JADE_CAVE = registerCaveBiome(new JadeCaveBiome());
|
||||
|
||||
public static void register() {}
|
||||
public static void register() {
|
||||
LifeCycleAPI.onLevelLoad(EndBiomes::onWorldLoad);
|
||||
}
|
||||
|
||||
public static void onWorldLoad(long seed, Registry<Biome> registry) {
|
||||
private static void onWorldLoad(ServerLevel level, long seed, Registry<Biome> registry) {
|
||||
CAVE_BIOMES.getBiomes().forEach(biome -> biome.updateActualBiomes(registry));
|
||||
CAVE_BIOMES.rebuild();
|
||||
if (caveBiomeMap == null || caveBiomeMap.getSeed() != seed) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue