Terrain height setter

This commit is contained in:
paulevsGitch 2021-12-23 05:54:31 +03:00
parent 717c0d7fb8
commit 6d279852f0
2 changed files with 31 additions and 8 deletions

View file

@ -63,6 +63,7 @@ public class BCLBiomeBuilder {
private float fogDensity;
private float genChance;
private float downfall;
private float height;
/**
* Starts new biome building process.
@ -81,6 +82,7 @@ public class BCLBiomeBuilder {
INSTANCE.fogDensity = 1.0F;
INSTANCE.downfall = 1.0F;
INSTANCE.genChance = 1.0F;
INSTANCE.height = 0.1F;
return INSTANCE;
}
@ -566,6 +568,16 @@ public class BCLBiomeBuilder {
return this;
}
/**
* Set terrain height for the biome. Can be used in custom generators, doesn't change vanilla biome distribution or generation.
* @param height a relative float terrain height value.
* @return same {@link BCLBiomeBuilder} instance.
*/
public BCLBiomeBuilder terrainHeight(float height) {
this.height = height;
return this;
}
/**
* Finalize biome creation.
* @return created {@link BCLBiome} instance.
@ -590,26 +602,27 @@ public class BCLBiomeBuilder {
builder.specialEffects(getEffects().build());
Map<Decoration, List<Supplier<PlacedFeature>>> defferedFeatures = new HashMap<>();
BiomeGenerationSettingsAccessor acc = (BiomeGenerationSettingsAccessor)getGeneration().build();
BiomeGenerationSettingsAccessor acc = BiomeGenerationSettingsAccessor.class.cast(getGeneration().build());
if (acc != null) {
builder.generationSettings(new BiomeGenerationSettings.Builder().build());
var decorations = acc.bclib_getFeatures();
for (Decoration d : Decoration.values()) {
int i = d.ordinal();
if (i >= 0 && i < decorations.size()) {
var features = decorations.get(i);
defferedFeatures.put(d, features.stream().collect(Collectors.toList()));
} else {
}
else {
defferedFeatures.put(d, new ArrayList<>(0));
}
}
} else {
}
else {
builder.generationSettings(getGeneration().build());
}
final T res = biomeConstructor.apply(biomeID, builder.build());
res.setTerrainHeight(height);
res.attachStructures(structures);
res.setSurface(surfaceRule);
res.setFogDensity(fogDensity);

View file

@ -289,6 +289,16 @@ public class BCLBiome {
return this;
}
/**
* Setter for terrain height, can be used in custom terrain generator.
* @param terrainHeight a relative float terrain height value.
* @return same {@link BCLBiome}.
*/
public BCLBiome setTerrainHeight(float terrainHeight) {
this.terrainHeight = terrainHeight;
return this;
}
/**
* Getter for terrain height, can be used in custom terrain generator.
* @return terrain height.