- filter out non-overworld (BiomeDictionary) biomes so we don't pick mod-biomes designed for other dimensions
- add BiomeDict types for tf biomes - fix possible crash when setting a terrain type to 0 - rename 'generate' button to 'new seed' - reduce float slider precision to 3 decimal places
This commit is contained in:
parent
f4cfcc3bac
commit
661cf47eb8
@ -27,12 +27,7 @@ package com.terraforged.core.world.terrain;
|
||||
|
||||
import com.terraforged.core.cell.Cell;
|
||||
import com.terraforged.core.cell.Populator;
|
||||
import com.terraforged.core.util.Seed;
|
||||
import me.dags.noise.Module;
|
||||
import me.dags.noise.Source;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
public class TerrainPopulator implements Populator {
|
||||
|
||||
@ -62,41 +57,4 @@ public class TerrainPopulator implements Populator {
|
||||
public void tag(Cell<Terrain> cell, float x, float y) {
|
||||
cell.tag = type;
|
||||
}
|
||||
|
||||
public static TerrainPopulator[] combine(TerrainPopulator[] input, Seed seed, int scale) {
|
||||
return combine(input, (tp1, tp2) -> TerrainPopulator.combine(tp1, tp2, seed, scale));
|
||||
}
|
||||
|
||||
public static TerrainPopulator combine(TerrainPopulator tp1, TerrainPopulator tp2, Seed seed, int scale) {
|
||||
Module combined = Source.perlin(seed.next(), scale, 1)
|
||||
.warp(seed.next(), scale / 2, 2, scale / 2)
|
||||
.blend(tp1.getSource(), tp2.getSource(), 0.5, 0.25);
|
||||
|
||||
String name = tp1.getType().getName() + "-" + tp2.getType().getName();
|
||||
int id = Terrain.ID_START + 1 + tp1.getType().getId() * tp2.getType().getId();
|
||||
float weight = Math.min(tp1.getType().getWeight(), tp2.getType().getWeight());
|
||||
Terrain type = new Terrain(name, id, weight);
|
||||
|
||||
return new TerrainPopulator(combined, type);
|
||||
}
|
||||
|
||||
public static <T> T[] combine(T[] input, BiFunction<T, T, T> operator) {
|
||||
int length = input.length;
|
||||
for (int i = 1; i < input.length; i++) {
|
||||
length += (input.length - i);
|
||||
}
|
||||
|
||||
T[] result = Arrays.copyOf(input, length);
|
||||
for (int i = 0, k = input.length; i < input.length; i++) {
|
||||
T t1 = input[i];
|
||||
result[i] = t1;
|
||||
for (int j = i + 1; j < input.length; j++, k++) {
|
||||
T t2 = input[j];
|
||||
T t3 = operator.apply(t1, t2);
|
||||
result[k] = t3;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public class StandardTerrainProvider implements TerrainProvider {
|
||||
|
||||
@Override
|
||||
public List<Populator> getPopulators() {
|
||||
List<TerrainPopulator> mixed = combine(mixable, this::combine);
|
||||
List<TerrainPopulator> mixed = combine(getMixable(mixable), this::combine);
|
||||
List<Populator> result = new ArrayList<>(mixed.size() + unmixable.size());
|
||||
result.addAll(mixed);
|
||||
result.addAll(unmixable);
|
||||
@ -117,14 +117,15 @@ public class StandardTerrainProvider implements TerrainProvider {
|
||||
}
|
||||
|
||||
private static TerrainPopulator combine(TerrainPopulator tp1, TerrainPopulator tp2, Seed seed, int scale) {
|
||||
Module combined = Source.perlin(seed.next(), scale, 1)
|
||||
.warp(seed.next(), scale / 2, 2, scale / 2)
|
||||
.blend(tp1.getSource(), tp2.getSource(), 0.5, 0.25);
|
||||
float weight = Math.min(tp1.getType().getWeight(), tp2.getType().getWeight());
|
||||
|
||||
String name = tp1.getType().getName() + "-" + tp2.getType().getName();
|
||||
int id = Terrain.ID_START + 1 + tp1.getType().getId() * tp2.getType().getId();
|
||||
float weight = Math.min(tp1.getType().getWeight(), tp2.getType().getWeight());
|
||||
|
||||
Terrain type = new Terrain(name, id, weight);
|
||||
Module combined = Source.perlin(seed.next(), scale, 1)
|
||||
.warp(seed.next(), scale / 2, 2, scale / 2D)
|
||||
.blend(tp1.getSource(), tp2.getSource(), 0.5, 0.25);
|
||||
|
||||
return new TerrainPopulator(combined, type);
|
||||
}
|
||||
@ -152,4 +153,14 @@ public class StandardTerrainProvider implements TerrainProvider {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static List<TerrainPopulator> getMixable(List<TerrainPopulator> input) {
|
||||
List<TerrainPopulator> output = new ArrayList<>(input.size());
|
||||
for (TerrainPopulator populator : input) {
|
||||
if (populator.getType().getWeight() > 0) {
|
||||
output.add(populator);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ package com.terraforged.mod.biome;
|
||||
|
||||
import com.terraforged.api.biome.BiomeVariant;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@ -53,7 +54,11 @@ public class ModBiomes {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void register(RegistryEvent.Register<Biome> event) {
|
||||
biomes.forEach(event.getRegistry()::register);
|
||||
biomes.forEach(biome -> {
|
||||
event.getRegistry().register(biome);
|
||||
BiomeDictionary.makeBestGuess(biome);
|
||||
BiomeDictionary.addTypes(biome, BiomeDictionary.Type.OVERWORLD);
|
||||
});
|
||||
biomes.clear();
|
||||
biomes.trimToSize();
|
||||
}
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
package com.terraforged.mod.biome.provider;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.terraforged.core.settings.BiomeSettings;
|
||||
import com.terraforged.core.world.biome.BiomeData;
|
||||
import com.terraforged.core.world.biome.BiomeType;
|
||||
@ -55,20 +54,6 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class BiomeHelper {
|
||||
|
||||
private static final Set<Biome> IGNORE_BIOMES = Sets.newHashSet(
|
||||
Biomes.THE_END,
|
||||
Biomes.END_BARRENS,
|
||||
Biomes.END_HIGHLANDS,
|
||||
Biomes.END_MIDLANDS,
|
||||
Biomes.SMALL_END_ISLANDS,
|
||||
Biomes.NETHER,
|
||||
Biomes.THE_VOID,
|
||||
Biomes.JUNGLE_EDGE,
|
||||
Biomes.MODIFIED_JUNGLE_EDGE,
|
||||
Biomes.MOUNTAIN_EDGE,
|
||||
Biomes.STONE_SHORE
|
||||
);
|
||||
|
||||
private static final Map<BiomeType, BiomePredicate> PREDICATES = new HashMap<BiomeType, BiomePredicate>() {{
|
||||
put(BiomeType.TROPICAL_RAINFOREST, BiomePredicate.TROPICAL_RAINFOREST);
|
||||
put(BiomeType.SAVANNA, BiomePredicate.SAVANNA.or(BiomePredicate.MESA).not(BiomePredicate.DESERT).not(BiomePredicate.STEPPE).not(BiomePredicate.COAST).not(BiomePredicate.MOUNTAIN).not(BiomePredicate.WETLAND));
|
||||
@ -227,7 +212,7 @@ public class BiomeHelper {
|
||||
if (biome.getCategory() == Biome.Category.NETHER) {
|
||||
return true;
|
||||
}
|
||||
return IGNORE_BIOMES.contains(biome);
|
||||
return !BiomeDictionary.getTypes(biome).contains(BiomeDictionary.Type.OVERWORLD);
|
||||
}
|
||||
|
||||
private static Vec2f getRange(Collection<Biome> biomes, Function<Biome, Float> getter) {
|
||||
|
@ -85,7 +85,7 @@ public abstract class TerraSlider extends Slider implements Slider.ISlider, Elem
|
||||
|
||||
public Float(String prefix, CompoundNBT value) {
|
||||
super(prefix, value, true);
|
||||
precision = 4;
|
||||
precision = 3;
|
||||
setValue(value.getFloat("value"));
|
||||
updateSlider();
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public class PreviewPage extends BasePage {
|
||||
preview.setHeight(256);
|
||||
|
||||
addElements(right.left, right.top, right, previewerSettings, right.scrollPane::addButton, this::update);
|
||||
right.scrollPane.addButton(new TerraButton("Generate") {
|
||||
right.scrollPane.addButton(new TerraButton("New Seed") {
|
||||
@Override
|
||||
public void onPress() {
|
||||
preview.regenerate();
|
||||
|
Loading…
Reference in New Issue
Block a user