- more work on presets

- added stone forest biome
- updated lang file
This commit is contained in:
dags- 2020-06-24 23:00:08 +01:00
parent 44b6d56d89
commit 8abd851f77
10 changed files with 215 additions and 7 deletions

View File

@ -11,6 +11,7 @@
"biome.terraforged.snowy_fir_forest": "Snowy Fir Forest",
"biome.terraforged.snowy_taiga_scrub": "Snowy Taiga Scrub",
"biome.terraforged.steppe": "Steppe",
"biome.terraforged.stone_forest": "Stone Forest",
"biome.terraforged.taiga_scrub": "Taiga Scrub",
"biome.terraforged.warm_beach": "Warm Beach",
"display.terraforged.climate": "Climate",

View File

@ -34,6 +34,11 @@ public abstract class BiomeVariant extends Biome {
super(biomeBuilder);
}
// override to register a custom biome weight with Forge's BiomeManager (default is 10)
public void registerWeights() {
}
@Override
public int getGrassColor(double x, double z) {
return getBase().getGrassColor(x, z);

View File

@ -41,6 +41,7 @@ public class ModBiomes {
public static final Biome BRYCE = register(new Bryce());
public static final Biome COLD_STEPPE = register(new ColdSteppe());
public static final Biome ERODED_PINNACLE = register(new StoneForest());
public static final Biome FIR_FOREST = register(new FirForest());
public static final Biome FLOWER_PLAINS = register(new FlowerPlains());
public static final Biome FROZEN_LAKE = register(new FrozenLake());
@ -63,12 +64,22 @@ public class ModBiomes {
public static void register(RegistryEvent.Register<Biome> event) {
biomes.forEach(biome -> {
event.getRegistry().register(biome);
// TF biomes can specify a custom biome weight
biome.registerWeights();
// let forge generate the BiomeDictionary.Type's since TF biomes are just variants of vanilla ones
BiomeDictionary.makeBestGuess(biome);
// overworld is required for TerraForged
BiomeDictionary.addTypes(biome, BiomeDictionary.Type.OVERWORLD);
// if a variant of a rare biome, register as such
if (BiomeDictionary.getTypes(biome.getBase()).contains(BiomeDictionary.Type.RARE)) {
BiomeDictionary.addTypes(biome, BiomeDictionary.Type.RARE);
}
});
biomes.clear();
biomes.trimToSize();
}

View File

@ -0,0 +1,67 @@
package com.terraforged.biome;
import com.terraforged.api.biome.BiomeVariant;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.biome.DefaultBiomeFeatures;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.IFeatureConfig;
import net.minecraft.world.gen.feature.structure.MineshaftConfig;
import net.minecraft.world.gen.feature.structure.MineshaftStructure;
import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder;
import net.minecraftforge.common.BiomeManager;
public class StoneForest extends BiomeVariant {
public StoneForest() {
super((new Biome.Builder()).surfaceBuilder(SurfaceBuilder.DEFAULT, SurfaceBuilder.GRASS_DIRT_GRAVEL_CONFIG).precipitation(Biome.RainType.RAIN).category(Biome.Category.JUNGLE).depth(0.1F).scale(0.2F).temperature(0.95F).downfall(0.9F).waterColor(4159204).waterFogColor(329011).parent((String)null));
this.addStructure(Feature.MINESHAFT.withConfiguration(new MineshaftConfig(0.004D, MineshaftStructure.Type.NORMAL)));
this.addStructure(Feature.STRONGHOLD.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG));
DefaultBiomeFeatures.addCarvers(this);
DefaultBiomeFeatures.addStructures(this);
DefaultBiomeFeatures.addLakes(this);
DefaultBiomeFeatures.addMonsterRooms(this);
DefaultBiomeFeatures.addStoneVariants(this);
DefaultBiomeFeatures.addOres(this);
DefaultBiomeFeatures.addSedimentDisks(this);
DefaultBiomeFeatures.addBamboo(this);
DefaultBiomeFeatures.addJungleTreeForest(this);
DefaultBiomeFeatures.addExtraDefaultFlowers(this);
DefaultBiomeFeatures.addJungleGrass(this);
DefaultBiomeFeatures.addMushrooms(this);
DefaultBiomeFeatures.addReedsAndPumpkins(this);
DefaultBiomeFeatures.addSprings(this);
DefaultBiomeFeatures.addJunglePlants(this);
DefaultBiomeFeatures.addFreezeTopLayer(this);
this.addSpawn(EntityClassification.CREATURE, new Biome.SpawnListEntry(EntityType.SHEEP, 12, 4, 4));
this.addSpawn(EntityClassification.CREATURE, new Biome.SpawnListEntry(EntityType.PIG, 10, 4, 4));
this.addSpawn(EntityClassification.CREATURE, new Biome.SpawnListEntry(EntityType.CHICKEN, 10, 4, 4));
this.addSpawn(EntityClassification.CREATURE, new Biome.SpawnListEntry(EntityType.COW, 8, 4, 4));
this.addSpawn(EntityClassification.CREATURE, new Biome.SpawnListEntry(EntityType.PARROT, 40, 1, 2));
this.addSpawn(EntityClassification.CREATURE, new Biome.SpawnListEntry(EntityType.PANDA, 1, 1, 2));
this.addSpawn(EntityClassification.CREATURE, new Biome.SpawnListEntry(EntityType.CHICKEN, 10, 4, 4));
this.addSpawn(EntityClassification.AMBIENT, new Biome.SpawnListEntry(EntityType.BAT, 10, 8, 8));
this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.SPIDER, 100, 4, 4));
this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.ZOMBIE, 95, 4, 4));
this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.ZOMBIE_VILLAGER, 5, 1, 1));
this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.SKELETON, 100, 4, 4));
this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.CREEPER, 100, 4, 4));
this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.SLIME, 100, 4, 4));
this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.ENDERMAN, 10, 1, 4));
this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.WITCH, 5, 1, 1));
this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.OCELOT, 2, 1, 3));
setRegistryName("terraforged", "stone_forest");
}
@Override
public void registerWeights() {
BiomeManager.addBiome(BiomeManager.BiomeType.WARM, new BiomeManager.BiomeEntry(this, 5));
}
@Override
public Biome getBase() {
return Biomes.JUNGLE;
}
}

