- refactored/renamed classes
- pool cell/chunk arrays
This commit is contained in:
parent
58286d4381
commit
904580ef38
2
Engine
2
Engine
@ -1 +1 @@
|
|||||||
Subproject commit 637b43efb49d4aabe5332118caf8d72be1339a49
|
Subproject commit 7f617d303c09d52d4242379ef87bc4b679d8fcea
|
@ -37,7 +37,7 @@ import com.terraforged.settings.SettingsHelper;
|
|||||||
import com.terraforged.settings.TerraSettings;
|
import com.terraforged.settings.TerraSettings;
|
||||||
import com.terraforged.util.Environment;
|
import com.terraforged.util.Environment;
|
||||||
import com.terraforged.util.nbt.NBTHelper;
|
import com.terraforged.util.nbt.NBTHelper;
|
||||||
import com.terraforged.world.terrain.TerrainTypes;
|
import com.terraforged.world.terrain.Terrains;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.screen.CreateWorldScreen;
|
import net.minecraft.client.gui.screen.CreateWorldScreen;
|
||||||
import net.minecraft.world.IWorld;
|
import net.minecraft.world.IWorld;
|
||||||
@ -76,7 +76,7 @@ public class TerraWorld extends WorldType {
|
|||||||
settings.world.seed = world.getSeed();
|
settings.world.seed = world.getSeed();
|
||||||
settings.dimensions.dimensions.apply(world.getWorldInfo());
|
settings.dimensions.dimensions.apply(world.getWorldInfo());
|
||||||
|
|
||||||
TerrainTypes terrains = TerrainTypes.create(settings);
|
Terrains terrains = Terrains.create(settings);
|
||||||
|
|
||||||
OverworldGenSettings genSettings = new TerraGenSettings(settings.structures);
|
OverworldGenSettings genSettings = new TerraGenSettings(settings.structures);
|
||||||
OverworldBiomeProviderSettings biomeSettings = new OverworldBiomeProviderSettings(world.getWorldInfo());
|
OverworldBiomeProviderSettings biomeSettings = new OverworldBiomeProviderSettings(world.getWorldInfo());
|
||||||
|
@ -31,7 +31,7 @@ import com.terraforged.core.concurrent.Resource;
|
|||||||
import com.terraforged.world.climate.Climate;
|
import com.terraforged.world.climate.Climate;
|
||||||
import com.terraforged.world.geology.DepthBuffer;
|
import com.terraforged.world.geology.DepthBuffer;
|
||||||
import com.terraforged.world.heightmap.Levels;
|
import com.terraforged.world.heightmap.Levels;
|
||||||
import com.terraforged.world.terrain.TerrainTypes;
|
import com.terraforged.world.terrain.Terrains;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
import net.minecraft.world.chunk.IChunk;
|
import net.minecraft.world.chunk.IChunk;
|
||||||
@ -40,18 +40,18 @@ public class DecoratorContext extends ChunkContext implements AutoCloseable {
|
|||||||
|
|
||||||
public final Levels levels;
|
public final Levels levels;
|
||||||
public final Climate climate;
|
public final Climate climate;
|
||||||
public final TerrainTypes terrains;
|
public final Terrains terrains;
|
||||||
public final Resource<DepthBuffer> depthBuffer;
|
public final Resource<DepthBuffer> depthBuffer;
|
||||||
public final BlockPos.Mutable pos = new BlockPos.Mutable();
|
public final BlockPos.Mutable pos = new BlockPos.Mutable();
|
||||||
|
|
||||||
public Biome biome;
|
public Biome biome;
|
||||||
public Cell cell;
|
public Cell cell;
|
||||||
|
|
||||||
public DecoratorContext(IChunk chunk, Levels levels, TerrainTypes terrain, Climate climate) {
|
public DecoratorContext(IChunk chunk, Levels levels, Terrains terrain, Climate climate) {
|
||||||
this(chunk, levels, terrain, climate, true);
|
this(chunk, levels, terrain, climate, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DecoratorContext(IChunk chunk, Levels levels, TerrainTypes terrain, Climate climate, boolean depthBuffer) {
|
public DecoratorContext(IChunk chunk, Levels levels, Terrains terrain, Climate climate, boolean depthBuffer) {
|
||||||
super(chunk);
|
super(chunk);
|
||||||
this.levels = levels;
|
this.levels = levels;
|
||||||
this.climate = climate;
|
this.climate = climate;
|
||||||
|
@ -28,7 +28,7 @@ package com.terraforged.api.chunk.surface;
|
|||||||
import com.terraforged.api.chunk.column.DecoratorContext;
|
import com.terraforged.api.chunk.column.DecoratorContext;
|
||||||
import com.terraforged.world.climate.Climate;
|
import com.terraforged.world.climate.Climate;
|
||||||
import com.terraforged.world.heightmap.Levels;
|
import com.terraforged.world.heightmap.Levels;
|
||||||
import com.terraforged.world.terrain.TerrainTypes;
|
import com.terraforged.world.terrain.Terrains;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.world.gen.GenerationSettings;
|
import net.minecraft.world.gen.GenerationSettings;
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ public class SurfaceContext extends DecoratorContext implements AutoCloseable {
|
|||||||
|
|
||||||
public double noise;
|
public double noise;
|
||||||
|
|
||||||
public SurfaceContext(ChunkSurfaceBuffer buffer, Levels levels, TerrainTypes terrain, Climate climate, GenerationSettings settings, long seed) {
|
public SurfaceContext(ChunkSurfaceBuffer buffer, Levels levels, Terrains terrain, Climate climate, GenerationSettings settings, long seed) {
|
||||||
super(buffer, levels, terrain, climate);
|
super(buffer, levels, terrain, climate);
|
||||||
this.solid = settings.getDefaultBlock();
|
this.solid = settings.getDefaultBlock();
|
||||||
this.fluid = settings.getDefaultFluid();
|
this.fluid = settings.getDefaultFluid();
|
||||||
|
@ -30,13 +30,13 @@ import com.terraforged.biome.map.BiomeMap;
|
|||||||
import com.terraforged.chunk.TerraContext;
|
import com.terraforged.chunk.TerraContext;
|
||||||
import com.terraforged.core.cell.Cell;
|
import com.terraforged.core.cell.Cell;
|
||||||
import com.terraforged.world.heightmap.Levels;
|
import com.terraforged.world.heightmap.Levels;
|
||||||
import com.terraforged.world.terrain.TerrainTypes;
|
import com.terraforged.world.terrain.Terrains;
|
||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
|
|
||||||
public class BeachModifier implements BiomeModifier {
|
public class BeachModifier implements BiomeModifier {
|
||||||
|
|
||||||
private final Levels levels;
|
private final Levels levels;
|
||||||
private final TerrainTypes terrain;
|
private final Terrains terrain;
|
||||||
private final BiomeMap biomeMap;
|
private final BiomeMap biomeMap;
|
||||||
|
|
||||||
public BeachModifier(BiomeMap biomeMap, TerraContext context) {
|
public BeachModifier(BiomeMap biomeMap, TerraContext context) {
|
||||||
@ -57,10 +57,10 @@ public class BeachModifier implements BiomeModifier {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Biome modify(Biome in, Cell cell, int x, int z) {
|
public Biome modify(Biome in, Cell cell, int x, int z) {
|
||||||
if (cell.terrainType == terrain.beach) {
|
if (cell.terrain == terrain.beach) {
|
||||||
return biomeMap.getBeach(cell.temperature, cell.moisture, cell.biome);
|
return biomeMap.getBeach(cell.temperature, cell.moisture, cell.biome);
|
||||||
}
|
}
|
||||||
if (cell.terrainType == terrain.coast && cell.value <= levels.water) {
|
if (cell.terrain == terrain.coast && cell.value <= levels.water) {
|
||||||
return biomeMap.getOcean(cell.temperature, cell.moisture, cell.biome);
|
return biomeMap.getOcean(cell.temperature, cell.moisture, cell.biome);
|
||||||
}
|
}
|
||||||
return in;
|
return in;
|
||||||
|
@ -32,6 +32,8 @@ import com.terraforged.biome.provider.DesertBiomes;
|
|||||||
import com.terraforged.chunk.TerraContext;
|
import com.terraforged.chunk.TerraContext;
|
||||||
import com.terraforged.core.cell.Cell;
|
import com.terraforged.core.cell.Cell;
|
||||||
import com.terraforged.world.biome.BiomeType;
|
import com.terraforged.world.biome.BiomeType;
|
||||||
|
import com.terraforged.world.terrain.ITerrain;
|
||||||
|
import com.terraforged.world.terrain.TerrainType;
|
||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -53,16 +55,20 @@ public class BiomeModifierManager implements BiomeModifier, ModifierManager {
|
|||||||
this.biomeModifiers = modifiers;
|
this.biomeModifiers = modifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public boolean hasModifiers(ITerrain type) {
|
||||||
public void register(BiomeModifier modifier) {
|
return type.isOverground();
|
||||||
biomeModifiers.add(modifier);
|
|
||||||
Collections.sort(biomeModifiers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DesertBiomes getDesertBiomes() {
|
public DesertBiomes getDesertBiomes() {
|
||||||
return desertBiomes;
|
return desertBiomes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void register(BiomeModifier modifier) {
|
||||||
|
biomeModifiers.add(modifier);
|
||||||
|
Collections.sort(biomeModifiers);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int priority() {
|
public int priority() {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -0,0 +1,58 @@
|
|||||||
|
package com.terraforged.biome.provider;
|
||||||
|
|
||||||
|
import com.terraforged.core.cell.Cell;
|
||||||
|
import com.terraforged.world.heightmap.Levels;
|
||||||
|
import com.terraforged.world.terrain.TerrainType;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.biome.Biome;
|
||||||
|
|
||||||
|
public class BiomeAccess {
|
||||||
|
|
||||||
|
private static final BiomeAccessor DEEP_OCEAN = (m, c) -> m.getDeepOcean(c.temperature, c.moisture, c.biome);
|
||||||
|
private static final BiomeAccessor SHALLOW_OCEAN = (m, c) -> m.getOcean(c.temperature, c.moisture, c.biome);
|
||||||
|
private static final BiomeAccessor LAKE = (m, c) -> m.getLake(c.temperature, c.moisture, c.biome);
|
||||||
|
private static final BiomeAccessor WETLAND = (m, c) -> m.getWetland(c.temperature, c.moisture, c.biome);
|
||||||
|
private static final BiomeAccessor NORMAL = (m, c) -> m.getBiome(c.biomeType, c.temperature, c.moisture, c.biome);
|
||||||
|
private static final BiomeAccessor RIVER = (m, c) -> {
|
||||||
|
Biome biome = m.getBiome(c.biomeType, c.temperature, c.moisture, c.biome);
|
||||||
|
if (overridesRiver(biome)) {
|
||||||
|
return biome;
|
||||||
|
}
|
||||||
|
return m.getRiver(c.temperature, c.moisture, c.biome);
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final BiomeAccessor[] accessors = createAccessorArray();
|
||||||
|
|
||||||
|
private final Levels levels;
|
||||||
|
|
||||||
|
public BiomeAccess(Levels levels) {
|
||||||
|
this.levels = levels;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BiomeAccessor getAccessor(Cell cell) {
|
||||||
|
TerrainType type = cell.terrain.getType();
|
||||||
|
if (type.isSubmerged() && cell.value > levels.water) {
|
||||||
|
return NORMAL;
|
||||||
|
}
|
||||||
|
return accessors[cell.terrain.getType().ordinal()];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BiomeAccessor[] createAccessorArray() {
|
||||||
|
BiomeAccessor[] accessors = new BiomeAccessor[TerrainType.values().length];
|
||||||
|
accessors[TerrainType.SHALLOW_OCEAN.ordinal()] = SHALLOW_OCEAN;
|
||||||
|
accessors[TerrainType.DEEP_OCEAN.ordinal()] = DEEP_OCEAN;
|
||||||
|
accessors[TerrainType.WETLAND.ordinal()] = WETLAND;
|
||||||
|
accessors[TerrainType.RIVER.ordinal()] = RIVER;
|
||||||
|
accessors[TerrainType.LAKE.ordinal()] = LAKE;
|
||||||
|
for (TerrainType type : TerrainType.values()) {
|
||||||
|
if (accessors[type.ordinal()] == null) {
|
||||||
|
accessors[type.ordinal()] = NORMAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return accessors;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean overridesRiver(Biome biome) {
|
||||||
|
return biome.getCategory() == Biome.Category.SWAMP || biome.getCategory() == Biome.Category.JUNGLE;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.terraforged.biome.provider;
|
||||||
|
|
||||||
|
import com.terraforged.biome.map.BiomeMap;
|
||||||
|
import com.terraforged.core.cell.Cell;
|
||||||
|
import net.minecraft.world.biome.Biome;
|
||||||
|
|
||||||
|
public interface BiomeAccessor {
|
||||||
|
|
||||||
|
Biome getBiome(BiomeMap map, Cell cell);
|
||||||
|
}
|
@ -52,6 +52,7 @@ import java.util.Set;
|
|||||||
public class BiomeProvider extends AbstractBiomeProvider {
|
public class BiomeProvider extends AbstractBiomeProvider {
|
||||||
|
|
||||||
private final BiomeMap biomeMap;
|
private final BiomeMap biomeMap;
|
||||||
|
private final BiomeAccess biomeAccess;
|
||||||
private final TerraContext context;
|
private final TerraContext context;
|
||||||
private final WorldLookup worldLookup;
|
private final WorldLookup worldLookup;
|
||||||
private final BiomeModifierManager modifierManager;
|
private final BiomeModifierManager modifierManager;
|
||||||
@ -60,6 +61,7 @@ public class BiomeProvider extends AbstractBiomeProvider {
|
|||||||
public BiomeProvider(TerraContext context) {
|
public BiomeProvider(TerraContext context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.biomeMap = BiomeHelper.getDefaultBiomeMap();
|
this.biomeMap = BiomeHelper.getDefaultBiomeMap();
|
||||||
|
this.biomeAccess = new BiomeAccess(context.levels);
|
||||||
this.worldLookup = new WorldLookup(context.factory, context);
|
this.worldLookup = new WorldLookup(context.factory, context);
|
||||||
this.modifierManager = SetupHooks.setup(new BiomeModifierManager(context, biomeMap), context.copy());
|
this.modifierManager = SetupHooks.setup(new BiomeModifierManager(context, biomeMap), context.copy());
|
||||||
}
|
}
|
||||||
@ -153,39 +155,16 @@ public class BiomeProvider extends AbstractBiomeProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Biome getBiome(Cell cell, int x, int z) {
|
public Biome getBiome(Cell cell, int x, int z) {
|
||||||
if (cell.terrainType.isWetland()) {
|
BiomeAccessor accessor = biomeAccess.getAccessor(cell);
|
||||||
return biomeMap.getWetland(cell.temperature, cell.moisture, cell.biome);
|
Biome biome = accessor.getBiome(biomeMap, cell);
|
||||||
|
if (modifierManager.hasModifiers(cell.terrain)) {
|
||||||
|
return modifierManager.modify(biome, cell, x, z);
|
||||||
}
|
}
|
||||||
|
return biome;
|
||||||
if (cell.value > context.levels.water) {
|
|
||||||
return getModifierManager().modify(biomeMap.getBiome(cell), cell, x, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cell.terrainType.isLake()) {
|
|
||||||
return biomeMap.getLake(cell.temperature, cell.moisture, cell.biome);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cell.terrainType.isRiver()) {
|
|
||||||
Biome biome = biomeMap.getBiome(cell);
|
|
||||||
if (overridesRiver(biome)) {
|
|
||||||
return biome;
|
|
||||||
}
|
|
||||||
return biomeMap.getRiver(cell.temperature, cell.moisture, cell.biome);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cell.terrainType.isShallowOcean()) {
|
|
||||||
return biomeMap.getOcean(cell.temperature, cell.moisture, cell.biome);
|
|
||||||
}
|
|
||||||
|
|
||||||
return biomeMap.getDeepOcean(cell.temperature, cell.moisture, cell.biome);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSpawnAt(Cell cell) {
|
public boolean canSpawnAt(Cell cell) {
|
||||||
return cell.terrainType != context.terrain.ocean && cell.terrainType != context.terrain.deepOcean;
|
return cell.terrain != context.terrain.ocean && cell.terrain != context.terrain.deepOcean;
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean overridesRiver(Biome biome) {
|
|
||||||
return biome.getCategory() == Biome.Category.SWAMP || biome.getCategory() == Biome.Category.JUNGLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TerraContainer getBiomeContainer(TerraChunkGenerator generator, IChunk chunk) {
|
public static TerraContainer getBiomeContainer(TerraChunkGenerator generator, IChunk chunk) {
|
||||||
|
@ -33,7 +33,7 @@ import com.terraforged.biome.provider.DesertBiomes;
|
|||||||
import com.terraforged.chunk.TerraContext;
|
import com.terraforged.chunk.TerraContext;
|
||||||
import com.terraforged.core.cell.Cell;
|
import com.terraforged.core.cell.Cell;
|
||||||
import com.terraforged.world.heightmap.Levels;
|
import com.terraforged.world.heightmap.Levels;
|
||||||
import com.terraforged.world.terrain.TerrainTypes;
|
import com.terraforged.world.terrain.Terrains;
|
||||||
import me.dags.noise.Module;
|
import me.dags.noise.Module;
|
||||||
import me.dags.noise.Source;
|
import me.dags.noise.Source;
|
||||||
import me.dags.noise.func.CellFunc;
|
import me.dags.noise.func.CellFunc;
|
||||||
@ -48,7 +48,7 @@ public class DunesSurface implements Surface {
|
|||||||
private final int maxHeight;
|
private final int maxHeight;
|
||||||
private final Levels levels;
|
private final Levels levels;
|
||||||
private final Module module;
|
private final Module module;
|
||||||
private final TerrainTypes terrains;
|
private final Terrains terrains;
|
||||||
private final DesertBiomes deserts;
|
private final DesertBiomes deserts;
|
||||||
private final BlockPos.Mutable pos = new BlockPos.Mutable();
|
private final BlockPos.Mutable pos = new BlockPos.Mutable();
|
||||||
|
|
||||||
|
@ -25,17 +25,11 @@
|
|||||||
|
|
||||||
package com.terraforged.chunk;
|
package com.terraforged.chunk;
|
||||||
|
|
||||||
import com.terraforged.Log;
|
|
||||||
import com.terraforged.api.chunk.column.ColumnDecorator;
|
import com.terraforged.api.chunk.column.ColumnDecorator;
|
||||||
import com.terraforged.api.chunk.surface.SurfaceManager;
|
import com.terraforged.api.chunk.surface.SurfaceManager;
|
||||||
import com.terraforged.api.material.layer.LayerManager;
|
import com.terraforged.api.material.layer.LayerManager;
|
||||||
import com.terraforged.biome.provider.BiomeProvider;
|
import com.terraforged.biome.provider.BiomeProvider;
|
||||||
import com.terraforged.chunk.generator.BiomeGenerator;
|
import com.terraforged.chunk.generator.*;
|
||||||
import com.terraforged.chunk.generator.MobGenerator;
|
|
||||||
import com.terraforged.chunk.generator.StructureGenerator;
|
|
||||||
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.cell.Cell;
|
||||||
import com.terraforged.core.region.Size;
|
import com.terraforged.core.region.Size;
|
||||||
import com.terraforged.core.region.chunk.ChunkReader;
|
import com.terraforged.core.region.chunk.ChunkReader;
|
||||||
@ -46,7 +40,6 @@ import com.terraforged.fm.data.DataManager;
|
|||||||
import com.terraforged.fm.structure.StructureManager;
|
import com.terraforged.fm.structure.StructureManager;
|
||||||
import com.terraforged.material.Materials;
|
import com.terraforged.material.Materials;
|
||||||
import com.terraforged.material.geology.GeoManager;
|
import com.terraforged.material.geology.GeoManager;
|
||||||
import com.terraforged.util.Environment;
|
|
||||||
import com.terraforged.util.setup.SetupHooks;
|
import com.terraforged.util.setup.SetupHooks;
|
||||||
import net.minecraft.entity.EntityClassification;
|
import net.minecraft.entity.EntityClassification;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
@ -54,11 +47,7 @@ import net.minecraft.world.IWorld;
|
|||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
import net.minecraft.world.biome.BiomeManager;
|
import net.minecraft.world.biome.BiomeManager;
|
||||||
import net.minecraft.world.chunk.IChunk;
|
import net.minecraft.world.chunk.IChunk;
|
||||||
import net.minecraft.world.gen.ChunkGenerator;
|
import net.minecraft.world.gen.*;
|
||||||
import net.minecraft.world.gen.GenerationSettings;
|
|
||||||
import net.minecraft.world.gen.GenerationStage;
|
|
||||||
import net.minecraft.world.gen.Heightmap;
|
|
||||||
import net.minecraft.world.gen.WorldGenRegion;
|
|
||||||
import net.minecraft.world.gen.feature.template.TemplateManager;
|
import net.minecraft.world.gen.feature.template.TemplateManager;
|
||||||
import net.minecraft.world.server.ServerWorld;
|
import net.minecraft.world.server.ServerWorld;
|
||||||
|
|
||||||
@ -113,7 +102,6 @@ public class TerraChunkGenerator extends ChunkGenerator<GenerationSettings> {
|
|||||||
|
|
||||||
SetupHooks.setup(getLayerManager(), context.copy());
|
SetupHooks.setup(getLayerManager(), context.copy());
|
||||||
SetupHooks.setup(baseDecorators, postProcessors, context.copy());
|
SetupHooks.setup(baseDecorators, postProcessors, context.copy());
|
||||||
Log.info("Vanilla Biomes: {}", Environment.isVanillaBiomes());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -28,7 +28,7 @@ package com.terraforged.chunk;
|
|||||||
import com.terraforged.api.chunk.column.DecoratorContext;
|
import com.terraforged.api.chunk.column.DecoratorContext;
|
||||||
import com.terraforged.api.chunk.surface.ChunkSurfaceBuffer;
|
import com.terraforged.api.chunk.surface.ChunkSurfaceBuffer;
|
||||||
import com.terraforged.api.chunk.surface.SurfaceContext;
|
import com.terraforged.api.chunk.surface.SurfaceContext;
|
||||||
import com.terraforged.core.concurrent.pool.ThreadPools;
|
import com.terraforged.core.concurrent.thread.ThreadPools;
|
||||||
import com.terraforged.core.region.gen.RegionCache;
|
import com.terraforged.core.region.gen.RegionCache;
|
||||||
import com.terraforged.core.region.gen.RegionGenerator;
|
import com.terraforged.core.region.gen.RegionGenerator;
|
||||||
import com.terraforged.material.Materials;
|
import com.terraforged.material.Materials;
|
||||||
@ -36,7 +36,7 @@ import com.terraforged.settings.TerraSettings;
|
|||||||
import com.terraforged.world.GeneratorContext;
|
import com.terraforged.world.GeneratorContext;
|
||||||
import com.terraforged.world.WorldGeneratorFactory;
|
import com.terraforged.world.WorldGeneratorFactory;
|
||||||
import com.terraforged.world.heightmap.Heightmap;
|
import com.terraforged.world.heightmap.Heightmap;
|
||||||
import com.terraforged.world.terrain.TerrainTypes;
|
import com.terraforged.world.terrain.Terrains;
|
||||||
import net.minecraft.world.IWorld;
|
import net.minecraft.world.IWorld;
|
||||||
import net.minecraft.world.chunk.IChunk;
|
import net.minecraft.world.chunk.IChunk;
|
||||||
import net.minecraft.world.gen.GenerationSettings;
|
import net.minecraft.world.gen.GenerationSettings;
|
||||||
@ -56,7 +56,7 @@ public class TerraContext extends GeneratorContext {
|
|||||||
this.heightmap = factory.getHeightmap();
|
this.heightmap = factory.getHeightmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TerraContext(IWorld world, TerrainTypes terrain, TerraSettings settings) {
|
public TerraContext(IWorld world, Terrains terrain, TerraSettings settings) {
|
||||||
super(terrain, settings, TerraTerrainProvider::new, TerraContext::createCache);
|
super(terrain, settings, TerraTerrainProvider::new, TerraContext::createCache);
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.materials = new Materials();
|
this.materials = new Materials();
|
||||||
|
@ -36,7 +36,7 @@ public class ChunkPopulator implements ColumnDecorator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decorate(IChunk chunk, DecoratorContext context, int x, int y, int z) {
|
public void decorate(IChunk chunk, DecoratorContext context, int x, int y, int z) {
|
||||||
if (context.cell.terrainType == context.terrains.volcanoPipe && context.cell.riverMask > 0.25F) {
|
if (context.cell.terrain == context.terrains.volcanoPipe && context.cell.riverMask > 0.25F) {
|
||||||
int lavaStart = Math.max(context.levels.waterY + 10, y - 30);
|
int lavaStart = Math.max(context.levels.waterY + 10, y - 30);
|
||||||
int lavaEnd = Math.max(5, context.levels.waterY - 10);
|
int lavaEnd = Math.max(5, context.levels.waterY - 10);
|
||||||
fillDown(context, chunk, x, z, lavaStart, lavaEnd, States.LAVA.get());
|
fillDown(context, chunk, x, z, lavaStart, lavaEnd, States.LAVA.get());
|
||||||
|
@ -30,13 +30,13 @@ import com.terraforged.api.chunk.column.DecoratorContext;
|
|||||||
import com.terraforged.api.material.state.States;
|
import com.terraforged.api.material.state.States;
|
||||||
import com.terraforged.chunk.TerraContext;
|
import com.terraforged.chunk.TerraContext;
|
||||||
import com.terraforged.core.util.VariablePredicate;
|
import com.terraforged.core.util.VariablePredicate;
|
||||||
import com.terraforged.world.terrain.TerrainTypes;
|
import com.terraforged.world.terrain.Terrains;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.world.chunk.IChunk;
|
import net.minecraft.world.chunk.IChunk;
|
||||||
|
|
||||||
public class CoastDecorator implements ColumnDecorator {
|
public class CoastDecorator implements ColumnDecorator {
|
||||||
|
|
||||||
private final TerrainTypes terrains;
|
private final Terrains terrains;
|
||||||
private final BlockState sand;
|
private final BlockState sand;
|
||||||
private final BlockState gravel;
|
private final BlockState gravel;
|
||||||
private final VariablePredicate height;
|
private final VariablePredicate height;
|
||||||
@ -59,7 +59,7 @@ public class CoastDecorator implements ColumnDecorator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decorate(IChunk chunk, DecoratorContext context, int x, int y, int z) {
|
public void decorate(IChunk chunk, DecoratorContext context, int x, int y, int z) {
|
||||||
if (context.cell.terrainType != terrains.beach) {
|
if (context.cell.terrain != terrains.beach) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ import com.terraforged.api.chunk.column.DecoratorContext;
|
|||||||
import com.terraforged.api.material.state.States;
|
import com.terraforged.api.material.state.States;
|
||||||
import com.terraforged.chunk.TerraContext;
|
import com.terraforged.chunk.TerraContext;
|
||||||
import com.terraforged.material.Materials;
|
import com.terraforged.material.Materials;
|
||||||
import com.terraforged.world.terrain.TerrainTypes;
|
import com.terraforged.world.terrain.Terrains;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
@ -61,7 +61,7 @@ public class ErosionDecorator implements ColumnDecorator {
|
|||||||
private final int seed2;
|
private final int seed2;
|
||||||
private final int seed3;
|
private final int seed3;
|
||||||
private final float minY;
|
private final float minY;
|
||||||
private final TerrainTypes terrain;
|
private final Terrains terrain;
|
||||||
private final Materials materials;
|
private final Materials materials;
|
||||||
|
|
||||||
public ErosionDecorator(TerraContext context) {
|
public ErosionDecorator(TerraContext context) {
|
||||||
@ -75,11 +75,11 @@ public class ErosionDecorator implements ColumnDecorator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decorate(IChunk chunk, DecoratorContext context, int x, int y, int z) {
|
public void decorate(IChunk chunk, DecoratorContext context, int x, int y, int z) {
|
||||||
if (context.cell.value < minY || context.cell.terrainType == terrain.river || context.cell.terrainType == terrain.riverBanks) {
|
if (context.cell.value < minY || context.cell.terrain == terrain.river || context.cell.terrain == terrain.riverBanks) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context.cell.terrainType == terrain.volcanoPipe) {
|
if (context.cell.terrain == terrain.volcanoPipe) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ public class SnowEroder extends ErosionDecorator {
|
|||||||
float var = -ColumnDecorator.getNoise(x, z, seed1, 16, 0);
|
float var = -ColumnDecorator.getNoise(x, z, seed1, 16, 0);
|
||||||
float hNoise = rand.getValue(x, z, seed2) * HEIGHT_MODIFIER;
|
float hNoise = rand.getValue(x, z, seed2) * HEIGHT_MODIFIER;
|
||||||
float sNoise = rand.getValue(x, z, seed3) * SLOPE_MODIFIER;
|
float sNoise = rand.getValue(x, z, seed3) * SLOPE_MODIFIER;
|
||||||
float vModifier = context.cell.terrainType == context.terrains.volcano ? 0.15F : 0F;
|
float vModifier = context.cell.terrain == context.terrains.volcano ? 0.15F : 0F;
|
||||||
float height = context.cell.value + var + hNoise + vModifier;
|
float height = context.cell.value + var + hNoise + vModifier;
|
||||||
float steepness = context.cell.steepness + var + sNoise + vModifier;
|
float steepness = context.cell.steepness + var + sNoise + vModifier;
|
||||||
if (snowErosion(x, z, steepness, height)) {
|
if (snowErosion(x, z, steepness, height)) {
|
||||||
|
@ -13,7 +13,7 @@ import com.terraforged.feature.TerrainHelper;
|
|||||||
import com.terraforged.util.Environment;
|
import com.terraforged.util.Environment;
|
||||||
import com.terraforged.world.climate.Climate;
|
import com.terraforged.world.climate.Climate;
|
||||||
import com.terraforged.world.heightmap.Levels;
|
import com.terraforged.world.heightmap.Levels;
|
||||||
import com.terraforged.world.terrain.TerrainTypes;
|
import com.terraforged.world.terrain.Terrains;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IWorld;
|
import net.minecraft.world.IWorld;
|
||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
@ -28,7 +28,7 @@ public class TerrainGenerator {
|
|||||||
|
|
||||||
private final Levels levels;
|
private final Levels levels;
|
||||||
private final Climate climate;
|
private final Climate climate;
|
||||||
private final TerrainTypes terrain;
|
private final Terrains terrain;
|
||||||
private final TerraChunkGenerator generator;
|
private final TerraChunkGenerator generator;
|
||||||
private final TerrainHelper terrainHelper;
|
private final TerrainHelper terrainHelper;
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package com.terraforged.chunk.test;
|
package com.terraforged.chunk.test;
|
||||||
|
|
||||||
import com.terraforged.world.terrain.Terrain;
|
import com.terraforged.world.terrain.Terrain;
|
||||||
import com.terraforged.world.terrain.TerrainTypes;
|
import com.terraforged.world.terrain.Terrains;
|
||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
import net.minecraft.world.biome.Biomes;
|
import net.minecraft.world.biome.Biomes;
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ public class Test {
|
|||||||
|
|
||||||
public static boolean fixedBiome = false;
|
public static boolean fixedBiome = false;
|
||||||
|
|
||||||
public static Terrain getTerrainType(TerrainTypes terrains) {
|
public static Terrain getTerrainType(Terrains terrains) {
|
||||||
return terrains.badlands;
|
return terrains.badlands;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,11 +3,11 @@ package com.terraforged.chunk.test;
|
|||||||
import com.terraforged.core.cell.Cell;
|
import com.terraforged.core.cell.Cell;
|
||||||
import com.terraforged.world.GeneratorContext;
|
import com.terraforged.world.GeneratorContext;
|
||||||
import com.terraforged.world.heightmap.WorldHeightmap;
|
import com.terraforged.world.heightmap.WorldHeightmap;
|
||||||
import com.terraforged.world.terrain.TerrainTypes;
|
import com.terraforged.world.terrain.Terrains;
|
||||||
|
|
||||||
public class TestHeightMap extends WorldHeightmap {
|
public class TestHeightMap extends WorldHeightmap {
|
||||||
|
|
||||||
private final TerrainTypes terrains;
|
private final Terrains terrains;
|
||||||
|
|
||||||
public TestHeightMap(GeneratorContext context) {
|
public TestHeightMap(GeneratorContext context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
@ -4,6 +4,7 @@ import com.terraforged.api.chunk.ChunkDelegate;
|
|||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.palette.PalettedContainer;
|
||||||
import net.minecraft.world.biome.BiomeContainer;
|
import net.minecraft.world.biome.BiomeContainer;
|
||||||
import net.minecraft.world.chunk.ChunkPrimer;
|
import net.minecraft.world.chunk.ChunkPrimer;
|
||||||
import net.minecraft.world.chunk.ChunkSection;
|
import net.minecraft.world.chunk.ChunkSection;
|
||||||
@ -63,6 +64,31 @@ public class FastChunk implements ChunkDelegate {
|
|||||||
return Blocks.VOID_AIR.getDefaultState();
|
return Blocks.VOID_AIR.getDefaultState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void fill(BlockState state) {
|
||||||
|
int surfaceMinY = 255;
|
||||||
|
for (int dz = 0; dz < 16; dz++) {
|
||||||
|
for (int dx = 0; dx < 16; dx++) {
|
||||||
|
int y = primer.getTopBlockY(Heightmap.Type.OCEAN_FLOOR_WG, dx, dz);
|
||||||
|
surfaceMinY = Math.min(surfaceMinY, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int topSection = (surfaceMinY >> 4);
|
||||||
|
for (int sectionIndex = 0; sectionIndex < topSection; sectionIndex++) {
|
||||||
|
ChunkSection section = primer.getSection(sectionIndex);
|
||||||
|
section.lock();
|
||||||
|
PalettedContainer<BlockState> container = section.getData();
|
||||||
|
for (int dy = 0; dy < 16; dy++) {
|
||||||
|
for (int dz = 0; dz < 16; dz++) {
|
||||||
|
for (int dx = 0; dx < 16; dx++) {
|
||||||
|
container.swap(dx, dy, dz, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
section.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setBiomes(BiomeContainer biomes) {
|
public void setBiomes(BiomeContainer biomes) {
|
||||||
primer.func_225548_a_(biomes);
|
primer.func_225548_a_(biomes);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ import com.terraforged.data.DataGen;
|
|||||||
import com.terraforged.settings.SettingsHelper;
|
import com.terraforged.settings.SettingsHelper;
|
||||||
import com.terraforged.world.WorldGenerator;
|
import com.terraforged.world.WorldGenerator;
|
||||||
import com.terraforged.world.terrain.Terrain;
|
import com.terraforged.world.terrain.Terrain;
|
||||||
import com.terraforged.world.terrain.TerrainTypes;
|
import com.terraforged.world.terrain.Terrains;
|
||||||
import net.minecraft.command.CommandSource;
|
import net.minecraft.command.CommandSource;
|
||||||
import net.minecraft.command.Commands;
|
import net.minecraft.command.Commands;
|
||||||
import net.minecraft.command.arguments.ArgumentSerializer;
|
import net.minecraft.command.arguments.ArgumentSerializer;
|
||||||
@ -129,7 +129,7 @@ public class TerraCommand {
|
|||||||
Cell cell = biomeProvider.lookupPos(pos.getX(), pos.getZ());
|
Cell cell = biomeProvider.lookupPos(pos.getX(), pos.getZ());
|
||||||
Biome biome = biomeProvider.getBiome(cell, pos.getX(), pos.getZ());
|
Biome biome = biomeProvider.getBiome(cell, pos.getX(), pos.getZ());
|
||||||
context.getSource().sendFeedback(
|
context.getSource().sendFeedback(
|
||||||
new StringTextComponent("Terrain=" + cell.terrainType.getName() + ", Biome=" + biome.getRegistryName()),
|
new StringTextComponent("Terrain=" + cell.terrain.getName() + ", Biome=" + biome.getRegistryName()),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -277,7 +277,7 @@ public class TerraCommand {
|
|||||||
|
|
||||||
// the terrain parsed from the command will not be the same instance as used in the
|
// the terrain parsed from the command will not be the same instance as used in the
|
||||||
// world generator, so find the matching instance by name
|
// world generator, so find the matching instance by name
|
||||||
private static Terrain getTerrainInstance(Terrain find, TerrainTypes terrains) {
|
private static Terrain getTerrainInstance(Terrain find, Terrains terrains) {
|
||||||
for (Terrain t : terrains.index) {
|
for (Terrain t : terrains.index) {
|
||||||
if (t.getName().equals(find.getName())) {
|
if (t.getName().equals(find.getName())) {
|
||||||
return t;
|
return t;
|
||||||
|
@ -25,6 +25,6 @@ public class TerrainSearchTask extends Search {
|
|||||||
@Override
|
@Override
|
||||||
public boolean test(BlockPos pos) {
|
public boolean test(BlockPos pos) {
|
||||||
generator.getHeightmap().apply(cell, pos.getX(), pos.getZ());
|
generator.getHeightmap().apply(cell, pos.getX(), pos.getZ());
|
||||||
return cell.terrainType == type;
|
return cell.terrain == type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
package com.terraforged.feature;
|
package com.terraforged.feature;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
import it.unimi.dsi.fastutil.longs.LongIterator;
|
import it.unimi.dsi.fastutil.longs.LongIterator;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectList;
|
import it.unimi.dsi.fastutil.objects.ObjectList;
|
||||||
@ -37,15 +38,22 @@ import net.minecraft.util.math.MutableBoundingBox;
|
|||||||
import net.minecraft.world.IWorld;
|
import net.minecraft.world.IWorld;
|
||||||
import net.minecraft.world.chunk.IChunk;
|
import net.minecraft.world.chunk.IChunk;
|
||||||
import net.minecraft.world.gen.Heightmap;
|
import net.minecraft.world.gen.Heightmap;
|
||||||
import net.minecraft.world.gen.feature.Feature;
|
|
||||||
import net.minecraft.world.gen.feature.jigsaw.JigsawPattern;
|
import net.minecraft.world.gen.feature.jigsaw.JigsawPattern;
|
||||||
import net.minecraft.world.gen.feature.structure.AbstractVillagePiece;
|
import net.minecraft.world.gen.feature.structure.*;
|
||||||
import net.minecraft.world.gen.feature.structure.Structure;
|
|
||||||
import net.minecraft.world.gen.feature.structure.StructurePiece;
|
import java.util.List;
|
||||||
import net.minecraft.world.gen.feature.structure.StructureStart;
|
import java.util.Set;
|
||||||
|
|
||||||
public class TerrainHelper {
|
public class TerrainHelper {
|
||||||
|
|
||||||
|
private static final Set<IStructurePieceType> SURFACE_STRUCTURES = ImmutableSet.of(
|
||||||
|
IStructurePieceType.PCP, // outpost
|
||||||
|
IStructurePieceType.NVI, // village
|
||||||
|
IStructurePieceType.TEJP, // jungle temple
|
||||||
|
IStructurePieceType.IGLU, // igloo
|
||||||
|
IStructurePieceType.TEDP // desert pyramid
|
||||||
|
);
|
||||||
|
|
||||||
private final float radius;
|
private final float radius;
|
||||||
|
|
||||||
public TerrainHelper(float radius) {
|
public TerrainHelper(float radius) {
|
||||||
@ -53,15 +61,15 @@ public class TerrainHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void flatten(IWorld world, IChunk chunk) {
|
public void flatten(IWorld world, IChunk chunk) {
|
||||||
ObjectList<AbstractVillagePiece> pieces = new ObjectArrayList<>(10);
|
ObjectList<StructurePiece> pieces = new ObjectArrayList<>(10);
|
||||||
collectPieces(world, chunk, pieces);
|
collectPieces(world, chunk, pieces);
|
||||||
buildBases(chunk, pieces);
|
buildBases(chunk, pieces);
|
||||||
}
|
}
|
||||||
|
|
||||||
// see NoiseChunkGenerator
|
// see NoiseChunkGenerator
|
||||||
private void collectPieces(IWorld world, IChunk chunk, ObjectList<AbstractVillagePiece> pieces) {
|
private void collectPieces(IWorld world, IChunk chunk, ObjectList<StructurePiece> pieces) {
|
||||||
ChunkPos pos = chunk.getPos();
|
ChunkPos pos = chunk.getPos();
|
||||||
for (Structure<?> structure : Feature.ILLAGER_STRUCTURES) {
|
for (Structure<?> structure : Structure.ILLAGER_STRUCTURES) {
|
||||||
String name = structure.getStructureName();
|
String name = structure.getStructureName();
|
||||||
LongIterator structureIds = chunk.getStructureReferences(name).iterator();
|
LongIterator structureIds = chunk.getStructureReferences(name).iterator();
|
||||||
|
|
||||||
@ -72,12 +80,9 @@ public class TerrainHelper {
|
|||||||
StructureStart structurestart = neighbourChunk.getStructureStart(name);
|
StructureStart structurestart = neighbourChunk.getStructureStart(name);
|
||||||
if (structurestart != null && structurestart.isValid()) {
|
if (structurestart != null && structurestart.isValid()) {
|
||||||
for (StructurePiece structurepiece : structurestart.getComponents()) {
|
for (StructurePiece structurepiece : structurestart.getComponents()) {
|
||||||
if (structurepiece.func_214810_a(pos, 12) && structurepiece instanceof AbstractVillagePiece) {
|
// collect if piece is within radius of the chunk
|
||||||
AbstractVillagePiece piece = (AbstractVillagePiece) structurepiece;
|
if (structurepiece.func_214810_a(pos, 12)) {
|
||||||
JigsawPattern.PlacementBehaviour placement = piece.getJigsawPiece().getPlacementBehaviour();
|
collectPiece(structurepiece, pieces);
|
||||||
if (placement == JigsawPattern.PlacementBehaviour.RIGID) {
|
|
||||||
pieces.add(piece);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,11 +91,11 @@ public class TerrainHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// lowers or raises the terrain matcher the base height of each structure piece
|
// lowers or raises the terrain matcher the base height of each structure piece
|
||||||
private void buildBases(IChunk chunk, ObjectList<AbstractVillagePiece> pieces) {
|
private void buildBases(IChunk chunk, ObjectList<StructurePiece> pieces) {
|
||||||
int chunkStartX = chunk.getPos().getXStart();
|
int chunkStartX = chunk.getPos().getXStart();
|
||||||
int chunkStartZ = chunk.getPos().getZStart();
|
int chunkStartZ = chunk.getPos().getZStart();
|
||||||
BlockPos.Mutable pos = new BlockPos.Mutable();
|
BlockPos.Mutable pos = new BlockPos.Mutable();
|
||||||
ObjectListIterator<AbstractVillagePiece> iterator = pieces.iterator();
|
ObjectListIterator<StructurePiece> iterator = pieces.iterator();
|
||||||
MutableBoundingBox chunkBounds = new MutableBoundingBox(chunkStartX, chunkStartZ, chunkStartX + 15, chunkStartZ + 15);
|
MutableBoundingBox chunkBounds = new MutableBoundingBox(chunkStartX, chunkStartZ, chunkStartX + 15, chunkStartZ + 15);
|
||||||
|
|
||||||
for (int dz = 0; dz < 16; dz++) {
|
for (int dz = 0; dz < 16; dz++) {
|
||||||
@ -100,9 +105,10 @@ public class TerrainHelper {
|
|||||||
int surface = chunk.getTopBlockY(Heightmap.Type.OCEAN_FLOOR_WG, dx, dz);
|
int surface = chunk.getTopBlockY(Heightmap.Type.OCEAN_FLOOR_WG, dx, dz);
|
||||||
float y = surface;
|
float y = surface;
|
||||||
|
|
||||||
AbstractVillagePiece highest = null;
|
int highestOffset = 0;
|
||||||
|
StructurePiece highest = null;
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
AbstractVillagePiece piece = iterator.next();
|
StructurePiece piece = iterator.next();
|
||||||
MutableBoundingBox pieceBounds = piece.getBoundingBox();
|
MutableBoundingBox pieceBounds = piece.getBoundingBox();
|
||||||
int length = Math.min(pieceBounds.maxX - pieceBounds.minX, pieceBounds.maxZ - pieceBounds.minZ);
|
int length = Math.min(pieceBounds.maxX - pieceBounds.minX, pieceBounds.maxZ - pieceBounds.minZ);
|
||||||
int borderRadius = Math.min(5, Math.max(10, NoiseUtil.round(length * radius)));
|
int borderRadius = Math.min(5, Math.max(10, NoiseUtil.round(length * radius)));
|
||||||
@ -111,7 +117,8 @@ public class TerrainHelper {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int level = pieceBounds.minY + piece.getGroundLevelDelta();
|
int offset = getGroundLevelDelta(piece);
|
||||||
|
int level = pieceBounds.minY + offset;
|
||||||
if (level > y) {
|
if (level > y) {
|
||||||
y = raise(pieceBounds, pos.setPos(x, surface, z), level, y, borderRadius);
|
y = raise(pieceBounds, pos.setPos(x, surface, z), level, y, borderRadius);
|
||||||
}
|
}
|
||||||
@ -119,6 +126,7 @@ public class TerrainHelper {
|
|||||||
if (x > pieceBounds.minX && x < pieceBounds.maxX && z > pieceBounds.minZ && z < pieceBounds.maxZ) {
|
if (x > pieceBounds.minX && x < pieceBounds.maxX && z > pieceBounds.minZ && z < pieceBounds.maxZ) {
|
||||||
if (highest == null || pieceBounds.minY > highest.getBoundingBox().minY) {
|
if (highest == null || pieceBounds.minY > highest.getBoundingBox().minY) {
|
||||||
highest = piece;
|
highest = piece;
|
||||||
|
highestOffset = offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,7 +144,7 @@ public class TerrainHelper {
|
|||||||
|
|
||||||
if (highest != null) {
|
if (highest != null) {
|
||||||
MutableBoundingBox bounds = highest.getBoundingBox();
|
MutableBoundingBox bounds = highest.getBoundingBox();
|
||||||
for (int dy = bounds.minY + highest.getGroundLevelDelta(); dy <= surface; dy++) {
|
for (int dy = bounds.minY + highestOffset; dy <= surface; dy++) {
|
||||||
pos.setPos(dx, dy, dz);
|
pos.setPos(dx, dy, dz);
|
||||||
chunk.setBlockState(pos, Blocks.AIR.getDefaultState(), false);
|
chunk.setBlockState(pos, Blocks.AIR.getDefaultState(), false);
|
||||||
}
|
}
|
||||||
@ -152,6 +160,25 @@ public class TerrainHelper {
|
|||||||
return NoiseUtil.lerp(surface, level, alpha);
|
return NoiseUtil.lerp(surface, level, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void collectPiece(StructurePiece structurepiece, List<StructurePiece> list) {
|
||||||
|
if (structurepiece instanceof AbstractVillagePiece) {
|
||||||
|
AbstractVillagePiece piece = (AbstractVillagePiece) structurepiece;
|
||||||
|
JigsawPattern.PlacementBehaviour placement = piece.getJigsawPiece().getPlacementBehaviour();
|
||||||
|
if (placement == JigsawPattern.PlacementBehaviour.RIGID) {
|
||||||
|
list.add(piece);
|
||||||
|
}
|
||||||
|
} else if (SURFACE_STRUCTURES.contains(structurepiece.getStructurePieceType())) {
|
||||||
|
list.add(structurepiece);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getGroundLevelDelta(StructurePiece piece) {
|
||||||
|
if (piece instanceof AbstractVillagePiece) {
|
||||||
|
return ((AbstractVillagePiece) piece).getGroundLevelDelta();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
private static MutableBoundingBox expand(MutableBoundingBox box, int radius) {
|
private static MutableBoundingBox expand(MutableBoundingBox box, int radius) {
|
||||||
return new MutableBoundingBox(
|
return new MutableBoundingBox(
|
||||||
box.minX - radius,
|
box.minX - radius,
|
||||||
|
@ -3,7 +3,7 @@ package com.terraforged.feature.context;
|
|||||||
import com.terraforged.chunk.fix.RegionDelegate;
|
import com.terraforged.chunk.fix.RegionDelegate;
|
||||||
import com.terraforged.chunk.util.TerraContainer;
|
import com.terraforged.chunk.util.TerraContainer;
|
||||||
import com.terraforged.core.cell.Cell;
|
import com.terraforged.core.cell.Cell;
|
||||||
import com.terraforged.core.concurrent.ObjectPool;
|
import com.terraforged.core.concurrent.pool.ObjectPool;
|
||||||
import com.terraforged.core.concurrent.Resource;
|
import com.terraforged.core.concurrent.Resource;
|
||||||
import com.terraforged.core.region.chunk.ChunkReader;
|
import com.terraforged.core.region.chunk.ChunkReader;
|
||||||
import com.terraforged.world.heightmap.Levels;
|
import com.terraforged.world.heightmap.Levels;
|
||||||
|
@ -23,7 +23,7 @@ public abstract class PoissonDecorator extends Placement<PoissonConfig> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final <FC extends IFeatureConfig, F extends Feature<FC>> boolean place(IWorld world, ChunkGenerator<?> generator, Random random, BlockPos pos, PoissonConfig config, ConfiguredFeature<FC, F> feature) {
|
public <FC extends IFeatureConfig, F extends Feature<FC>> boolean place(IWorld world, ChunkGenerator<?> generator, Random random, BlockPos pos, PoissonConfig config, ConfiguredFeature<FC, F> feature) {
|
||||||
int radius = Math.max(1, Math.min(30, config.radius));
|
int radius = Math.max(1, Math.min(30, config.radius));
|
||||||
Poisson poisson = getInstance(radius);
|
Poisson poisson = getInstance(radius);
|
||||||
PoissonVisitor visitor = new PoissonVisitor(this, feature, world, generator, random, pos);
|
PoissonVisitor visitor = new PoissonVisitor(this, feature, world, generator, random, pos);
|
||||||
|
@ -26,15 +26,13 @@
|
|||||||
package com.terraforged.gui;
|
package com.terraforged.gui;
|
||||||
|
|
||||||
import com.terraforged.gui.element.TerraLabel;
|
import com.terraforged.gui.element.TerraLabel;
|
||||||
import com.terraforged.gui.page.ClimatePage;
|
|
||||||
import com.terraforged.gui.page.MiscPage;
|
|
||||||
import com.terraforged.gui.page.Page;
|
import com.terraforged.gui.page.Page;
|
||||||
import com.terraforged.gui.page.PresetsPage;
|
import com.terraforged.gui.page.PresetsPage;
|
||||||
import com.terraforged.gui.page.RiverPage;
|
import com.terraforged.gui.page.SimplePage;
|
||||||
import com.terraforged.gui.page.StructurePage;
|
import com.terraforged.gui.page.SimplePreviewPage;
|
||||||
import com.terraforged.gui.page.TerrainPage;
|
|
||||||
import com.terraforged.gui.page.WorldPage;
|
import com.terraforged.gui.page.WorldPage;
|
||||||
import com.terraforged.gui.preview.PreviewPage;
|
import com.terraforged.gui.preview.PreviewPage;
|
||||||
|
import com.terraforged.gui.preview.again.PreviewPage2;
|
||||||
import com.terraforged.settings.SettingsHelper;
|
import com.terraforged.settings.SettingsHelper;
|
||||||
import com.terraforged.settings.TerraSettings;
|
import com.terraforged.settings.TerraSettings;
|
||||||
import com.terraforged.util.nbt.NBTHelper;
|
import com.terraforged.util.nbt.NBTHelper;
|
||||||
@ -51,7 +49,7 @@ public class SettingsScreen extends OverlayScreen {
|
|||||||
private static final Button.IPressable NO_ACTION = b -> {};
|
private static final Button.IPressable NO_ACTION = b -> {};
|
||||||
|
|
||||||
private final Page[] pages;
|
private final Page[] pages;
|
||||||
private final PreviewPage preview;
|
private final PreviewPage2 preview;
|
||||||
private final CreateWorldScreen parent;
|
private final CreateWorldScreen parent;
|
||||||
private final TerraSettings settings = new TerraSettings();
|
private final TerraSettings settings = new TerraSettings();
|
||||||
|
|
||||||
@ -60,15 +58,16 @@ public class SettingsScreen extends OverlayScreen {
|
|||||||
public SettingsScreen(CreateWorldScreen parent) {
|
public SettingsScreen(CreateWorldScreen parent) {
|
||||||
SettingsHelper.applyDefaults(parent.chunkProviderSettingsJson, settings);
|
SettingsHelper.applyDefaults(parent.chunkProviderSettingsJson, settings);
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.preview = new PreviewPage(settings, getSeed(parent));
|
this.preview = new PreviewPage2(settings, getSeed(parent));
|
||||||
this.pages = new Page[]{
|
this.pages = new Page[]{
|
||||||
new PresetsPage(),
|
new PresetsPage(),
|
||||||
new WorldPage(settings, preview),
|
new WorldPage(settings, preview),
|
||||||
new ClimatePage(settings, preview),
|
new SimplePreviewPage("Climate Settings", "climate", preview, settings, s -> s.climate),
|
||||||
new TerrainPage(settings, preview),
|
new SimplePreviewPage("Terrain Settings", "terrain", preview, settings, s -> s.terrain),
|
||||||
new RiverPage(settings, preview),
|
new SimplePreviewPage("River Settings", "rivers", preview, settings, s -> s.rivers),
|
||||||
new StructurePage(settings),
|
new SimplePreviewPage("Filter Settings", "filters", preview, settings, s -> s.filters),
|
||||||
new MiscPage(settings)
|
new SimplePage("Structure Settings", "structures", settings, s -> s.structures),
|
||||||
|
new SimplePage("Feature Settings", "features", settings, s -> s.features)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* MIT License
|
|
||||||
*
|
|
||||||
* Copyright (c) 2020 TerraForged
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.terraforged.gui.page;
|
|
||||||
|
|
||||||
import com.terraforged.core.settings.Settings;
|
|
||||||
import com.terraforged.gui.OverlayScreen;
|
|
||||||
import com.terraforged.gui.preview.PreviewPage;
|
|
||||||
import com.terraforged.util.nbt.NBTHelper;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
|
|
||||||
public class ClimatePage extends BasePage {
|
|
||||||
|
|
||||||
private final Settings settings;
|
|
||||||
private final PreviewPage preview;
|
|
||||||
private final CompoundNBT climateSettings;
|
|
||||||
|
|
||||||
public ClimatePage(Settings settings, PreviewPage preview) {
|
|
||||||
this.settings = settings;
|
|
||||||
this.preview = preview;
|
|
||||||
this.climateSettings = NBTHelper.serialize("climate", settings.climate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTitle() {
|
|
||||||
return "Climate Settings";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void save() {
|
|
||||||
NBTHelper.deserialize(climateSettings, settings.climate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(OverlayScreen parent) {
|
|
||||||
Column center = getColumn(0);
|
|
||||||
center.scrollPane.setScrollAmount(0D);
|
|
||||||
addElements(0, 0, center, climateSettings, true, center.scrollPane::addButton, this::update);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void update() {
|
|
||||||
super.update();
|
|
||||||
preview.apply(settings -> NBTHelper.deserialize(climateSettings, settings.climate));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* MIT License
|
|
||||||
*
|
|
||||||
* Copyright (c) 2020 TerraForged
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.terraforged.gui.page;
|
|
||||||
|
|
||||||
import com.terraforged.gui.OverlayScreen;
|
|
||||||
import com.terraforged.gui.element.TerraLabel;
|
|
||||||
import com.terraforged.settings.TerraSettings;
|
|
||||||
import com.terraforged.util.nbt.NBTHelper;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
|
|
||||||
public class MiscPage extends BasePage {
|
|
||||||
|
|
||||||
private final TerraSettings settings;
|
|
||||||
private final CompoundNBT filterSettings;
|
|
||||||
private final CompoundNBT featureSettings;
|
|
||||||
|
|
||||||
public MiscPage(TerraSettings settings) {
|
|
||||||
this.settings = settings;
|
|
||||||
this.filterSettings = NBTHelper.serialize("filters", settings.filters);
|
|
||||||
this.featureSettings = NBTHelper.serialize("features", settings.features);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTitle() {
|
|
||||||
return "Miscellaneous Settings";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void save() {
|
|
||||||
NBTHelper.deserialize(filterSettings, settings.filters);
|
|
||||||
NBTHelper.deserialize(featureSettings, settings.features);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(OverlayScreen parent) {
|
|
||||||
Column left = getColumn(0);
|
|
||||||
addElements(left.left, left.top, left, filterSettings, true, left.scrollPane::addButton, this::update);
|
|
||||||
|
|
||||||
left.scrollPane.addButton(new TerraLabel("Features & Decorators"));
|
|
||||||
addElements(left.left, left.top, left, featureSettings, false, left.scrollPane::addButton, this::update);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
package com.terraforged.gui.page;
|
|
||||||
|
|
||||||
import com.terraforged.gui.OverlayScreen;
|
|
||||||
|
|
||||||
public class PresetPage extends BasePage {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void save() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(OverlayScreen parent) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* MIT License
|
|
||||||
*
|
|
||||||
* Copyright (c) 2020 TerraForged
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.terraforged.gui.page;
|
|
||||||
|
|
||||||
import com.terraforged.core.settings.Settings;
|
|
||||||
import com.terraforged.gui.OverlayScreen;
|
|
||||||
import com.terraforged.gui.preview.PreviewPage;
|
|
||||||
import com.terraforged.util.nbt.NBTHelper;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
|
|
||||||
public class RiverPage extends BasePage {
|
|
||||||
|
|
||||||
private final Settings settings;
|
|
||||||
private final PreviewPage preview;
|
|
||||||
private final CompoundNBT riverSettings;
|
|
||||||
|
|
||||||
public RiverPage(Settings settings, PreviewPage preview) {
|
|
||||||
this.settings = settings;
|
|
||||||
this.preview = preview;
|
|
||||||
this.riverSettings = NBTHelper.serialize("rivers", settings.rivers);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTitle() {
|
|
||||||
return "River Settings";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void save() {
|
|
||||||
NBTHelper.deserialize(riverSettings, settings.rivers);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(OverlayScreen parent) {
|
|
||||||
Column center = getColumn(0);
|
|
||||||
center.scrollPane.setScrollAmount(0D);
|
|
||||||
addElements(0, 0, center, riverSettings, true, center.scrollPane::addButton, this::update);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void update() {
|
|
||||||
super.update();
|
|
||||||
preview.apply(settings -> NBTHelper.deserialize(riverSettings, settings.rivers));
|
|
||||||
}
|
|
||||||
}
|
|
44
src/main/java/com/terraforged/gui/page/SimplePage.java
Normal file
44
src/main/java/com/terraforged/gui/page/SimplePage.java
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
package com.terraforged.gui.page;
|
||||||
|
|
||||||
|
import com.terraforged.gui.OverlayScreen;
|
||||||
|
import com.terraforged.settings.TerraSettings;
|
||||||
|
import com.terraforged.util.nbt.NBTHelper;
|
||||||
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public class SimplePage extends BasePage {
|
||||||
|
|
||||||
|
private final String title;
|
||||||
|
protected final TerraSettings settings;
|
||||||
|
protected final CompoundNBT sectionSettings;
|
||||||
|
protected final Function<TerraSettings, Object> section;
|
||||||
|
|
||||||
|
public SimplePage(String title, String sectionName, TerraSettings settings, Function<TerraSettings, Object> section) {
|
||||||
|
this.title = title;
|
||||||
|
this.section = section;
|
||||||
|
this.settings = settings;
|
||||||
|
this.sectionSettings = NBTHelper.serialize(sectionName, section.apply(settings));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save() {
|
||||||
|
NBTHelper.deserialize(sectionSettings, section);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(OverlayScreen parent) {
|
||||||
|
Column left = getColumn(0);
|
||||||
|
addElements(left.left, left.top, left, sectionSettings, true, left.scrollPane::addButton, this::update);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void update() {
|
||||||
|
super.update();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.terraforged.gui.page;
|
||||||
|
|
||||||
|
import com.terraforged.settings.TerraSettings;
|
||||||
|
import com.terraforged.util.nbt.NBTHelper;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public class SimplePreviewPage extends SimplePage {
|
||||||
|
|
||||||
|
private final UpdatablePage preview;
|
||||||
|
|
||||||
|
public SimplePreviewPage(String title, String sectionName, UpdatablePage preview, TerraSettings settings, Function<TerraSettings, Object> section) {
|
||||||
|
super(title, sectionName, settings, section);
|
||||||
|
this.preview = preview;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void update() {
|
||||||
|
super.update();
|
||||||
|
preview.apply(settings -> NBTHelper.deserialize(sectionSettings, section.apply(settings)));
|
||||||
|
}
|
||||||
|
}
|
@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* MIT License
|
|
||||||
*
|
|
||||||
* Copyright (c) 2020 TerraForged
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.terraforged.gui.page;
|
|
||||||
|
|
||||||
import com.terraforged.gui.OverlayScreen;
|
|
||||||
import com.terraforged.settings.TerraSettings;
|
|
||||||
import com.terraforged.util.nbt.NBTHelper;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
|
|
||||||
public class StructurePage extends BasePage {
|
|
||||||
|
|
||||||
private final TerraSettings settings;
|
|
||||||
private final CompoundNBT structureSettings;
|
|
||||||
|
|
||||||
public StructurePage(TerraSettings settings) {
|
|
||||||
this.settings = settings;
|
|
||||||
this.structureSettings = NBTHelper.serialize("structures", settings.structures);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTitle() {
|
|
||||||
return "Structure Settings";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void save() {
|
|
||||||
NBTHelper.deserialize(structureSettings, settings.structures);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(OverlayScreen parent) {
|
|
||||||
Column left = getColumn(0);
|
|
||||||
addElements(left.left, left.top, left, structureSettings, true, left.scrollPane::addButton, this::update);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* MIT License
|
|
||||||
*
|
|
||||||
* Copyright (c) 2020 TerraForged
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.terraforged.gui.page;
|
|
||||||
|
|
||||||
import com.terraforged.core.settings.Settings;
|
|
||||||
import com.terraforged.gui.OverlayScreen;
|
|
||||||
import com.terraforged.gui.preview.PreviewPage;
|
|
||||||
import com.terraforged.util.nbt.NBTHelper;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
|
|
||||||
public class TerrainPage extends BasePage {
|
|
||||||
|
|
||||||
private final Settings settings;
|
|
||||||
private final PreviewPage preview;
|
|
||||||
private final CompoundNBT terrainSettings;
|
|
||||||
|
|
||||||
public TerrainPage(Settings settings, PreviewPage preview) {
|
|
||||||
this.settings = settings;
|
|
||||||
this.preview = preview;
|
|
||||||
this.terrainSettings = NBTHelper.serialize("terrain", settings.terrain);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTitle() {
|
|
||||||
return "Terrain Settings";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void save() {
|
|
||||||
NBTHelper.deserialize(terrainSettings, settings.terrain);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(OverlayScreen parent) {
|
|
||||||
Column center = getColumn(0);
|
|
||||||
center.scrollPane.setScrollAmount(0D);
|
|
||||||
addElements(0, 0, center, terrainSettings, true, center.scrollPane::addButton, this::update);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void update() {
|
|
||||||
super.update();
|
|
||||||
preview.apply(settings -> NBTHelper.deserialize(terrainSettings, settings.terrain));
|
|
||||||
}
|
|
||||||
}
|
|
23
src/main/java/com/terraforged/gui/page/UpdatablePage.java
Normal file
23
src/main/java/com/terraforged/gui/page/UpdatablePage.java
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package com.terraforged.gui.page;
|
||||||
|
|
||||||
|
import com.terraforged.gui.OverlayScreen;
|
||||||
|
import com.terraforged.settings.TerraSettings;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
public class UpdatablePage extends BasePage {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(OverlayScreen parent) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void apply(Consumer<TerraSettings> consumer) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -42,11 +42,11 @@ import net.minecraftforge.registries.ForgeRegistries;
|
|||||||
public class WorldPage extends BasePage {
|
public class WorldPage extends BasePage {
|
||||||
|
|
||||||
private final TerraSettings settings;
|
private final TerraSettings settings;
|
||||||
private final PreviewPage preview;
|
private final UpdatablePage preview;
|
||||||
private final CompoundNBT worldSettings;
|
private final CompoundNBT worldSettings;
|
||||||
private final CompoundNBT dimSettings;
|
private final CompoundNBT dimSettings;
|
||||||
|
|
||||||
public WorldPage(TerraSettings settings, PreviewPage preview) {
|
public WorldPage(TerraSettings settings, UpdatablePage preview) {
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.preview = preview;
|
this.preview = preview;
|
||||||
this.worldSettings = NBTHelper.serialize("world", settings.world);
|
this.worldSettings = NBTHelper.serialize("world", settings.world);
|
||||||
|
@ -29,7 +29,7 @@ import com.mojang.blaze3d.platform.GlStateManager;
|
|||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.terraforged.core.cell.Cell;
|
import com.terraforged.core.cell.Cell;
|
||||||
import com.terraforged.core.concurrent.cache.CacheEntry;
|
import com.terraforged.core.concurrent.cache.CacheEntry;
|
||||||
import com.terraforged.core.concurrent.pool.ThreadPools;
|
import com.terraforged.core.concurrent.thread.ThreadPools;
|
||||||
import com.terraforged.core.region.Region;
|
import com.terraforged.core.region.Region;
|
||||||
import com.terraforged.core.region.Size;
|
import com.terraforged.core.region.Size;
|
||||||
import com.terraforged.core.region.gen.RegionGenerator;
|
import com.terraforged.core.region.gen.RegionGenerator;
|
||||||
@ -38,7 +38,7 @@ import com.terraforged.util.nbt.NBTHelper;
|
|||||||
import com.terraforged.world.GeneratorContext;
|
import com.terraforged.world.GeneratorContext;
|
||||||
import com.terraforged.world.continent.MutableVeci;
|
import com.terraforged.world.continent.MutableVeci;
|
||||||
import com.terraforged.world.heightmap.Levels;
|
import com.terraforged.world.heightmap.Levels;
|
||||||
import com.terraforged.world.terrain.TerrainTypes;
|
import com.terraforged.world.terrain.Terrains;
|
||||||
import me.dags.noise.util.NoiseUtil;
|
import me.dags.noise.util.NoiseUtil;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.AbstractGui;
|
import net.minecraft.client.gui.AbstractGui;
|
||||||
@ -197,7 +197,7 @@ public class Preview extends Button {
|
|||||||
settings.world.seed = seed;
|
settings.world.seed = seed;
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
|
|
||||||
GeneratorContext context = GeneratorContext.createNoCache(TerrainTypes.create(settings), settings);
|
GeneratorContext context = GeneratorContext.createNoCache(Terrains.create(settings), settings);
|
||||||
|
|
||||||
MutableVeci center = new MutableVeci();
|
MutableVeci center = new MutableVeci();
|
||||||
context.factory.getHeightmap().getContinent().getNearestCenter(offsetX, offsetZ, center);
|
context.factory.getHeightmap().getContinent().getNearestCenter(offsetX, offsetZ, center);
|
||||||
@ -276,7 +276,7 @@ public class Preview extends Button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String getTerrainName(Cell cell) {
|
private static String getTerrainName(Cell cell) {
|
||||||
String terrain = cell.terrainType.getName().toLowerCase();
|
String terrain = cell.terrain.getName().toLowerCase();
|
||||||
if (terrain.contains("river")) {
|
if (terrain.contains("river")) {
|
||||||
return "river";
|
return "river";
|
||||||
}
|
}
|
||||||
@ -284,7 +284,7 @@ public class Preview extends Button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String getBiomeName(Cell cell) {
|
private static String getBiomeName(Cell cell) {
|
||||||
String terrain = cell.terrainType.getName().toLowerCase();
|
String terrain = cell.terrain.getName().toLowerCase();
|
||||||
if (terrain.contains("ocean")) {
|
if (terrain.contains("ocean")) {
|
||||||
if (cell.temperature < 0.3) {
|
if (cell.temperature < 0.3) {
|
||||||
return "cold_ocean";
|
return "cold_ocean";
|
||||||
|
@ -25,22 +25,23 @@
|
|||||||
|
|
||||||
package com.terraforged.gui.preview;
|
package com.terraforged.gui.preview;
|
||||||
|
|
||||||
import com.terraforged.core.settings.Settings;
|
|
||||||
import com.terraforged.gui.OverlayScreen;
|
import com.terraforged.gui.OverlayScreen;
|
||||||
import com.terraforged.gui.element.TerraButton;
|
import com.terraforged.gui.element.TerraButton;
|
||||||
import com.terraforged.gui.page.BasePage;
|
import com.terraforged.gui.page.BasePage;
|
||||||
|
import com.terraforged.gui.page.UpdatablePage;
|
||||||
|
import com.terraforged.settings.TerraSettings;
|
||||||
import com.terraforged.util.nbt.NBTHelper;
|
import com.terraforged.util.nbt.NBTHelper;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class PreviewPage extends BasePage {
|
public class PreviewPage extends UpdatablePage {
|
||||||
|
|
||||||
private final Preview preview;
|
private final Preview preview;
|
||||||
private final Settings settings;
|
private final TerraSettings settings;
|
||||||
private final CompoundNBT previewerSettings = NBTHelper.serialize("preview", new PreviewSettings());
|
private final CompoundNBT previewerSettings = NBTHelper.serialize("preview", new PreviewSettings());
|
||||||
|
|
||||||
public PreviewPage(Settings settings, int seed) {
|
public PreviewPage(TerraSettings settings, int seed) {
|
||||||
this.preview = new Preview(seed);
|
this.preview = new Preview(seed);
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
}
|
}
|
||||||
@ -49,7 +50,8 @@ public class PreviewPage extends BasePage {
|
|||||||
return preview.getSeed();
|
return preview.getSeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void apply(Consumer<Settings> consumer) {
|
@Override
|
||||||
|
public void apply(Consumer<TerraSettings> consumer) {
|
||||||
consumer.accept(settings);
|
consumer.accept(settings);
|
||||||
preview.update(settings, previewerSettings);
|
preview.update(settings, previewerSettings);
|
||||||
}
|
}
|
||||||
@ -59,11 +61,6 @@ public class PreviewPage extends BasePage {
|
|||||||
preview.close();
|
preview.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void save() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(OverlayScreen parent) {
|
public void init(OverlayScreen parent) {
|
||||||
Column right = getColumn(1);
|
Column right = getColumn(1);
|
||||||
@ -92,6 +89,7 @@ public class PreviewPage extends BasePage {
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
preview.update(settings, previewerSettings);
|
preview.update(settings, previewerSettings);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
package com.terraforged.gui.preview.again;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.terraforged.core.render.RenderAPI;
|
||||||
|
import com.terraforged.core.render.RenderBuffer;
|
||||||
|
import net.minecraft.client.renderer.BufferBuilder;
|
||||||
|
|
||||||
|
public class MCRenderAPI implements RenderAPI {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void pushMatrix() {
|
||||||
|
RenderSystem.pushMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void popMatrix() {
|
||||||
|
RenderSystem.popMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void translate(float x, float y, float z) {
|
||||||
|
RenderSystem.translatef(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void rotateX(float angle) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void rotateY(float angle) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void rotateZ(float angle) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RenderBuffer createBuffer() {
|
||||||
|
return new MCRenderBuffer(new BufferBuilder(4096));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
package com.terraforged.gui.preview.again;
|
||||||
|
|
||||||
|
import com.terraforged.core.render.RenderBuffer;
|
||||||
|
import net.minecraft.client.renderer.BufferBuilder;
|
||||||
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
|
import net.minecraft.client.renderer.WorldVertexBufferUploader;
|
||||||
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class MCRenderBuffer implements RenderBuffer {
|
||||||
|
|
||||||
|
private final Object lock = new Object();
|
||||||
|
private final BufferBuilder buffer;
|
||||||
|
|
||||||
|
private BufferBuilder.State state = null;
|
||||||
|
|
||||||
|
private float r, g, b;
|
||||||
|
|
||||||
|
public MCRenderBuffer(BufferBuilder buffer) {
|
||||||
|
this.buffer = buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beginQuads() {
|
||||||
|
buffer.reset();
|
||||||
|
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void endQuads() {
|
||||||
|
synchronized (lock) {
|
||||||
|
state = buffer.getVertexState();
|
||||||
|
buffer.finishDrawing();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void vertex(float x, float y, float z) {
|
||||||
|
buffer.pos(x, y, z).color(r, g, b, 1).endVertex();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void color(float hue, float saturation, float brightness) {
|
||||||
|
Color color = Color.getHSBColor(hue / 100F, saturation / 100F, brightness / 100F);
|
||||||
|
r = color.getRed() / 255F;
|
||||||
|
g = color.getGreen() / 255F;
|
||||||
|
b = color.getBlue() / 255F;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw() {
|
||||||
|
synchronized (lock) {
|
||||||
|
if (state != null) {
|
||||||
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
|
BufferBuilder builder = tessellator.getBuffer();
|
||||||
|
builder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
|
||||||
|
builder.setVertexState(state);
|
||||||
|
builder.sortVertexData(0, 0, 5000);
|
||||||
|
builder.finishDrawing();
|
||||||
|
WorldVertexBufferUploader.draw(builder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
111
src/main/java/com/terraforged/gui/preview/again/Preview2.java
Normal file
111
src/main/java/com/terraforged/gui/preview/again/Preview2.java
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
package com.terraforged.gui.preview.again;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.terraforged.core.concurrent.thread.ThreadPool;
|
||||||
|
import com.terraforged.core.concurrent.thread.ThreadPools;
|
||||||
|
import com.terraforged.core.region.gen.RegionGenerator;
|
||||||
|
import com.terraforged.core.render.RenderAPI;
|
||||||
|
import com.terraforged.core.render.RenderSettings;
|
||||||
|
import com.terraforged.core.render.RenderWorld;
|
||||||
|
import com.terraforged.settings.TerraSettings;
|
||||||
|
import com.terraforged.world.GeneratorContext;
|
||||||
|
import com.terraforged.world.continent.MutableVeci;
|
||||||
|
import com.terraforged.world.terrain.Terrains;
|
||||||
|
import net.minecraft.client.gui.widget.Widget;
|
||||||
|
import net.minecraft.client.renderer.RenderHelper;
|
||||||
|
|
||||||
|
public class Preview2 extends Widget {
|
||||||
|
|
||||||
|
private final ThreadPool threadPool = ThreadPools.getPool();
|
||||||
|
|
||||||
|
private final TerraSettings settings;
|
||||||
|
|
||||||
|
private int seed;
|
||||||
|
private float zoom = 50;
|
||||||
|
private float offsetX = 0;
|
||||||
|
private float offsetZ = 0;
|
||||||
|
private float angle = 45F;
|
||||||
|
private RenderWorld world;
|
||||||
|
private PreviewSettings previewSettings = new PreviewSettings();
|
||||||
|
|
||||||
|
public Preview2(TerraSettings settings, int seed) {
|
||||||
|
super(0, 0, "preview");
|
||||||
|
this.seed = seed;
|
||||||
|
this.settings = settings;
|
||||||
|
this.world = createWorld(settings);
|
||||||
|
this.world.update(offsetX, offsetZ, zoom, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSeed() {
|
||||||
|
return seed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void nextSeed() {
|
||||||
|
seed++;
|
||||||
|
world = createWorld(settings);
|
||||||
|
world.update(offsetX, offsetZ, zoom, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(int mx, int my, float ticks) {
|
||||||
|
try {
|
||||||
|
float scale = 0.75F;
|
||||||
|
|
||||||
|
angle += 0.35F;
|
||||||
|
if (angle >= 360) {
|
||||||
|
angle = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
RenderSystem.pushMatrix();
|
||||||
|
RenderSystem.enableLighting();
|
||||||
|
RenderHelper.enableStandardItemLighting();
|
||||||
|
RenderHelper.setupGui3DDiffuseLighting();
|
||||||
|
|
||||||
|
RenderSystem.translatef(x, y, 0);
|
||||||
|
RenderSystem.translatef(width / 2F, width / 2F, 0);
|
||||||
|
RenderSystem.rotatef(70, 1, 0, 0);
|
||||||
|
RenderSystem.rotatef(angle, 0, 0, 1);
|
||||||
|
RenderSystem.scalef(scale, scale, scale);
|
||||||
|
|
||||||
|
world.refresh();
|
||||||
|
world.render();
|
||||||
|
|
||||||
|
RenderHelper.disableStandardItemLighting();
|
||||||
|
RenderSystem.popMatrix();
|
||||||
|
} catch (Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(PreviewSettings settings, TerraSettings genSettings) {
|
||||||
|
this.previewSettings = settings;
|
||||||
|
// this.world = createWorld(genSettings);
|
||||||
|
world.update(offsetX, offsetZ, previewSettings.zoom, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private RenderWorld createWorld(TerraSettings settings) {
|
||||||
|
int size = 4;
|
||||||
|
int regions = 1;
|
||||||
|
settings.world.seed = seed;
|
||||||
|
GeneratorContext context = GeneratorContext.createNoCache(Terrains.create(settings), settings);
|
||||||
|
|
||||||
|
MutableVeci center = new MutableVeci();
|
||||||
|
context.factory.getHeightmap().getContinent().getNearestCenter(0, 0, center);
|
||||||
|
|
||||||
|
RegionGenerator generator = RegionGenerator.builder()
|
||||||
|
.pool(threadPool)
|
||||||
|
.size(size, 0)
|
||||||
|
.factory(context.factory)
|
||||||
|
.batch(6)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
RenderAPI renderAPI = new MCRenderAPI();
|
||||||
|
RenderSettings renderSettings = new RenderSettings(context);
|
||||||
|
renderSettings.width = width;
|
||||||
|
renderSettings.height = height;
|
||||||
|
renderSettings.zoom = previewSettings.zoom;
|
||||||
|
renderSettings.renderMode = previewSettings.renderMode;
|
||||||
|
|
||||||
|
return new RenderWorld(generator, renderAPI, renderSettings, regions, size);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,76 @@
|
|||||||
|
package com.terraforged.gui.preview.again;
|
||||||
|
|
||||||
|
import com.terraforged.gui.OverlayScreen;
|
||||||
|
import com.terraforged.gui.element.TerraButton;
|
||||||
|
import com.terraforged.gui.page.UpdatablePage;
|
||||||
|
import com.terraforged.gui.preview.Preview;
|
||||||
|
import com.terraforged.settings.TerraSettings;
|
||||||
|
import com.terraforged.util.nbt.NBTHelper;
|
||||||
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
public class PreviewPage2 extends UpdatablePage {
|
||||||
|
|
||||||
|
private final Preview2 preview;
|
||||||
|
private final CompoundNBT settings;
|
||||||
|
private final TerraSettings genSettings = new TerraSettings();
|
||||||
|
|
||||||
|
public PreviewPage2(TerraSettings settings, int seed) {
|
||||||
|
this.preview = new Preview2(settings, seed);
|
||||||
|
this.settings = NBTHelper.serialize(new PreviewSettings());
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSeed() {
|
||||||
|
return preview.getSeed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply(Consumer<TerraSettings> consumer) {
|
||||||
|
// consumer.accept(genSettings);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(OverlayScreen parent) {
|
||||||
|
Column right = getColumn(1);
|
||||||
|
preview.x = 0;
|
||||||
|
preview.y = 0;
|
||||||
|
preview.setWidth(Preview.WIDTH);
|
||||||
|
preview.setHeight(Preview.HEIGHT);
|
||||||
|
|
||||||
|
addElements(right.left, right.top, right, settings, right.scrollPane::addButton, this::update);
|
||||||
|
|
||||||
|
right.scrollPane.addButton(new TerraButton("New Seed") {
|
||||||
|
@Override
|
||||||
|
public void onPress() {
|
||||||
|
preview.nextSeed();
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
right.scrollPane.addButton(preview);
|
||||||
|
|
||||||
|
// used to pad the scroll-pane out so that the preview legend scrolls on larger gui scales
|
||||||
|
TerraButton spacer = createSpacer();
|
||||||
|
for (int i = 0; i < 7; i++) {
|
||||||
|
right.scrollPane.addButton(spacer);
|
||||||
|
}
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update() {
|
||||||
|
PreviewSettings settings = new PreviewSettings();
|
||||||
|
NBTHelper.deserialize(this.settings, settings);
|
||||||
|
preview.update(settings, genSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TerraButton createSpacer() {
|
||||||
|
return new TerraButton("") {
|
||||||
|
@Override
|
||||||
|
public void render(int x, int y, float tick) { }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.terraforged.gui.preview.again;
|
||||||
|
|
||||||
|
import com.terraforged.core.render.RenderMode;
|
||||||
|
import com.terraforged.core.serialization.annotation.Range;
|
||||||
|
import com.terraforged.core.serialization.annotation.Serializable;
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
public class PreviewSettings {
|
||||||
|
|
||||||
|
@Range(min = 1, max = 200)
|
||||||
|
public float zoom = 10F;
|
||||||
|
|
||||||
|
public RenderMode renderMode = RenderMode.BIOME_TYPE;
|
||||||
|
}
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
package com.terraforged.util;
|
package com.terraforged.util;
|
||||||
|
|
||||||
import com.terraforged.core.concurrent.ObjectPool;
|
import com.terraforged.core.concurrent.pool.ObjectPool;
|
||||||
import com.terraforged.core.concurrent.Resource;
|
import com.terraforged.core.concurrent.Resource;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
|
@ -14,31 +14,43 @@
|
|||||||
"name": "minecraft:decorated",
|
"name": "minecraft:decorated",
|
||||||
"config": {
|
"config": {
|
||||||
"feature": {
|
"feature": {
|
||||||
"name": "minecraft:random_selector",
|
"name": "minecraft:decorated",
|
||||||
"config": {
|
"config": {
|
||||||
"features": [
|
"feature": {
|
||||||
{
|
"name": "minecraft:random_selector",
|
||||||
"name": "terraforged:template",
|
|
||||||
"config": {
|
|
||||||
"template": "terraforged:pine"
|
|
||||||
},
|
|
||||||
"chance": 0.3
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"default": {
|
|
||||||
"name": "terraforged:template",
|
|
||||||
"config": {
|
"config": {
|
||||||
"template": "terraforged:pine"
|
"features": [
|
||||||
|
{
|
||||||
|
"name": "terraforged:template",
|
||||||
|
"config": {
|
||||||
|
"template": "terraforged:pine"
|
||||||
|
},
|
||||||
|
"chance": 0.3
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"default": {
|
||||||
|
"name": "terraforged:template",
|
||||||
|
"config": {
|
||||||
|
"template": "terraforged:pine"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"decorator": {
|
||||||
|
"name": "terraforged:poisson_surface",
|
||||||
|
"config": {
|
||||||
|
"radius": 10,
|
||||||
|
"density_noise_scale": 120,
|
||||||
|
"density_noise_min": 0.5,
|
||||||
|
"density_noise_max": 1.5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"decorator": {
|
"decorator": {
|
||||||
"name": "minecraft:count_extra_heightmap",
|
"name": "minecraft:chance_passthrough",
|
||||||
"config": {
|
"config": {
|
||||||
"count": 0,
|
"chance": 0.02
|
||||||
"extra_chance": 0.02,
|
|
||||||
"extra_count": 1
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user