mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-18 14:50:56 +00:00
remove static world registration
This commit is contained in:
@@ -62,16 +62,10 @@ public class PlatformImpl extends AbstractPlatform {
|
|||||||
private final WorldHandle worldHandle = new FabricWorldHandle();
|
private final WorldHandle worldHandle = new FabricWorldHandle();
|
||||||
private final Lazy<File> dataFolder = Lazy.lazy(() -> new File(FabricLoader.getInstance().getConfigDir().toFile(), "Terra"));
|
private final Lazy<File> dataFolder = Lazy.lazy(() -> new File(FabricLoader.getInstance().getConfigDir().toFile(), "Terra"));
|
||||||
|
|
||||||
private final Set<ServerWorld> worlds = new HashSet<>();
|
|
||||||
|
|
||||||
public PlatformImpl() {
|
public PlatformImpl() {
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addWorld(ServerWorld world) {
|
|
||||||
worlds.add(world);
|
|
||||||
}
|
|
||||||
|
|
||||||
private MinecraftServer server;
|
private MinecraftServer server;
|
||||||
|
|
||||||
public void setServer(MinecraftServer server) {
|
public void setServer(MinecraftServer server) {
|
||||||
@@ -90,16 +84,15 @@ public class PlatformImpl extends AbstractPlatform {
|
|||||||
LOGGER.warn("Failed to execute reload", throwable);
|
LOGGER.warn("Failed to execute reload", throwable);
|
||||||
return null;
|
return null;
|
||||||
}).join();
|
}).join();
|
||||||
}
|
server.getWorlds().forEach(world -> {
|
||||||
|
if(world.getChunkManager().getChunkGenerator() instanceof FabricChunkGeneratorWrapper chunkGeneratorWrapper) {
|
||||||
worlds.forEach(world -> {
|
|
||||||
FabricChunkGeneratorWrapper chunkGeneratorWrapper = ((FabricChunkGeneratorWrapper) world.getChunkManager().getChunkGenerator());
|
|
||||||
getConfigRegistry().get(chunkGeneratorWrapper.getPack().getRegistryKey()).ifPresent(pack -> {
|
getConfigRegistry().get(chunkGeneratorWrapper.getPack().getRegistryKey()).ifPresent(pack -> {
|
||||||
chunkGeneratorWrapper.setPack(pack);
|
chunkGeneratorWrapper.setPack(pack);
|
||||||
LOGGER.info("Replaced pack in chunk generator for world {}", world);
|
LOGGER.info("Replaced pack in chunk generator for world {}", world);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
return succeed;
|
return succeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
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 = "<init>", at = @At("RETURN"))
|
|
||||||
public void injectConstructor(MinecraftServer server, Executor workerExecutor, LevelStorage.Session session,
|
|
||||||
ServerWorldProperties properties, RegistryKey<World> worldKey, RegistryEntry<DimensionType> registryEntry,
|
|
||||||
WorldGenerationProgressListener worldGenerationProgressListener, ChunkGenerator chunkGenerator,
|
|
||||||
boolean debugWorld, long seed, List<Spawner> spawners, boolean shouldTickTime, CallbackInfo ci) {
|
|
||||||
if(chunkGenerator instanceof FabricChunkGeneratorWrapper) {
|
|
||||||
FabricEntryPoint.getPlatform().addWorld((ServerWorld) (Object) this);
|
|
||||||
logger.info("Registered world {}", this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,6 @@
|
|||||||
"package": "com.dfsek.terra.fabric.mixin",
|
"package": "com.dfsek.terra.fabric.mixin",
|
||||||
"compatibilityLevel": "JAVA_16",
|
"compatibilityLevel": "JAVA_16",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"ServerWorldMixin",
|
|
||||||
"access.BiomeEffectsAccessor",
|
"access.BiomeEffectsAccessor",
|
||||||
"access.MobSpawnerLogicAccessor",
|
"access.MobSpawnerLogicAccessor",
|
||||||
"access.StateAccessor",
|
"access.StateAccessor",
|
||||||
|
|||||||
Reference in New Issue
Block a user