View File

@ -0,0 +1,45 @@
package com.terraforged.biome.surface;
import com.terraforged.api.chunk.surface.Surface;
import com.terraforged.api.chunk.surface.SurfaceContext;
import com.terraforged.api.material.state.States;
import com.terraforged.core.Seed;
import com.terraforged.n2d.Module;
import com.terraforged.n2d.Source;
import com.terraforged.n2d.util.NoiseUtil;
import net.minecraft.block.BlockState;
public class StoneForestSurface implements Surface {
private final Module module;
private final BlockState dirt;
private final BlockState grass;
private final BlockState stone;
public StoneForestSurface(Seed seed) {
dirt = States.DIRT.get();
stone = States.STONE.get();
grass = States.GRASS_BLOCK.get();
module = Source.ridge(seed.next(), 50, 4)
.clamp(0.7, 0.95).map(0, 1)
.pow(1.5)
.terrace(1, 0.25, 4, 1);
}
@Override
public void buildSurface(int x, int z, int height, SurfaceContext ctx) {
float alpha = 1 - ctx.cell.steepness;
float mask = alpha * ctx.cell.biomeEdge * NoiseUtil.map(ctx.cell.riverMask,0, 0.0005F, 0.0005F);
float value = module.getValue(x, z) * mask;
int top = height + (int) (value * 50);
if (top > height) {
for (int y = height; y < top - 1; y++) {
ctx.buffer.setBlockState(ctx.pos.setPos(x, y, z), stone, false);
}
ctx.buffer.setBlockState(ctx.pos.setPos(x, top, z), grass, false);
ctx.buffer.setBlockState(ctx.pos.setPos(x, top - 1, z), dirt, false);
}
}
}

View File

