mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-07 16:26:13 +00:00
fix /te reload
This commit is contained in:
@@ -3,6 +3,7 @@ package com.dfsek.terra.fabric;
|
||||
import com.dfsek.tectonic.exception.LoadException;
|
||||
import com.dfsek.tectonic.loading.TypeRegistry;
|
||||
|
||||
import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper;
|
||||
import com.dfsek.terra.fabric.util.FabricUtil;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
@@ -50,6 +51,11 @@ public class PlatformImpl extends AbstractPlatform {
|
||||
LangUtil.load(getTerraConfig().getLanguage(), this); // Load language.
|
||||
boolean succeed = getRawConfigRegistry().loadAll(this);
|
||||
|
||||
worlds.forEach(world -> {
|
||||
FabricChunkGeneratorWrapper chunkGeneratorWrapper = ((FabricChunkGeneratorWrapper) world.getChunkManager().getChunkGenerator());
|
||||
chunkGeneratorWrapper.setPack(getConfigRegistry().get(chunkGeneratorWrapper.getPack().getID()));
|
||||
});
|
||||
|
||||
return succeed;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,10 +60,10 @@ public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.C
|
||||
);
|
||||
|
||||
private final long seed;
|
||||
private final ChunkGenerator delegate;
|
||||
private ChunkGenerator delegate;
|
||||
private final TerraBiomeSource biomeSource;
|
||||
|
||||
private final ConfigPack pack;
|
||||
private ConfigPack pack;
|
||||
private ServerWorld world;
|
||||
|
||||
public FabricChunkGeneratorWrapper(TerraBiomeSource biomeSource, long seed, ConfigPack configPack) {
|
||||
@@ -77,6 +77,13 @@ public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.C
|
||||
this.seed = seed;
|
||||
}
|
||||
|
||||
public void setPack(ConfigPack pack) {
|
||||
this.pack = pack;
|
||||
this.delegate = pack.getGeneratorProvider().newInstance(pack);
|
||||
biomeSource.setPack(pack);
|
||||
|
||||
delegate.getPlatform().logger().info("Loading world with config pack " + pack.getID());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Codec<? extends net.minecraft.world.gen.chunk.ChunkGenerator> getCodec() {
|
||||
|
||||
@@ -34,8 +34,11 @@ public class TerraBiomeSource extends BiomeSource {
|
||||
|
||||
private final Registry<Biome> biomeRegistry;
|
||||
private final long seed;
|
||||
private final BiomeProvider provider;
|
||||
private final ConfigPack pack;
|
||||
private ConfigPack pack;
|
||||
|
||||
public void setPack(ConfigPack pack) {
|
||||
this.pack = pack;
|
||||
}
|
||||
|
||||
public TerraBiomeSource(Registry<Biome> biomes, long seed, ConfigPack pack) {
|
||||
super(biomes.stream()
|
||||
@@ -45,7 +48,6 @@ public class TerraBiomeSource extends BiomeSource {
|
||||
.collect(Collectors.toList()));
|
||||
this.biomeRegistry = biomes;
|
||||
this.seed = seed;
|
||||
this.provider = pack.getBiomeProviderBuilder();
|
||||
this.pack = pack;
|
||||
}
|
||||
|
||||
@@ -61,11 +63,11 @@ public class TerraBiomeSource extends BiomeSource {
|
||||
|
||||
@Override
|
||||
public Biome getBiomeForNoiseGen(int biomeX, int biomeY, int biomeZ) {
|
||||
TerraBiome biome = provider.getBiome(biomeX << 2, biomeZ << 2, seed);
|
||||
TerraBiome biome = pack.getBiomeProviderBuilder().getBiome(biomeX << 2, biomeZ << 2, seed);
|
||||
return biomeRegistry.get(new Identifier("terra", FabricUtil.createBiomeID(pack, biome.getID())));
|
||||
}
|
||||
|
||||
public BiomeProvider getProvider() {
|
||||
return provider;
|
||||
return pack.getBiomeProviderBuilder();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user