diff --git a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/PlatformImpl.java b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/PlatformImpl.java index a399b0a13..8beb238a1 100644 --- a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/PlatformImpl.java +++ b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/PlatformImpl.java @@ -62,16 +62,10 @@ public class PlatformImpl extends AbstractPlatform { private final WorldHandle worldHandle = new FabricWorldHandle(); private final Lazy dataFolder = Lazy.lazy(() -> new File(FabricLoader.getInstance().getConfigDir().toFile(), "Terra")); - private final Set worlds = new HashSet<>(); - public PlatformImpl() { load(); } - public void addWorld(ServerWorld world) { - worlds.add(world); - } - private MinecraftServer server; public void setServer(MinecraftServer server) { @@ -90,16 +84,15 @@ public class PlatformImpl extends AbstractPlatform { LOGGER.warn("Failed to execute reload", throwable); return null; }).join(); - } - - worlds.forEach(world -> { - FabricChunkGeneratorWrapper chunkGeneratorWrapper = ((FabricChunkGeneratorWrapper) world.getChunkManager().getChunkGenerator()); - getConfigRegistry().get(chunkGeneratorWrapper.getPack().getRegistryKey()).ifPresent(pack -> { - chunkGeneratorWrapper.setPack(pack); - LOGGER.info("Replaced pack in chunk generator for world {}", world); + server.getWorlds().forEach(world -> { + if(world.getChunkManager().getChunkGenerator() instanceof FabricChunkGeneratorWrapper chunkGeneratorWrapper) { + getConfigRegistry().get(chunkGeneratorWrapper.getPack().getRegistryKey()).ifPresent(pack -> { + chunkGeneratorWrapper.setPack(pack); + LOGGER.info("Replaced pack in chunk generator for world {}", world); + }); + } }); - }); - + } return succeed; } diff --git a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/ServerWorldMixin.java b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/ServerWorldMixin.java deleted file mode 100644 index e1161feda..000000000 --- a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/mixin/ServerWorldMixin.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This file is part of Terra. - * - * Terra is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Terra is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Terra. If not, see . - */ - -package com.dfsek.terra.fabric.mixin; - -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.WorldGenerationProgressListener; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.registry.RegistryEntry; -import net.minecraft.util.registry.RegistryKey; -import net.minecraft.world.World; -import net.minecraft.world.dimension.DimensionType; -import net.minecraft.world.gen.chunk.ChunkGenerator; -import net.minecraft.world.level.ServerWorldProperties; -import net.minecraft.world.level.storage.LevelStorage; -import net.minecraft.world.spawner.Spawner; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -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.CallbackInfo; - -import java.util.List; -import java.util.concurrent.Executor; - -import com.dfsek.terra.fabric.FabricEntryPoint; -import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper; - - -@Mixin(ServerWorld.class) -public abstract class ServerWorldMixin { - private static final Logger logger = LoggerFactory.getLogger(ServerWorld.class); - - @Inject(method = "", at = @At("RETURN")) - public void injectConstructor(MinecraftServer server, Executor workerExecutor, LevelStorage.Session session, - ServerWorldProperties properties, RegistryKey worldKey, RegistryEntry registryEntry, - WorldGenerationProgressListener worldGenerationProgressListener, ChunkGenerator chunkGenerator, - boolean debugWorld, long seed, List spawners, boolean shouldTickTime, CallbackInfo ci) { - if(chunkGenerator instanceof FabricChunkGeneratorWrapper) { - FabricEntryPoint.getPlatform().addWorld((ServerWorld) (Object) this); - logger.info("Registered world {}", this); - } - } -} diff --git a/platforms/fabric/src/main/resources/terra.mixins.json b/platforms/fabric/src/main/resources/terra.mixins.json index 5487f4406..4b0d3cd85 100644 --- a/platforms/fabric/src/main/resources/terra.mixins.json +++ b/platforms/fabric/src/main/resources/terra.mixins.json @@ -4,7 +4,6 @@ "package": "com.dfsek.terra.fabric.mixin", "compatibilityLevel": "JAVA_16", "mixins": [ - "ServerWorldMixin", "access.BiomeEffectsAccessor", "access.MobSpawnerLogicAccessor", "access.StateAccessor",