Region -> Tile

This commit is contained in:
dags- 2020-06-20 12:38:44 +01:00
parent 30faf7febf
commit f46272b4e4
32 changed files with 82 additions and 96 deletions

2
Engine

@ -1 +1 @@
Subproject commit 4a9677caf9d6805893747ce91ffb116ec9db64e6 Subproject commit 74305c79ee507602f7721478fbd5029bb5a9a51b

View File

@ -172,6 +172,12 @@
"display.terraforged.world.properties.sea_level": "Sea Level", "display.terraforged.world.properties.sea_level": "Sea Level",
"display.terraforged.world.properties.spawn_type": "Spawn Type", "display.terraforged.world.properties.spawn_type": "Spawn Type",
"display.terraforged.world.properties.world_height": "World Height", "display.terraforged.world.properties.world_height": "World Height",
"display.terraforged.world.transition_points": "Transition Points",
"display.terraforged.world.transition_points.beach": "Beach",
"display.terraforged.world.transition_points.coast": "Coast",
"display.terraforged.world.transition_points.deep_ocean": "Deep Ocean",
"display.terraforged.world.transition_points.inland": "Inland",
"display.terraforged.world.transition_points.shallow_ocean": "Shallow Ocean",
"generator.terraforged": "TerraForged", "generator.terraforged": "TerraForged",
"generator.terratest": "TerraTest", "generator.terratest": "TerraTest",
"tooltip.terraforged.climate.biome_edge_shape.gain": "Controls the gain subsequent noise octaves", "tooltip.terraforged.climate.biome_edge_shape.gain": "Controls the gain subsequent noise octaves",
@ -291,5 +297,10 @@
"tooltip.terraforged.world.continent.ocean_scale": "Controls the amount of ocean between continents", "tooltip.terraforged.world.continent.ocean_scale": "Controls the amount of ocean between continents",
"tooltip.terraforged.world.properties.sea_level": "Controls the sea level", "tooltip.terraforged.world.properties.sea_level": "Controls the sea level",
"tooltip.terraforged.world.properties.spawn_type": "Set whether spawn should be close to x=0,z=0 or the centre of the nearest continent", "tooltip.terraforged.world.properties.spawn_type": "Set whether spawn should be close to x=0,z=0 or the centre of the nearest continent",
"tooltip.terraforged.world.properties.world_height": "Controls the world height" "tooltip.terraforged.world.properties.world_height": "Controls the world height",
"tooltip.terraforged.world.transition_points.beach": "The beach transition point",
"tooltip.terraforged.world.transition_points.coast": "The coast transition point",
"tooltip.terraforged.world.transition_points.deep_ocean": "The deep ocean transition point",
"tooltip.terraforged.world.transition_points.inland": "The inland transition point",
"tooltip.terraforged.world.transition_points.shallow_ocean": "The shallow ocean transition point"
} }

View File

@ -34,7 +34,7 @@ import com.terraforged.feature.decorator.poisson.PoissonAtSurface;
import com.terraforged.feature.feature.DiskFeature; import com.terraforged.feature.feature.DiskFeature;
import com.terraforged.feature.feature.FreezeLayer; import com.terraforged.feature.feature.FreezeLayer;
import com.terraforged.fm.template.TemplateManager; import com.terraforged.fm.template.TemplateManager;
import com.terraforged.settings.SettingsHelper; import com.terraforged.chunk.settings.SettingsHelper;
import com.terraforged.util.DataPackFinder; import com.terraforged.util.DataPackFinder;
import com.terraforged.util.Environment; import com.terraforged.util.Environment;
import net.minecraft.world.biome.Biomes; import net.minecraft.world.biome.Biomes;

View File

@ -32,9 +32,9 @@ import com.terraforged.chunk.TerraContext;
import com.terraforged.chunk.TerraGenSettings; import com.terraforged.chunk.TerraGenSettings;
import com.terraforged.chunk.test.TestChunkGenerator; import com.terraforged.chunk.test.TestChunkGenerator;
import com.terraforged.gui.SettingsScreen; import com.terraforged.gui.SettingsScreen;
import com.terraforged.settings.DimesionSettings; import com.terraforged.chunk.settings.DimesionSettings;
import com.terraforged.settings.SettingsHelper; import com.terraforged.chunk.settings.SettingsHelper;
import com.terraforged.settings.TerraSettings; import com.terraforged.chunk.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.Terrains; import com.terraforged.world.terrain.Terrains;

