mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 10:30:42 +00:00
move stages to ConfigPack instance
This commit is contained in:
@@ -35,7 +35,6 @@ import com.dfsek.terra.api.world.chunk.generation.util.Palette;
|
||||
|
||||
public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
private final Platform platform;
|
||||
private final List<GenerationStage> generationStages = new ArrayList<>();
|
||||
|
||||
private final SamplerProvider samplerCache;
|
||||
|
||||
@@ -51,7 +50,6 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
this.carverHorizontalResolution = carverHorizontalResolution;
|
||||
this.carverVerticalResolution = carverVerticalResolution;
|
||||
this.samplerCache = new SamplerProvider(platform, c.getBiomeProvider(), elevationBlend);
|
||||
c.getStages().forEach(stage -> generationStages.add(stage.newInstance(c)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,11 +110,6 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GenerationStage> getGenerationStages() {
|
||||
return generationStages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(ServerWorld world, int x, int y, int z) {
|
||||
BiomeProvider provider = world.getBiomeProvider();
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.dfsek.terra.api.util.StringIdentifiable;
|
||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||
import com.dfsek.terra.api.world.ServerWorld;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.chunk.generation.stage.GenerationStage;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.provider.ChunkGeneratorProvider;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.provider.GenerationStageProvider;
|
||||
|
||||
@@ -53,7 +54,7 @@ public interface ConfigPack extends LoaderRegistrar, LoaderHolder, RegistryHolde
|
||||
return getOrCreateRegistry(type.getType());
|
||||
}
|
||||
|
||||
List<GenerationStageProvider> getStages();
|
||||
List<GenerationStage> getStages();
|
||||
|
||||
Loader getLoader();
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@ public interface ChunkGenerator {
|
||||
void generateChunkData(@NotNull ProtoChunk chunk, @NotNull WritableWorld world,
|
||||
int chunkX, int chunkZ);
|
||||
|
||||
List<GenerationStage> getGenerationStages();
|
||||
|
||||
BlockState getBlock(ServerWorld world, int x, int y, int z);
|
||||
|
||||
default BlockState getBlock(ServerWorld world, Vector3 vector3) {
|
||||
|
||||
@@ -29,6 +29,10 @@ import com.dfsek.tectonic.loading.TypeLoader;
|
||||
import com.dfsek.tectonic.loading.TypeRegistry;
|
||||
import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
||||
import com.dfsek.tectonic.yaml.YamlConfiguration;
|
||||
|
||||
import com.dfsek.terra.api.util.generic.Lazy;
|
||||
import com.dfsek.terra.api.world.chunk.generation.stage.GenerationStage;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -49,6 +53,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
@@ -75,7 +80,6 @@ import com.dfsek.terra.api.util.generic.pair.Pair;
|
||||
import com.dfsek.terra.api.util.reflection.ReflectionUtil;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.provider.ChunkGeneratorProvider;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.provider.GenerationStageProvider;
|
||||
import com.dfsek.terra.config.fileloaders.FolderLoader;
|
||||
import com.dfsek.terra.config.fileloaders.ZIPLoader;
|
||||
import com.dfsek.terra.config.loaders.GenericTemplateSupplierLoader;
|
||||
@@ -115,7 +119,11 @@ public class ConfigPackImpl implements ConfigPack {
|
||||
|
||||
private final ConfigTypeRegistry configTypeRegistry;
|
||||
|
||||
|
||||
private final Lazy<List<GenerationStage>> stages = Lazy.lazy(() -> template
|
||||
.getStages()
|
||||
.stream()
|
||||
.map(stage -> stage.newInstance(this))
|
||||
.collect(Collectors.toList()));
|
||||
private final TreeMap<Integer, List<Pair<String, ConfigType<?, ?>>>> configTypes = new TreeMap<>();
|
||||
|
||||
public ConfigPackImpl(File folder, Platform platform) throws ConfigException {
|
||||
@@ -343,8 +351,8 @@ public class ConfigPackImpl implements ConfigPack {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GenerationStageProvider> getStages() {
|
||||
return template.getStages();
|
||||
public List<GenerationStage> getStages() {
|
||||
return stages.value();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -67,12 +67,16 @@ public class BukkitChunkGeneratorWrapper extends org.bukkit.generator.ChunkGener
|
||||
|
||||
@Override
|
||||
public @NotNull List<BlockPopulator> getDefaultPopulators(@NotNull World world) {
|
||||
return delegate.getGenerationStages().stream().map(generationStage -> new BlockPopulator() {
|
||||
@Override
|
||||
public void populate(@NotNull WorldInfo worldInfo, @NotNull Random random, int x, int z, @NotNull LimitedRegion limitedRegion) {
|
||||
generationStage.populate(new BukkitProtoWorld(limitedRegion));
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
return pack.getStages()
|
||||
.stream()
|
||||
.map(generationStage -> new BlockPopulator() {
|
||||
@Override
|
||||
public void populate(@NotNull WorldInfo worldInfo, @NotNull Random random, int x, int z,
|
||||
@NotNull LimitedRegion limitedRegion) {
|
||||
generationStage.populate(new BukkitProtoWorld(limitedRegion));
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,11 +21,9 @@ import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.SpawnGroup;
|
||||
import net.minecraft.structure.StructureManager;
|
||||
import net.minecraft.util.collection.Pool;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.registry.DynamicRegistryManager;
|
||||
import net.minecraft.world.ChunkRegion;
|
||||
import net.minecraft.world.HeightLimitView;
|
||||
import net.minecraft.world.Heightmap;
|
||||
@@ -195,7 +193,7 @@ public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.C
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
ProtoWorld world = (ProtoWorld) ((StructureAccessorAccessor) structureAccessor).getWorld();
|
||||
delegate.generateChunkData((ProtoChunk) chunk, world, chunk.getPos().x, chunk.getPos().z);
|
||||
delegate.getGenerationStages().forEach(populator -> {
|
||||
pack.getStages().forEach(populator -> {
|
||||
if(populator instanceof Chunkified) {
|
||||
populator.populate(world);
|
||||
}
|
||||
@@ -207,7 +205,7 @@ public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.C
|
||||
@Override
|
||||
public void generateFeatures(StructureWorldAccess world, Chunk chunk, StructureAccessor structureAccessor) {
|
||||
super.generateFeatures(world, chunk, structureAccessor);
|
||||
delegate.getGenerationStages().forEach(populator -> {
|
||||
pack.getStages().forEach(populator -> {
|
||||
if(!(populator instanceof Chunkified)) {
|
||||
populator.populate((ProtoWorld) world);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user