mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-11 18:26:08 +00:00
use propertykey for features
This commit is contained in:
@@ -28,6 +28,8 @@ import com.dfsek.terra.api.event.events.config.ConfigurationLoadEvent;
|
||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||
import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
import com.dfsek.terra.api.properties.Context;
|
||||
import com.dfsek.terra.api.properties.PropertyKey;
|
||||
import com.dfsek.terra.api.structure.feature.Feature;
|
||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
@@ -49,12 +51,13 @@ public class FeatureGenerationAddon implements AddonInitializer {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void initialize() {
|
||||
PropertyKey<BiomeFeatures> biomeFeaturesKey = Context.create(BiomeFeatures.class);
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(addon, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> event.getPack()
|
||||
.getOrCreateRegistry(STAGE_TYPE_KEY)
|
||||
.register(addon.key("FEATURE"), () -> new FeatureStageTemplate(platform)))
|
||||
.register(addon.key("FEATURE"), () -> new FeatureStageTemplate(platform, biomeFeaturesKey)))
|
||||
.failThrough();
|
||||
|
||||
platform.getEventManager()
|
||||
|
||||
@@ -9,6 +9,7 @@ package com.dfsek.terra.addons.generation.feature;
|
||||
|
||||
import com.dfsek.terra.addons.generation.feature.config.BiomeFeatures;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.properties.PropertyKey;
|
||||
import com.dfsek.terra.api.registry.key.StringIdentifiable;
|
||||
import com.dfsek.terra.api.util.Rotation;
|
||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||
@@ -29,12 +30,14 @@ public class FeatureGenerationStage implements GenerationStage, StringIdentifiab
|
||||
private final String profile;
|
||||
|
||||
private final int resolution;
|
||||
private final PropertyKey<BiomeFeatures> biomeFeaturesKey;
|
||||
|
||||
public FeatureGenerationStage(Platform platform, String id, int resolution) {
|
||||
public FeatureGenerationStage(Platform platform, String id, int resolution, PropertyKey<BiomeFeatures> biomeFeaturesKey) {
|
||||
this.platform = platform;
|
||||
this.id = id;
|
||||
this.profile = "feature_stage:" + id;
|
||||
this.resolution = resolution;
|
||||
this.biomeFeaturesKey = biomeFeaturesKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -58,7 +61,7 @@ public class FeatureGenerationStage implements GenerationStage, StringIdentifiab
|
||||
long coordinateSeed = (seed * 31 + x) * 31 + z;
|
||||
Column<WritableWorld> column = world.column(x, z);
|
||||
biome.getContext()
|
||||
.get(BiomeFeatures.class)
|
||||
.get(biomeFeaturesKey)
|
||||
.getFeatures()
|
||||
.getOrDefault(this, Collections.emptyList())
|
||||
.forEach(feature -> {
|
||||
|
||||
@@ -8,11 +8,13 @@ import com.dfsek.tectonic.api.exception.ValidationException;
|
||||
|
||||
import com.dfsek.terra.addons.generation.feature.FeatureGenerationStage;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.properties.PropertyKey;
|
||||
import com.dfsek.terra.api.world.chunk.generation.stage.GenerationStage;
|
||||
|
||||
|
||||
public class FeatureStageTemplate implements ObjectTemplate<GenerationStage>, ValidatedConfigTemplate {
|
||||
private final Platform platform;
|
||||
private final PropertyKey<BiomeFeatures> biomeFeaturesKey;
|
||||
@Value("id")
|
||||
private String id;
|
||||
|
||||
@@ -20,12 +22,15 @@ public class FeatureStageTemplate implements ObjectTemplate<GenerationStage>, Va
|
||||
@Default
|
||||
private int resolution = 4;
|
||||
|
||||
public FeatureStageTemplate(Platform platform) { this.platform = platform; }
|
||||
public FeatureStageTemplate(Platform platform, PropertyKey<BiomeFeatures> biomeFeaturesKey) {
|
||||
this.platform = platform;
|
||||
this.biomeFeaturesKey = biomeFeaturesKey;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public FeatureGenerationStage get() {
|
||||
return new FeatureGenerationStage(platform, id, resolution);
|
||||
return new FeatureGenerationStage(platform, id, resolution, biomeFeaturesKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user