View File

@ -38,10 +38,10 @@ import com.terraforged.chunk.generator.SurfaceGenerator;
import com.terraforged.chunk.generator.TerrainCarver; import com.terraforged.chunk.generator.TerrainCarver;
import com.terraforged.chunk.generator.TerrainGenerator; import com.terraforged.chunk.generator.TerrainGenerator;
import com.terraforged.core.cell.Cell; import com.terraforged.core.cell.Cell;
import com.terraforged.core.region.Region; import com.terraforged.core.tile.Tile;
import com.terraforged.core.region.Size; import com.terraforged.core.tile.Size;
import com.terraforged.core.region.chunk.ChunkReader; import com.terraforged.core.tile.chunk.ChunkReader;
import com.terraforged.core.region.gen.RegionCache; import com.terraforged.core.tile.gen.TileCache;
import com.terraforged.feature.BlockDataManager; import com.terraforged.feature.BlockDataManager;
import com.terraforged.fm.FeatureManager; import com.terraforged.fm.FeatureManager;
import com.terraforged.fm.data.DataManager; import com.terraforged.fm.data.DataManager;
@ -86,7 +86,7 @@ public class TerraChunkGenerator extends ChunkGenerator<GenerationSettings> {
private final List<ColumnDecorator> baseDecorators; private final List<ColumnDecorator> baseDecorators;
private final List<ColumnDecorator> postProcessors; private final List<ColumnDecorator> postProcessors;
private final RegionCache regionCache; private final TileCache tileCache;
public TerraChunkGenerator(TerraContext context, TerraBiomeProvider biomeProvider, GenerationSettings settings) { public TerraChunkGenerator(TerraContext context, TerraBiomeProvider biomeProvider, GenerationSettings settings) {
super(context.world, biomeProvider, settings); super(context.world, biomeProvider, settings);
@ -105,7 +105,7 @@ public class TerraChunkGenerator extends ChunkGenerator<GenerationSettings> {
this.geologyManager = TerraSetupFactory.createGeologyManager(context); this.geologyManager = TerraSetupFactory.createGeologyManager(context);
this.baseDecorators = TerraSetupFactory.createBaseDecorators(geologyManager, context); this.baseDecorators = TerraSetupFactory.createBaseDecorators(geologyManager, context);
this.postProcessors = TerraSetupFactory.createFeatureDecorators(context); this.postProcessors = TerraSetupFactory.createFeatureDecorators(context);
this.regionCache = context.cache; this.tileCache = context.cache;
try (DataManager data = TerraSetupFactory.createDataManager()) { try (DataManager data = TerraSetupFactory.createDataManager()) {
FeatureManager.initData(data); FeatureManager.initData(data);
@ -248,19 +248,19 @@ public class TerraChunkGenerator extends ChunkGenerator<GenerationSettings> {
} }
public final void queueChunk(int chunkX, int chunkZ) { public final void queueChunk(int chunkX, int chunkZ) {
int rx = regionCache.chunkToRegion(chunkX); int rx = tileCache.chunkToRegion(chunkX);
int rz = regionCache.chunkToRegion(chunkZ); int rz = tileCache.chunkToRegion(chunkZ);
regionCache.queueRegion(rx, rz); tileCache.queueRegion(rx, rz);
} }
public final Region getRegion(int chunkX, int chunkZ) { public final Tile getTile(int chunkX, int chunkZ) {
int rx = regionCache.chunkToRegion(chunkX); int rx = tileCache.chunkToRegion(chunkX);
int rz = regionCache.chunkToRegion(chunkZ); int rz = tileCache.chunkToRegion(chunkZ);
return regionCache.getRegion(rx, rz); return tileCache.getRegion(rx, rz);
} }
public final ChunkReader getChunkReader(int chunkX, int chunkZ) { public final ChunkReader getChunkReader(int chunkX, int chunkZ) {
return regionCache.getChunk(chunkX, chunkZ); return tileCache.getChunk(chunkX, chunkZ);
} }
public static ChunkReader getChunk(IWorld world, ChunkGenerator<?> generator) { public static ChunkReader getChunk(IWorld world, ChunkGenerator<?> generator) {

View File

@ -31,10 +31,10 @@ import com.terraforged.api.chunk.surface.ChunkSurfaceBuffer;
import com.terraforged.api.chunk.surface.SurfaceContext; import com.terraforged.api.chunk.surface.SurfaceContext;
import com.terraforged.config.PerfDefaults; import com.terraforged.config.PerfDefaults;
import com.terraforged.core.concurrent.thread.ThreadPools; import com.terraforged.core.concurrent.thread.ThreadPools;
import com.terraforged.core.region.gen.RegionCache; import com.terraforged.core.tile.gen.TileCache;
import com.terraforged.core.region.gen.RegionGenerator; import com.terraforged.core.tile.gen.TileGenerator;
import com.terraforged.material.Materials; import com.terraforged.material.Materials;
import com.terraforged.settings.TerraSettings; import com.terraforged.chunk.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;
@ -74,13 +74,13 @@ public class TerraContext extends GeneratorContext {
return new SurfaceContext(buffer, levels, terrain, factory.getClimate(), settings, world.getSeed()); return new SurfaceContext(buffer, levels, terrain, factory.getClimate(), settings, world.getSeed());
} }
public static RegionCache createCache(WorldGeneratorFactory factory) { public static TileCache createCache(WorldGeneratorFactory factory) {
CommentedConfig config = PerfDefaults.getAndPrintPerfSettings(); CommentedConfig config = PerfDefaults.getAndPrintPerfSettings();
boolean batching = config.getOrElse("batching",false); boolean batching = config.getOrElse("batching",false);
int tileSize = Math.min(PerfDefaults.MAX_TILE_SIZE, Math.max(2, config.getInt("tile_size"))); int tileSize = Math.min(PerfDefaults.MAX_TILE_SIZE, Math.max(2, config.getInt("tile_size")));
int batchCount = Math.min(PerfDefaults.MAX_BATCH_COUNT, Math.max(1, config.getInt("batch_count"))); int batchCount = Math.min(PerfDefaults.MAX_BATCH_COUNT, Math.max(1, config.getInt("batch_count")));
int threadCount = Math.min(PerfDefaults.MAX_THREAD_COUNT, Math.max(1, config.getInt("thread_count"))); int threadCount = Math.min(PerfDefaults.MAX_THREAD_COUNT, Math.max(1, config.getInt("thread_count")));
return RegionGenerator.builder() return TileGenerator.builder()
.pool(ThreadPools.create(threadCount, batching)) .pool(ThreadPools.create(threadCount, batching))
.size(tileSize, 2) .size(tileSize, 2)
.batch(batchCount) .batch(batchCount)

View File

@ -25,7 +25,7 @@
package com.terraforged.chunk; package com.terraforged.chunk;
import com.terraforged.settings.StructureSettings; import com.terraforged.chunk.settings.StructureSettings;
import net.minecraft.world.gen.OverworldGenSettings; import net.minecraft.world.gen.OverworldGenSettings;
public class TerraGenSettings extends OverworldGenSettings { public class TerraGenSettings extends OverworldGenSettings {

View File

@ -3,7 +3,7 @@ package com.terraforged.chunk.generator;
import com.terraforged.biome.provider.TerraBiomeProvider; import com.terraforged.biome.provider.TerraBiomeProvider;
import com.terraforged.chunk.TerraChunkGenerator; import com.terraforged.chunk.TerraChunkGenerator;
import com.terraforged.chunk.util.TerraContainer; import com.terraforged.chunk.util.TerraContainer;
import com.terraforged.core.region.chunk.ChunkReader; import com.terraforged.core.tile.chunk.ChunkReader;
import com.terraforged.world.terrain.decorator.Decorator; import com.terraforged.world.terrain.decorator.Decorator;
import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;

View File

@ -5,7 +5,7 @@ import com.terraforged.api.chunk.column.DecoratorContext;
import com.terraforged.chunk.TerraChunkGenerator; import com.terraforged.chunk.TerraChunkGenerator;
import com.terraforged.chunk.fix.RegionFix; import com.terraforged.chunk.fix.RegionFix;
import com.terraforged.chunk.util.TerraContainer; import com.terraforged.chunk.util.TerraContainer;
import com.terraforged.core.region.chunk.ChunkReader; import com.terraforged.core.tile.chunk.ChunkReader;
import com.terraforged.util.Environment; import com.terraforged.util.Environment;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld; import net.minecraft.world.IWorld;

View File

@ -6,7 +6,7 @@ import com.terraforged.api.chunk.surface.SurfaceContext;
import com.terraforged.chunk.TerraChunkGenerator; import com.terraforged.chunk.TerraChunkGenerator;
import com.terraforged.chunk.util.FastChunk; import com.terraforged.chunk.util.FastChunk;
import com.terraforged.chunk.util.TerraContainer; import com.terraforged.chunk.util.TerraContainer;
import com.terraforged.core.region.chunk.ChunkReader; import com.terraforged.core.tile.chunk.ChunkReader;
import net.minecraft.util.SharedSeedRandom; import net.minecraft.util.SharedSeedRandom;
import net.minecraft.world.chunk.IChunk; import net.minecraft.world.chunk.IChunk;
import net.minecraft.world.gen.Heightmap; import net.minecraft.world.gen.Heightmap;

View File

@ -5,7 +5,7 @@ import com.terraforged.chunk.TerraChunkGenerator;
import com.terraforged.chunk.column.ChunkPopulator; import com.terraforged.chunk.column.ChunkPopulator;
import com.terraforged.chunk.util.FastChunk; import com.terraforged.chunk.util.FastChunk;
import com.terraforged.chunk.util.TerraContainer; import com.terraforged.chunk.util.TerraContainer;
import com.terraforged.core.region.chunk.ChunkReader; import com.terraforged.core.tile.chunk.ChunkReader;
import com.terraforged.feature.TerrainHelper; import com.terraforged.feature.TerrainHelper;
import com.terraforged.world.climate.Climate; import com.terraforged.world.climate.Climate;
import com.terraforged.world.heightmap.Levels; import com.terraforged.world.heightmap.Levels;

View File

@ -1,4 +1,4 @@
package com.terraforged.settings; package com.terraforged.chunk.settings;
import com.terraforged.TerraWorld; import com.terraforged.TerraWorld;
import com.terraforged.core.serialization.annotation.Comment; import com.terraforged.core.serialization.annotation.Comment;

View File

@ -23,7 +23,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
package com.terraforged.settings; package com.terraforged.chunk.settings;
import com.terraforged.core.serialization.annotation.Comment; import com.terraforged.core.serialization.annotation.Comment;
import com.terraforged.core.serialization.annotation.Serializable; import com.terraforged.core.serialization.annotation.Serializable;

View File

@ -1,4 +1,4 @@
package com.terraforged.settings; package com.terraforged.chunk.settings;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;

View File

@ -23,7 +23,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
package com.terraforged.settings; package com.terraforged.chunk.settings;
import com.terraforged.core.serialization.annotation.Comment; import com.terraforged.core.serialization.annotation.Comment;
import com.terraforged.core.serialization.annotation.Range; import com.terraforged.core.serialization.annotation.Range;

View File

@ -23,7 +23,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
package com.terraforged.settings; package com.terraforged.chunk.settings;
import com.terraforged.core.serialization.annotation.Serializable; import com.terraforged.core.serialization.annotation.Serializable;
import com.terraforged.core.settings.Settings; import com.terraforged.core.settings.Settings;

View File

@ -28,10 +28,6 @@ package com.terraforged.chunk.test;
import com.terraforged.biome.provider.TerraBiomeProvider; import com.terraforged.biome.provider.TerraBiomeProvider;
import com.terraforged.chunk.TerraChunkGenerator; import com.terraforged.chunk.TerraChunkGenerator;
import com.terraforged.chunk.TerraContext; import com.terraforged.chunk.TerraContext;
import com.terraforged.core.cell.Cell;
import com.terraforged.core.cell.Populator;
import com.terraforged.world.GeneratorContext;
import com.terraforged.world.heightmap.WorldHeightmap;
import net.minecraft.world.gen.GenerationSettings; import net.minecraft.world.gen.GenerationSettings;
public class TestChunkGenerator extends TerraChunkGenerator { public class TestChunkGenerator extends TerraChunkGenerator {
@ -47,25 +43,4 @@ public class TestChunkGenerator extends TerraChunkGenerator {
public TerraBiomeProvider getBiomeProvider() { public TerraBiomeProvider getBiomeProvider() {
return biomeProvider; return biomeProvider;
} }
private static class TestHeightMap extends WorldHeightmap {
private final Populator populator;
public TestHeightMap(GeneratorContext context) {
super(context);
this.populator = getPopulator(Test.getTerrainType(context.terrain));
}
@Override
public void apply(Cell cell, float x, float y) {
super.apply(cell, x, y);
populator.apply(cell, x, y);
}
@Override
public void tag(Cell cell, float x, float y) {
populator.tag(cell, x, y);
}
}
} }

View File

@ -2,10 +2,10 @@ 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.Heightmap;
import com.terraforged.world.terrain.Terrains; import com.terraforged.world.terrain.Terrains;
public class TestHeightMap extends WorldHeightmap { public class TestHeightMap extends Heightmap {
private final Terrains terrains; private final Terrains terrains;

View File

@ -3,7 +3,7 @@ package com.terraforged.chunk.util;
import com.terraforged.api.biome.BiomeVariant; import com.terraforged.api.biome.BiomeVariant;
import com.terraforged.biome.provider.TerraBiomeProvider; import com.terraforged.biome.provider.TerraBiomeProvider;
import com.terraforged.core.cell.Cell; import com.terraforged.core.cell.Cell;
import com.terraforged.core.region.chunk.ChunkReader; import com.terraforged.core.tile.chunk.ChunkReader;
import com.terraforged.core.util.PosIterator; import com.terraforged.core.util.PosIterator;
import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;

View File

@ -44,7 +44,7 @@ import com.terraforged.command.search.TerrainSearchTask;
import com.terraforged.core.cell.Cell; import com.terraforged.core.cell.Cell;
import com.terraforged.core.concurrent.Resource; import com.terraforged.core.concurrent.Resource;
import com.terraforged.data.DataGen; import com.terraforged.data.DataGen;
import com.terraforged.settings.SettingsHelper; import com.terraforged.chunk.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.Terrains; import com.terraforged.world.terrain.Terrains;

View File

@ -2,7 +2,7 @@ package com.terraforged.data;
import com.terraforged.core.util.NameUtil; import com.terraforged.core.util.NameUtil;
import com.terraforged.gui.preview2.PreviewSettings; import com.terraforged.gui.preview2.PreviewSettings;
import com.terraforged.settings.TerraSettings; import com.terraforged.chunk.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 net.minecraft.nbt.INBT; import net.minecraft.nbt.INBT;

View File

@ -6,7 +6,7 @@ import com.terraforged.core.cell.Cell;
import com.terraforged.core.concurrent.Resource; import com.terraforged.core.concurrent.Resource;
import com.terraforged.core.concurrent.cache.SafeCloseable; import com.terraforged.core.concurrent.cache.SafeCloseable;
import com.terraforged.core.concurrent.pool.ObjectPool; import com.terraforged.core.concurrent.pool.ObjectPool;
import com.terraforged.core.region.chunk.ChunkReader; import com.terraforged.core.tile.chunk.ChunkReader;
import com.terraforged.world.heightmap.Levels; import com.terraforged.world.heightmap.Levels;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld; import net.minecraft.world.IWorld;

View File

@ -2,7 +2,7 @@ package com.terraforged.feature.decorator.poisson;
import com.terraforged.chunk.TerraChunkGenerator; import com.terraforged.chunk.TerraChunkGenerator;
import com.terraforged.core.cell.Cell; import com.terraforged.core.cell.Cell;
import com.terraforged.core.region.chunk.ChunkReader; import com.terraforged.core.tile.chunk.ChunkReader;
import com.terraforged.n2d.Module; import com.terraforged.n2d.Module;
import com.terraforged.n2d.Source; import com.terraforged.n2d.Source;
import com.terraforged.n2d.util.NoiseUtil; import com.terraforged.n2d.util.NoiseUtil;

View File

@ -32,8 +32,8 @@ import com.terraforged.gui.page.SimplePage;
import com.terraforged.gui.page.SimplePreviewPage; import com.terraforged.gui.page.SimplePreviewPage;
import com.terraforged.gui.page.WorldPage; import com.terraforged.gui.page.WorldPage;
import com.terraforged.gui.preview2.PreviewPage; import com.terraforged.gui.preview2.PreviewPage;
import com.terraforged.settings.SettingsHelper; import com.terraforged.chunk.settings.SettingsHelper;
import com.terraforged.settings.TerraSettings; import com.terraforged.chunk.settings.TerraSettings;
import com.terraforged.util.nbt.NBTHelper; import com.terraforged.util.nbt.NBTHelper;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.IGuiEventListener; import net.minecraft.client.gui.IGuiEventListener;

View File

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

View File

@ -1,6 +1,6 @@
package com.terraforged.gui.page; package com.terraforged.gui.page;
import com.terraforged.settings.TerraSettings; import com.terraforged.chunk.settings.TerraSettings;
import com.terraforged.util.nbt.NBTHelper; import com.terraforged.util.nbt.NBTHelper;
import java.util.function.Function; import java.util.function.Function;

View File

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

View File

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

View File

@ -30,9 +30,9 @@ 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.thread.ThreadPools; import com.terraforged.core.concurrent.thread.ThreadPools;
import com.terraforged.core.region.Region; import com.terraforged.core.tile.Tile;
import com.terraforged.core.region.Size; import com.terraforged.core.tile.Size;
import com.terraforged.core.region.gen.RegionGenerator; import com.terraforged.core.tile.gen.TileGenerator;
import com.terraforged.core.settings.Settings; import com.terraforged.core.settings.Settings;
import com.terraforged.n2d.util.NoiseUtil; import com.terraforged.n2d.util.NoiseUtil;
import com.terraforged.util.nbt.NBTHelper; import com.terraforged.util.nbt.NBTHelper;
@ -68,8 +68,8 @@ public class Preview extends Button {
private int seed; private int seed;
private long lastUpdate = 0L; private long lastUpdate = 0L;
private Settings settings = new Settings(); private Settings settings = new Settings();
private CacheEntry<Region> task = null; private CacheEntry<Tile> task = null;
private Region region = null; private Tile tile = null;
private String[] labels = {"Area: ", "Terrain: ", "Biome: "}; private String[] labels = {"Area: ", "Terrain: ", "Biome: "};
private String[] values = {"", "", ""}; private String[] values = {"", "", ""};
@ -130,8 +130,8 @@ public class Preview extends Button {
private void preRender() { private void preRender() {
if (task != null && task.isDone()) { if (task != null && task.isDone()) {
try { try {
region = task.get(); tile = task.get();
render(region); render(tile);
} catch (Throwable t) { } catch (Throwable t) {
t.printStackTrace(); t.printStackTrace();
} finally { } finally {
@ -140,7 +140,7 @@ public class Preview extends Button {
} }
} }
private void render(Region region) { private void render(Tile tile) {
NativeImage image = texture.getTextureData(); NativeImage image = texture.getTextureData();
if (image == null) { if (image == null) {
return; return;
@ -150,7 +150,7 @@ public class Preview extends Button {
Levels levels = new Levels(settings.world); Levels levels = new Levels(settings.world);
int stroke = 2; int stroke = 2;
int width = region.getBlockSize().size; int width = tile.getBlockSize().size;
int zoom = (101 - previewSettings.zoom); int zoom = (101 - previewSettings.zoom);
int half = width / 2; int half = width / 2;
@ -163,7 +163,7 @@ public class Preview extends Button {
float waterLevelModifier = settings.world.properties.seaLevel / (float) settings.world.properties.worldHeight; float waterLevelModifier = settings.world.properties.seaLevel / (float) settings.world.properties.worldHeight;
float imageWaterLevelY = image.getHeight() - 1 - (waterLevelModifier * SLICE_HEIGHT * unit); float imageWaterLevelY = image.getHeight() - 1 - (waterLevelModifier * SLICE_HEIGHT * unit);
region.iterate((cell, x, z) -> { tile.iterate((cell, x, z) -> {
if (x < stroke || z < stroke || x >= width - stroke || z >= width - stroke) { if (x < stroke || z < stroke || x >= width - stroke || z >= width - stroke) {
image.setPixelRGBA(x, z, Color.BLACK.getRGB()); image.setPixelRGBA(x, z, Color.BLACK.getRGB());
} else { } else {
@ -192,7 +192,7 @@ public class Preview extends Button {
texture.updateDynamicTexture(); texture.updateDynamicTexture();
} }
private CacheEntry<Region> generate(Settings settings, CompoundNBT prevSettings) { private CacheEntry<Tile> generate(Settings settings, CompoundNBT prevSettings) {
NBTHelper.deserialize(prevSettings, previewSettings); NBTHelper.deserialize(prevSettings, previewSettings);
settings.world.seed = seed; settings.world.seed = seed;
this.settings = settings; this.settings = settings;
@ -202,7 +202,7 @@ public class Preview extends Button {
MutableVeci center = new MutableVeci(); MutableVeci center = new MutableVeci();
context.factory.getHeightmap().getContinent().getNearestCenter(offsetX, offsetZ, center); context.factory.getHeightmap().getContinent().getNearestCenter(offsetX, offsetZ, center);
RegionGenerator renderer = RegionGenerator.builder() TileGenerator renderer = TileGenerator.builder()
.pool(ThreadPools.getPool()) .pool(ThreadPools.getPool())
.size(FACTOR, 0) .size(FACTOR, 0)
.factory(context.factory) .factory(context.factory)
@ -215,20 +215,20 @@ public class Preview extends Button {
} }
private void updateLegend(int mx ,int my) { private void updateLegend(int mx ,int my) {
if (region != null) { if (tile != null) {
int left = this.x; int left = this.x;
int top = this.y; int top = this.y;
float size = this.width; float size = this.width;
int zoom = (101 - previewSettings.zoom); int zoom = (101 - previewSettings.zoom);
int width = Math.max(1, region.getBlockSize().size * zoom); int width = Math.max(1, tile.getBlockSize().size * zoom);
int height = Math.max(1, region.getBlockSize().size * zoom); int height = Math.max(1, tile.getBlockSize().size * zoom);
values[0] = width + "x" + height; values[0] = width + "x" + height;
if (mx >= left && mx <= left + size && my >= top && my <= top + size) { if (mx >= left && mx <= left + size && my >= top && my <= top + size) {
float fx = (mx - left) / size; float fx = (mx - left) / size;
float fz = (my - top) / size; float fz = (my - top) / size;
int ix = NoiseUtil.round(fx * region.getBlockSize().size); int ix = NoiseUtil.round(fx * tile.getBlockSize().size);
int iz = NoiseUtil.round(fz * region.getBlockSize().size); int iz = NoiseUtil.round(fz * tile.getBlockSize().size);
Cell cell = region.getCell(ix, iz); Cell cell = tile.getCell(ix, iz);
values[1] = getTerrainName(cell); values[1] = getTerrainName(cell);
values[2] = getBiomeName(cell); values[2] = getBiomeName(cell);
} }

View File

@ -28,7 +28,7 @@ package com.terraforged.gui.preview;
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.UpdatablePage; import com.terraforged.gui.page.UpdatablePage;
import com.terraforged.settings.TerraSettings; import com.terraforged.chunk.settings.TerraSettings;
import com.terraforged.util.nbt.NBTHelper; import com.terraforged.util.nbt.NBTHelper;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;

View File

@ -3,11 +3,11 @@ package com.terraforged.gui.preview2;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.terraforged.core.concurrent.thread.ThreadPool; import com.terraforged.core.concurrent.thread.ThreadPool;
import com.terraforged.core.concurrent.thread.ThreadPools; import com.terraforged.core.concurrent.thread.ThreadPools;
import com.terraforged.core.region.gen.RegionGenerator; import com.terraforged.core.tile.gen.TileGenerator;
import com.terraforged.core.render.RenderAPI; import com.terraforged.core.render.RenderAPI;
import com.terraforged.core.render.RenderSettings; import com.terraforged.core.render.RenderSettings;
import com.terraforged.core.render.RenderWorld; import com.terraforged.core.render.RenderWorld;
import com.terraforged.settings.TerraSettings; import com.terraforged.chunk.settings.TerraSettings;
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.continent.SpawnType; import com.terraforged.world.continent.SpawnType;
@ -100,7 +100,7 @@ public class Preview extends Widget {
offsetX = center.x; offsetX = center.x;
offsetZ = center.z; offsetZ = center.z;
RegionGenerator generator = RegionGenerator.builder() TileGenerator generator = TileGenerator.builder()
.pool(threadPool) .pool(threadPool)
.size(size, 0) .size(size, 0)
.factory(context.factory) .factory(context.factory)

View File

@ -3,7 +3,7 @@ package com.terraforged.gui.preview2;
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.UpdatablePage; import com.terraforged.gui.page.UpdatablePage;
import com.terraforged.settings.TerraSettings; import com.terraforged.chunk.settings.TerraSettings;
import com.terraforged.util.nbt.NBTHelper; import com.terraforged.util.nbt.NBTHelper;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;