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