mo deserts

This commit is contained in:
dags- 2020-06-20 17:41:02 +01:00
parent 9808bf093d
commit f0d4108477
21 changed files with 63 additions and 53 deletions

View File

@ -26,6 +26,7 @@
package com.terraforged;
import com.terraforged.api.material.WGTags;
import com.terraforged.chunk.settings.SettingsHelper;
import com.terraforged.command.TerraCommand;
import com.terraforged.config.ConfigManager;
import com.terraforged.data.DataGen;
@ -35,7 +36,6 @@ import com.terraforged.feature.feature.BushFeature;
import com.terraforged.feature.feature.DiskFeature;
import com.terraforged.feature.feature.FreezeLayer;
import com.terraforged.fm.template.TemplateManager;
import com.terraforged.chunk.settings.SettingsHelper;
import com.terraforged.util.DataPackFinder;
import com.terraforged.util.Environment;
import net.minecraft.world.biome.Biomes;

View File

@ -30,11 +30,11 @@ import com.terraforged.chunk.ChunkGeneratorFactory;
import com.terraforged.chunk.TerraChunkGenerator;
import com.terraforged.chunk.TerraContext;
import com.terraforged.chunk.TerraGenSettings;
import com.terraforged.chunk.test.TestChunkGenerator;
import com.terraforged.gui.SettingsScreen;
import com.terraforged.chunk.settings.DimesionSettings;
import com.terraforged.chunk.settings.SettingsHelper;
import com.terraforged.chunk.settings.TerraSettings;
import com.terraforged.chunk.test.TestChunkGenerator;
import com.terraforged.gui.SettingsScreen;
import com.terraforged.util.Environment;
import com.terraforged.util.nbt.NBTHelper;
import com.terraforged.world.terrain.Terrains;

View File