@ -6,6 +6,7 @@ import com.terraforged.api.chunk.surface.SurfaceManager;
import com.terraforged.biome.ModBiomes;
import com.terraforged.biome.surface.BriceSurface;
import com.terraforged.biome.surface.DesertSurface;
import com.terraforged.biome.surface.StoneForestSurface;
import com.terraforged.biome.surface.ForestSurface;
import com.terraforged.biome.surface.IcebergsSurface;
import com.terraforged.biome.surface.SwampSurface;
@ -113,6 +114,7 @@ public class TerraSetupFactory {
manager.replace(Biomes.DEEP_FROZEN_OCEAN, new IcebergsSurface(context, 30, 30));
manager.replace(Biomes.FROZEN_OCEAN, new IcebergsSurface(context, 20, 15));
manager.append(ModBiomes.BRYCE, new BriceSurface(context.seed));
manager.append(ModBiomes.ERODED_PINNACLE, new StoneForestSurface(context.seed));
manager.append(
new DesertSurface(context),
Biomes.DESERT,

View File

@ -39,10 +39,10 @@ public class Test {
}
public static Terrain getTerrainType(Terrains terrains) {
return terrains.mountains;
return terrains.plains;
}
public static Biome getBiome() {
return ModBiomes.TAIGA_SCRUB;
return ModBiomes.ERODED_PINNACLE;
}
}

View File

@ -14,6 +14,9 @@ public class TerraTextInput extends TextFieldWidget implements Element, Consumer
private final String name;
private final CompoundNBT value;
private final List<String> tooltip;
private String stringValue = "";
private boolean valid = true;
private Predicate<String> validator = s -> true;
private Consumer<TerraTextInput> callback = t -> {};
@ -22,17 +25,31 @@ public class TerraTextInput extends TextFieldWidget implements Element, Consumer
this.name = name;
this.value = value;
this.tooltip = Element.getToolTip(name, value);
this.stringValue = value.getString(name);
setText(value.getString(name));
setResponder(this);
setEnabled(true);
}
public boolean isValid() {
return valid;
}
public String getValue() {
return value.getString(name);
return stringValue;
}
public void setColorValidator(Predicate<String> validator) {
this.validator = validator;
// update validity immediately
if (validator.test(stringValue)) {
valid = true;
setTextColor(14737632);
} else {
valid = false;
setTextColor(0xffff3f30);
}
}
@Override
@ -53,12 +70,16 @@ public class TerraTextInput extends TextFieldWidget implements Element, Consumer
@Override
public void accept(String text) {
value.put(name, StringNBT.valueOf(text));
callback.accept(this);
stringValue = text;
if (validator.test(text)) {
valid = true;
setTextColor(14737632);
} else {
valid = false;
setTextColor(0xffff3f30);
}
callback.accept(this);
}
}

View File

@ -13,12 +13,16 @@ import com.terraforged.util.nbt.NBTHelper;
import net.minecraft.nbt.CompoundNBT;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.regex.Pattern;
public class PresetsPage extends BasePage {
private static final Predicate<String> NAME_VALIDATOR = Pattern.compile("^[A-Za-z0-9\\-_ ]+$").asPredicate();
private final Instance instance;
private final UpdatablePage preview;
private final TerraTextInput nameInput;
private final Instance instance;
private final PresetManager manager = PresetManager.load();
public PresetsPage(Instance instance, UpdatablePage preview) {
@ -27,6 +31,7 @@ public class PresetsPage extends BasePage {
this.preview = preview;
this.instance = instance;
this.nameInput = new TerraTextInput("name", value);
this.nameInput.setColorValidator(NAME_VALIDATOR);
}
@Override
@ -59,7 +64,8 @@ public class PresetsPage extends BasePage {
@Override
public void render(int x, int z, float ticks) {
super.active = !nameInput.getValue().isEmpty();
// only render as active if the text field is not empty
super.active = nameInput.isValid();
super.render(x, z, ticks);
}
@ -79,6 +85,13 @@ public class PresetsPage extends BasePage {
});
right.scrollPane.addButton(new TerraButton("Load") {
@Override
public void render(int x, int z, float ticks) {
super.active = hasSelectedPreset();
super.render(x, z, ticks);
}
@Override
public void onClick(double x, double y) {
super.onClick(x, y);
@ -87,6 +100,13 @@ public class PresetsPage extends BasePage {
});
right.scrollPane.addButton(new TerraButton("Save") {
@Override
public void render(int x, int z, float ticks) {
super.active = hasSelectedPreset();
super.render(x, z, ticks);
}
@Override
public void onClick(double x, double y) {
super.onClick(x, y);
@ -104,7 +124,38 @@ public class PresetsPage extends BasePage {
}
});
right.scrollPane.addButton(new TerraButton("Reset") {
@Override
public void render(int x, int z, float ticks) {
super.active = hasSelectedPreset();
super.render(x, z, ticks);
}
@Override
public void onClick(double x, double y) {
super.onClick(x, y);
getSelected().ifPresent(preset -> {
// create new preset with the same name but default settings
Preset reset = new Preset(preset.getName(), new TerraSettings());
// replaces by name
manager.add(reset);
// update the ui
rebuildPresetList();
});
}
});
right.scrollPane.addButton(new TerraButton("Delete") {
@Override
public void render(int x, int z, float ticks) {
super.active = hasSelectedPreset();
super.render(x, z, ticks);
}
@Override
public void onClick(double x, double y) {
super.onClick(x, y);
@ -117,6 +168,10 @@ public class PresetsPage extends BasePage {
});
}
private boolean hasSelectedPreset() {
return getColumn(0).scrollPane.getSelected() != null;
}
private void load(Preset preset) {
instance.sync(preset.getSettings());

View File

@ -1,7 +1,8 @@
{
"biomes": [
"minecraft:jungle_edge",
"minecraft:modified_jungle_edge"
"minecraft:modified_jungle_edge",
"terraforged:stone_forest"
],
"match": [
[