mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 14:21:08 +00:00
finish feature stage impl
This commit is contained in:
+28
-18
@@ -7,18 +7,19 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.addons.generation.feature;
|
package com.dfsek.terra.addons.generation.feature;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.generation.feature.config.BiomeFeatures;
|
import com.dfsek.terra.addons.generation.feature.config.BiomeFeatures;
|
||||||
import com.dfsek.terra.api.Platform;
|
import com.dfsek.terra.api.Platform;
|
||||||
import com.dfsek.terra.api.profiler.ProfileFrame;
|
import com.dfsek.terra.api.profiler.ProfileFrame;
|
||||||
import com.dfsek.terra.api.util.Rotation;
|
|
||||||
import com.dfsek.terra.api.util.PopulationUtil;
|
import com.dfsek.terra.api.util.PopulationUtil;
|
||||||
|
import com.dfsek.terra.api.util.Rotation;
|
||||||
import com.dfsek.terra.api.util.StringIdentifiable;
|
import com.dfsek.terra.api.util.StringIdentifiable;
|
||||||
import com.dfsek.terra.api.util.vector.Vector3;
|
import com.dfsek.terra.api.util.vector.Vector3;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.ProtoWorld;
|
import com.dfsek.terra.api.world.chunk.generation.ProtoWorld;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.stage.GenerationStage;
|
import com.dfsek.terra.api.world.chunk.generation.stage.GenerationStage;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
|
|
||||||
public class FeatureGenerationStage implements GenerationStage, StringIdentifiable {
|
public class FeatureGenerationStage implements GenerationStage, StringIdentifiable {
|
||||||
private final Platform platform;
|
private final Platform platform;
|
||||||
@@ -42,21 +43,30 @@ public class FeatureGenerationStage implements GenerationStage, StringIdentifiab
|
|||||||
int tx = cx + x;
|
int tx = cx + x;
|
||||||
int tz = cz + z;
|
int tz = cz + z;
|
||||||
ColumnImpl<ProtoWorld> column = new ColumnImpl<>(tx, tz, world);
|
ColumnImpl<ProtoWorld> column = new ColumnImpl<>(tx, tz, world);
|
||||||
world.getBiomeProvider().getBiome(tx, tz, seed).getContext().get(BiomeFeatures.class).getFeatures().forEach(feature -> {
|
world.getBiomeProvider()
|
||||||
try(ProfileFrame ignored = platform.getProfiler().profile(feature.getID())) {
|
.getBiome(tx, tz, seed)
|
||||||
if(feature.getDistributor().matches(tx, tz, seed)) {
|
.getContext()
|
||||||
feature.getLocator()
|
.get(BiomeFeatures.class)
|
||||||
.getSuitableCoordinates(column)
|
.getFeatures()
|
||||||
.forEach(y ->
|
.getOrDefault(id, Collections.emptyList())
|
||||||
feature.getStructure(world, tx, y, tz)
|
.forEach(feature -> {
|
||||||
.generate(new Vector3(tx, y, tz), world, new Random(
|
try(ProfileFrame ignored = platform.getProfiler().profile(feature.getID())) {
|
||||||
PopulationUtil.getCarverChunkSeed(world.centerChunkX(),
|
if(feature.getDistributor().matches(tx, tz, seed)) {
|
||||||
world.centerChunkZ(), seed)),
|
feature.getLocator()
|
||||||
Rotation.NONE)
|
.getSuitableCoordinates(column)
|
||||||
);
|
.forEach(y ->
|
||||||
}
|
feature.getStructure(world, tx, y, tz)
|
||||||
}
|
.generate(new Vector3(tx, y, tz),
|
||||||
});
|
world,
|
||||||
|
new Random(PopulationUtil.getCarverChunkSeed(
|
||||||
|
world.centerChunkX(),
|
||||||
|
world.centerChunkZ(),
|
||||||
|
seed)),
|
||||||
|
Rotation.NONE)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-3
@@ -8,19 +8,20 @@
|
|||||||
package com.dfsek.terra.addons.generation.feature.config;
|
package com.dfsek.terra.addons.generation.feature.config;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.dfsek.terra.api.properties.Properties;
|
import com.dfsek.terra.api.properties.Properties;
|
||||||
import com.dfsek.terra.api.structure.feature.Feature;
|
import com.dfsek.terra.api.structure.feature.Feature;
|
||||||
|
|
||||||
|
|
||||||
public class BiomeFeatures implements Properties {
|
public class BiomeFeatures implements Properties {
|
||||||
private final List<Feature> features;
|
private final Map<String, List<Feature>> features;
|
||||||
|
|
||||||
public BiomeFeatures(List<Feature> features) {
|
public BiomeFeatures(Map<String, List<Feature>> features) {
|
||||||
this.features = features;
|
this.features = features;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Feature> getFeatures() {
|
public Map<String, List<Feature>> getFeatures() {
|
||||||
return features;
|
return features;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -13,6 +13,8 @@ import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
|||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import com.dfsek.terra.api.config.meta.Meta;
|
import com.dfsek.terra.api.config.meta.Meta;
|
||||||
import com.dfsek.terra.api.structure.feature.Feature;
|
import com.dfsek.terra.api.structure.feature.Feature;
|
||||||
@@ -22,7 +24,7 @@ import com.dfsek.terra.api.structure.feature.Feature;
|
|||||||
public class BiomeFeaturesTemplate implements ObjectTemplate<BiomeFeatures> {
|
public class BiomeFeaturesTemplate implements ObjectTemplate<BiomeFeatures> {
|
||||||
@Value("features")
|
@Value("features")
|
||||||
@Default
|
@Default
|
||||||
private @Meta List<@Meta Feature> features = Collections.emptyList();
|
private @Meta Map<@Meta String, @Meta List<@Meta Feature>> features = Collections.emptyMap();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BiomeFeatures get() {
|
public BiomeFeatures get() {
|
||||||
|
|||||||
Reference in New Issue
Block a user