@ -36,6 +36,10 @@ public interface BiomeModifier extends Comparable<BiomeModifier> {
Biome modify(Biome in, Cell cell, int x, int z);
default boolean exitEarly() {
return false;
}
@Override
default int compareTo(BiomeModifier other) {
// reverse order

View File

@ -48,8 +48,7 @@ public class BiomeModifierManager implements BiomeModifier, ModifierManager {
desertBiomes = new DesertBiomes(context.materials, biomes.getAllBiomes(BiomeType.DESERT));
List<BiomeModifier> modifiers = new ArrayList<>();
modifiers.add(new CoastModifier(biomes, context));
modifiers.add(new DesertColorModifier(context, desertBiomes));
modifiers.add(new SandBiomeModifier(context));
modifiers.add(new DesertColorModifier(desertBiomes));
modifiers.add(new BeachModifier(biomes, context));
Collections.sort(modifiers);
this.biomeModifiers = modifiers;
@ -84,6 +83,9 @@ public class BiomeModifierManager implements BiomeModifier, ModifierManager {
for (BiomeModifier modifier : biomeModifiers) {
if (modifier.test(biome)) {
biome = modifier.modify(biome, cell, x, z);
if (modifier.exitEarly()) {
return biome;
}
}
}
return biome;

View File

@ -28,23 +28,19 @@ package com.terraforged.biome.modifier;
import com.terraforged.api.biome.modifier.BiomeModifier;
import com.terraforged.biome.provider.DesertBiomes;
import com.terraforged.core.cell.Cell;
import com.terraforged.n2d.Module;
import com.terraforged.n2d.Source;
import com.terraforged.world.GeneratorContext;
import com.terraforged.world.climate.Climate;
import net.minecraft.world.biome.Biome;
public class DesertColorModifier implements BiomeModifier {
private final Module noise;
private final Climate climate;
private final DesertBiomes biomes;
public DesertColorModifier(GeneratorContext context, DesertBiomes biomes) {
int scale = context.settings.terrain.general.terrainRegionSize;
public DesertColorModifier(DesertBiomes biomes) {
this.biomes = biomes;
this.climate = context.factory.getClimate();
this.noise = Source.cell(context.seed.next(), scale * 3).warp(context.seed.next(), scale / 2, 1, scale / 4F);
}
@Override
public boolean exitEarly() {
return true;
}
@Override
@ -54,20 +50,19 @@ public class DesertColorModifier implements BiomeModifier {
@Override
public boolean test(Biome biome) {
return biome.getCategory() == Biome.Category.DESERT;
return biome.getCategory() == Biome.Category.DESERT
|| biome.getCategory() == Biome.Category.MESA
|| biomes.isDesert(biome);
}
@Override
public Biome modify(Biome in, Cell cell, int x, int z) {
float px = x + climate.getOffsetX(x, z, 12);
float pz = z + climate.getOffsetZ(x, z, 12);
float type = noise.getValue(px, pz);
if (biomes.isRedDesert(in)) {
if (type <= 0.5F) {
if (cell.macroNoise <= 0.5F) {
return biomes.getWhiteDesert(cell.biome);
}
} else {
if (type > 0.5F) {
if (cell.macroNoise > 0.5F) {
return biomes.getRedDesert(cell.biome);
}
}

View File

@ -50,6 +50,7 @@ public class DesertBiomes {
private final Set<Biome> reds;
private final Set<Biome> whites;
private final Set<Biome> deserts;
private final List<Biome> redSand;
private final List<Biome> whiteSand;
private final LayerManager layerManager;
@ -76,6 +77,7 @@ public class DesertBiomes {
this.layerManager = materials.getLayerManager();
this.whiteSand = new ArrayList<>(white);
this.redSand = new ArrayList<>(red);
this.deserts = new HashSet<>(deserts);
this.whites = new HashSet<>(white);
this.reds = new HashSet<>(red);
this.whiteSand.sort(Comparator.comparing(BiomeHelper::getId));
@ -83,6 +85,9 @@ public class DesertBiomes {
this.maxRedIndex = red.size() - 1;
this.maxWhiteIndex = white.size() - 1;
}
public boolean isDesert(Biome biome) {
return deserts.contains(biome);
}
public boolean isRedDesert(Biome biome) {
return reds.contains(biome);

View File

@ -11,17 +11,21 @@ import net.minecraft.block.Blocks;
public class DesertSurface implements Surface {
private final float min;
private final float level;
private final Module noise;
private final BlockState sandstone = States.SANDSTONE.get();
private final BlockState low = Blocks.TERRACOTTA.delegate.get().getDefaultState();
private final BlockState mid = Blocks.ORANGE_TERRACOTTA.delegate.get().getDefaultState();
private final BlockState high = Blocks.BROWN_TERRACOTTA.delegate.get().getDefaultState();
public DesertSurface(GeneratorContext context) {
min = context.levels.ground(10);
level = context.levels.ground(40);
noise = Source.perlin(context.seed.next(), 10, 1)
.scale(context.levels.scale(10));
noise = Source.perlin(context.seed.next(), 8, 1)
.scale(context.levels.scale(16));
}
@Override
@ -30,15 +34,22 @@ public class DesertSurface implements Surface {
return;
}
if (ctx.cell.steepness > 0.3 || ctx.cell.value + noise.getValue(x, z) > level) {
BlockState state = States.SANDSTONE.get();
if (ctx.cell.value < min) {
return;
}
if (ctx.cell.value > level) {
if (ctx.cell.steepness > 0.85) {
float value = ctx.cell.value + noise.getValue(x, z);
if (ctx.cell.steepness > 0.3 || value > level) {
BlockState state = sandstone;
if (value > level) {
if (ctx.cell.steepness > 0.975) {
state = low;
} else if (ctx.cell.steepness > 0.85) {
state = high;
} else if (ctx.cell.steepness > 0.75) {
state = mid;
} else if (ctx.cell.steepness > 0.625) {
} else if (ctx.cell.steepness > 0.65) {
state = low;
}
}

View File

@ -28,8 +28,8 @@ package com.terraforged.biome.surface;
import com.terraforged.api.chunk.surface.Surface;
import com.terraforged.api.chunk.surface.SurfaceContext;
import com.terraforged.api.material.layer.LayerMaterial;
import com.terraforged.biome.provider.TerraBiomeProvider;
import com.terraforged.biome.provider.DesertBiomes;
import com.terraforged.biome.provider.TerraBiomeProvider;
import com.terraforged.chunk.TerraContext;
import com.terraforged.core.cell.Cell;
import com.terraforged.n2d.Module;

View File

@ -38,8 +38,8 @@ import com.terraforged.chunk.generator.SurfaceGenerator;
import com.terraforged.chunk.generator.TerrainCarver;
import com.terraforged.chunk.generator.TerrainGenerator;
import com.terraforged.core.cell.Cell;
import com.terraforged.core.tile.Tile;
import com.terraforged.core.tile.Size;
import com.terraforged.core.tile.Tile;
import com.terraforged.core.tile.chunk.ChunkReader;
import com.terraforged.core.tile.gen.TileCache;
import com.terraforged.feature.BlockDataManager;

View File

@ -29,12 +29,12 @@ import com.electronwill.nightconfig.core.CommentedConfig;
import com.terraforged.api.chunk.column.DecoratorContext;
import com.terraforged.api.chunk.surface.ChunkSurfaceBuffer;
import com.terraforged.api.chunk.surface.SurfaceContext;
import com.terraforged.chunk.settings.TerraSettings;
import com.terraforged.config.PerfDefaults;
import com.terraforged.core.concurrent.thread.ThreadPools;
import com.terraforged.core.tile.gen.TileCache;
import com.terraforged.core.tile.gen.TileGenerator;
import com.terraforged.material.Materials;
import com.terraforged.chunk.settings.TerraSettings;
import com.terraforged.world.GeneratorContext;
import com.terraforged.world.WorldGeneratorFactory;
import com.terraforged.world.heightmap.Heightmap;

View File

@ -68,14 +68,7 @@ public class TerraContainer extends BiomeContainer {
return (TerraContainer) biomes;
}
TerraContainer container;
if (biomes == null) {
// create new container based on the provided ChunkReader
container = TerraContainer.create(reader, biomeProvider);
} else {
// converts an existing non-tf biome container into one that TerraForged can use
container = TerraContainer.convert(chunk.getPos(), biomes, biomeProvider);
}
TerraContainer container = TerraContainer.create(reader, biomeProvider);
// replace/set the primer's biomes
((ChunkPrimer) chunk).func_225548_a_(container);

View File

@ -35,6 +35,7 @@ import com.terraforged.Log;
import com.terraforged.biome.provider.TerraBiomeProvider;
import com.terraforged.chunk.TerraChunkGenerator;
import com.terraforged.chunk.TerraContext;
import com.terraforged.chunk.settings.SettingsHelper;
import com.terraforged.command.arg.BiomeArgType;
import com.terraforged.command.arg.TerrainArgType;
import com.terraforged.command.search.BiomeSearchTask;
@ -44,7 +45,6 @@ import com.terraforged.command.search.TerrainSearchTask;
import com.terraforged.core.cell.Cell;
import com.terraforged.core.concurrent.Resource;
import com.terraforged.data.DataGen;
import com.terraforged.chunk.settings.SettingsHelper;
import com.terraforged.world.WorldGenerator;
import com.terraforged.world.terrain.Terrain;
import com.terraforged.world.terrain.Terrains;

View File

@ -1,8 +1,8 @@
package com.terraforged.data;
import com.terraforged.chunk.settings.TerraSettings;
import com.terraforged.core.util.NameUtil;
import com.terraforged.gui.preview2.PreviewSettings;
import com.terraforged.chunk.settings.TerraSettings;
import com.terraforged.util.nbt.NBTHelper;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT;

View File

@ -25,6 +25,8 @@
package com.terraforged.gui;
import com.terraforged.chunk.settings.SettingsHelper;
import com.terraforged.chunk.settings.TerraSettings;
import com.terraforged.gui.element.TerraLabel;
import com.terraforged.gui.page.Page;
import com.terraforged.gui.page.PresetsPage;
@ -32,8 +34,6 @@ import com.terraforged.gui.page.SimplePage;
import com.terraforged.gui.page.SimplePreviewPage;
import com.terraforged.gui.page.WorldPage;
import com.terraforged.gui.preview2.PreviewPage;
import com.terraforged.chunk.settings.SettingsHelper;
import com.terraforged.chunk.settings.TerraSettings;
import com.terraforged.util.nbt.NBTHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.IGuiEventListener;

View File

@ -1,7 +1,7 @@
package com.terraforged.gui.page;
import com.terraforged.gui.OverlayScreen;
import com.terraforged.chunk.settings.TerraSettings;
import com.terraforged.gui.OverlayScreen;
import com.terraforged.util.nbt.NBTHelper;
import net.minecraft.nbt.CompoundNBT;

View File

@ -1,7 +1,7 @@
package com.terraforged.gui.page;
import com.terraforged.gui.OverlayScreen;
import com.terraforged.chunk.settings.TerraSettings;
import com.terraforged.gui.OverlayScreen;
import java.util.function.Consumer;

View File

@ -26,9 +26,9 @@
package com.terraforged.gui.page;
import com.terraforged.TerraWorld;
import com.terraforged.chunk.settings.TerraSettings;
import com.terraforged.gui.OverlayScreen;
import com.terraforged.gui.element.TerraTextInput;
import com.terraforged.chunk.settings.TerraSettings;
import com.terraforged.util.nbt.NBTHelper;
import net.minecraft.client.gui.widget.Widget;
import net.minecraft.nbt.CompoundNBT;

View File

@ -30,10 +30,10 @@ import com.mojang.blaze3d.systems.RenderSystem;
import com.terraforged.core.cell.Cell;
import com.terraforged.core.concurrent.cache.CacheEntry;
import com.terraforged.core.concurrent.thread.ThreadPools;
import com.terraforged.core.tile.Tile;
import com.terraforged.core.tile.Size;
import com.terraforged.core.tile.gen.TileGenerator;
import com.terraforged.core.settings.Settings;
import com.terraforged.core.tile.Size;
import com.terraforged.core.tile.Tile;
import com.terraforged.core.tile.gen.TileGenerator;
import com.terraforged.n2d.util.NoiseUtil;
import com.terraforged.util.nbt.NBTHelper;
import com.terraforged.world.GeneratorContext;

View File

@ -25,10 +25,10 @@
package com.terraforged.gui.preview;
import com.terraforged.chunk.settings.TerraSettings;
import com.terraforged.gui.OverlayScreen;
import com.terraforged.gui.element.TerraButton;
import com.terraforged.gui.page.UpdatablePage;
import com.terraforged.chunk.settings.TerraSettings;
import com.terraforged.util.nbt.NBTHelper;
import net.minecraft.nbt.CompoundNBT;

View File

@ -1,13 +1,13 @@
package com.terraforged.gui.preview2;
import com.mojang.blaze3d.systems.RenderSystem;
import com.terraforged.chunk.settings.TerraSettings;
import com.terraforged.core.concurrent.thread.ThreadPool;
import com.terraforged.core.concurrent.thread.ThreadPools;
import com.terraforged.core.tile.gen.TileGenerator;
import com.terraforged.core.render.RenderAPI;
import com.terraforged.core.render.RenderSettings;
import com.terraforged.core.render.RenderWorld;
import com.terraforged.chunk.settings.TerraSettings;
import com.terraforged.core.tile.gen.TileGenerator;
import com.terraforged.world.GeneratorContext;
import com.terraforged.world.continent.MutableVeci;
import com.terraforged.world.continent.SpawnType;

View File

@ -1,9 +1,9 @@
package com.terraforged.gui.preview2;
import com.terraforged.chunk.settings.TerraSettings;
import com.terraforged.gui.OverlayScreen;
import com.terraforged.gui.element.TerraButton;
import com.terraforged.gui.page.UpdatablePage;
import com.terraforged.chunk.settings.TerraSettings;
import com.terraforged.util.nbt.NBTHelper;
import net.minecraft.nbt.CompoundNBT;