From 93b7abff6210a9832858fcc96034ec8bc4ff86b3 Mon Sep 17 00:00:00 2001 From: dags- Date: Thu, 16 Jan 2020 21:33:41 +0000 Subject: [PATCH] much --- .gitmodules | 3 ++ FeatureManager | 2 +- TerraForgedApp/build.gradle | 5 +- TerraForgedCore/build.gradle | 2 - .../com/terraforged/core/cell/Extent.java | 2 - .../com/terraforged/core/cell/Populator.java | 13 ++--- .../terraforged/core/module/CellLookup.java | 22 +++++--- .../core/module/CellLookupOffset.java | 21 +++++--- .../com/terraforged/core/region/Region.java | 47 +++++++++++----- .../core/region/RegionGenerator.java | 4 +- .../com/terraforged/core/region/Size.java | 2 +- .../core/region/chunk/ChunkReader.java | 1 - .../core/util/concurrent/ThreadPool.java | 1 - .../core/world/climate/Climate.java | 54 ++----------------- .../world/continent/ContinentBlender.java | 2 +- .../continent/ContinentMultiBlender.java | 2 +- .../continent/VoronoiContinentModule.java | 11 ++-- .../core/world/heightmap/Heightmap.java | 12 +---- .../core/world/heightmap/RegionExtent.java | 8 --- .../core/world/heightmap/WorldHeightmap.java | 14 ++--- .../core/world/river/PosGenerator.java | 21 +++++--- TerraForgedMod | 1 + settings.gradle | 6 ++- 23 files changed, 120 insertions(+), 136 deletions(-) create mode 160000 TerraForgedMod diff --git a/.gitmodules b/.gitmodules index 94e857f..cef1e47 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "Noise2D"] path = Noise2D url = https://github.com/TerraForged/Noise2D.git +[submodule "TerraForgedMod"] + path = TerraForgedMod + url = https://github.com/dags-/TerraForgedMod.git diff --git a/FeatureManager b/FeatureManager index 1fd2cd9..4083d60 160000 --- a/FeatureManager +++ b/FeatureManager @@ -1 +1 @@ -Subproject commit 1fd2cd9f133c861c613edfb2d49fe1a801fe3366 +Subproject commit 4083d609c0023744eef091e3f74ac871806b5565 diff --git a/TerraForgedApp/build.gradle b/TerraForgedApp/build.gradle index 1537abc..d696079 100644 --- a/TerraForgedApp/build.gradle +++ b/TerraForgedApp/build.gradle @@ -1,7 +1,3 @@ -plugins { - id "java" -} - repositories { mavenCentral() jcenter() @@ -15,4 +11,5 @@ dependencies { jar { manifest { attributes "Main-Class": "com.terraforged.app.Main" } + from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } } \ No newline at end of file diff --git a/TerraForgedCore/build.gradle b/TerraForgedCore/build.gradle index 664feb8..3389df0 100644 --- a/TerraForgedCore/build.gradle +++ b/TerraForgedCore/build.gradle @@ -1,5 +1,3 @@ -apply plugin: "java" - dependencies { compile project(":Noise2D") } \ No newline at end of file diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/cell/Extent.java b/TerraForgedCore/src/main/java/com/terraforged/core/cell/Extent.java index ab7e3ba..e320747 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/cell/Extent.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/cell/Extent.java @@ -4,7 +4,5 @@ import com.terraforged.core.world.terrain.Terrain; public interface Extent { - Cell getCell(int x, int z); - void visit(int minX, int minZ, int maxX, int maxZ, Cell.Visitor visitor); } diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/cell/Populator.java b/TerraForgedCore/src/main/java/com/terraforged/core/cell/Populator.java index 47564c8..ed9989e 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/cell/Populator.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/cell/Populator.java @@ -1,23 +1,20 @@ package com.terraforged.core.cell; -import me.dags.noise.Module; import com.terraforged.core.util.concurrent.ObjectPool; import com.terraforged.core.world.terrain.Terrain; +import me.dags.noise.Module; -public interface Populator extends Module { +public interface Populator extends Module { void apply(Cell cell, float x, float y); void tag(Cell cell, float x, float y); + @Override default float getValue(float x, float z) { try (ObjectPool.Item> cell = Cell.pooled()) { - return getValue(cell.getValue(), x, z); + apply(cell.getValue(), x, z); + return cell.getValue().value; } } - - default float getValue(Cell cell, float x, float z) { - apply(cell, x, z); - return cell.value; - } } diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/module/CellLookup.java b/TerraForgedCore/src/main/java/com/terraforged/core/module/CellLookup.java index f045f4f..6bc9f16 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/module/CellLookup.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/module/CellLookup.java @@ -1,21 +1,29 @@ package com.terraforged.core.module; -import me.dags.noise.Module; +import com.terraforged.core.cell.Cell; +import com.terraforged.core.cell.Populator; +import com.terraforged.core.world.heightmap.Heightmap; +import com.terraforged.core.world.terrain.Terrain; -public class CellLookup implements Module { +public class CellLookup implements Populator { private final int scale; - private final Module module; + private final Heightmap heightmap; - public CellLookup(Module module, int scale) { - this.module = module; + public CellLookup(Heightmap heightmap, int scale) { + this.heightmap = heightmap; this.scale = scale; } @Override - public float getValue(float x, float y) { + public void apply(Cell cell, float x, float y) { float px = x * scale; float pz = y * scale; - return module.getValue(px, pz); + heightmap.getValue(px, pz); + } + + @Override + public void tag(Cell cell, float x, float y) { + } } diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/module/CellLookupOffset.java b/TerraForgedCore/src/main/java/com/terraforged/core/module/CellLookupOffset.java index 91a6fe4..76e50f0 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/module/CellLookupOffset.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/module/CellLookupOffset.java @@ -1,30 +1,39 @@ package com.terraforged.core.module; +import com.terraforged.core.cell.Cell; +import com.terraforged.core.cell.Populator; +import com.terraforged.core.world.heightmap.Heightmap; +import com.terraforged.core.world.terrain.Terrain; import me.dags.noise.Module; import me.dags.noise.util.NoiseUtil; -public class CellLookupOffset implements Module { +public class CellLookupOffset implements Populator { private final int scale; - private final Module lookup; private final Module direction; private final Module strength; + private final Heightmap heightmap; - public CellLookupOffset(Module lookup, Module direction, Module strength, int scale) { + public CellLookupOffset(Heightmap heightmap, Module direction, Module strength, int scale) { this.scale = scale; - this.lookup = lookup; + this.heightmap = heightmap; this.direction = direction; this.strength = strength; } @Override - public float getValue(float x, float y) { + public void apply(Cell cell, float x, float y) { float px = x * scale; float pz = y * scale; float str = strength.getValue(x, y); float dir = direction.getValue(x, y) * NoiseUtil.PI2; float dx = NoiseUtil.sin(dir) * str; float dz = NoiseUtil.cos(dir) * str; - return lookup.getValue(px + dx, pz + dz); + heightmap.visit(cell, px + dx, pz + dz); + } + + @Override + public void tag(Cell cell, float x, float y) { + } } diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/region/Region.java b/TerraForgedCore/src/main/java/com/terraforged/core/region/Region.java index dd9de3c..626e0f7 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/region/Region.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/region/Region.java @@ -77,7 +77,6 @@ public class Region implements Extent { return new FilterRegion(); } - @Override public Cell getCell(int blockX, int blockZ) { int relBlockX = blockSize.border + blockSize.mask(blockX); int relBlockZ = blockSize.border + blockSize.mask(blockZ); @@ -131,6 +130,26 @@ public class Region implements Extent { } } + public void check() { + for (int dz = 0; dz < chunkSize.total; dz++) { + for (int dx = 0; dx < chunkSize.total; dx++) { + int index = chunkSize.indexOf(dx, dz); + if (chunks[index] == null) { + throw new NullPointerException("Null chunk " + dx + ":" + dz); + } + } + } + + for (int dz = 0; dz < blockSize.total; dz++) { + for (int dx = 0; dx < blockSize.total; dx++) { + int index = blockSize.indexOf(dx, dz); + if (blocks[index] == null) { + throw new NullPointerException("Null block " + dx + ":" + dz); + } + } + } + } + public void decorate(Collection decorators) { for (int dz = 0; dz < blockSize.total; dz++) { for (int dx = 0; dx < blockSize.total; dx++) { @@ -233,14 +252,18 @@ public class Region implements Extent { private final int chunkZ; private final int blockX; private final int blockZ; - private final int relBlockX; - private final int relBlockZ; + private final int regionBlockX; + private final int regionBlockZ; - private GenChunk(int relChunkX, int relChunkZ) { - this.relBlockX = relChunkX << 4; - this.relBlockZ = relChunkZ << 4; - this.chunkX = Region.this.chunkX + relChunkX; - this.chunkZ = Region.this.chunkZ + relChunkZ; + // the coordinate of the chunk within this region (relative to 0,0) + private GenChunk(int regionChunkX, int regionChunkZ) { + // the block coordinate of this chunk within this region (relative 0,0) + this.regionBlockX = regionChunkX << 4; + this.regionBlockZ = regionChunkZ << 4; + // the real coordinate of this chunk within the world + this.chunkX = Region.this.chunkX + regionChunkX; + this.chunkZ = Region.this.chunkZ + regionChunkZ; + // the real block coordinate of this chunk within the world this.blockX = chunkX << 4; this.blockZ = chunkZ << 4; } @@ -267,16 +290,16 @@ public class Region implements Extent { @Override public Cell getCell(int blockX, int blockZ) { - int relX = relBlockX + (blockX & 15); - int relZ = relBlockZ + (blockZ & 15); + int relX = regionBlockX + (blockX & 15); + int relZ = regionBlockZ + (blockZ & 15); int index = blockSize.indexOf(relX, relZ); return blocks[index]; } @Override public Cell genCell(int blockX, int blockZ) { - int relX = relBlockX + (blockX & 15); - int relZ = relBlockZ + (blockZ & 15); + int relX = regionBlockX + (blockX & 15); + int relZ = regionBlockZ + (blockZ & 15); int index = blockSize.indexOf(relX, relZ); return computeCell(index); } diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/region/RegionGenerator.java b/TerraForgedCore/src/main/java/com/terraforged/core/region/RegionGenerator.java index c5dc74c..9c51540 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/region/RegionGenerator.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/region/RegionGenerator.java @@ -84,13 +84,13 @@ public class RegionGenerator implements RegionExtent { try (ThreadPool.Batcher batcher = threadPool.batcher(region.getChunkCount())) { region.generateZoom(generator.getHeightmap(), centerX, centerZ, zoom, batcher); } + region.check(); postProcess(region, generator, centerX, centerZ, zoom, filter); return region; } } - private void postProcess(Region region, WorldGenerator generator, float centerX, float centerZ, float zoom, - boolean filter) { + private void postProcess(Region region, WorldGenerator generator, float centerX, float centerZ, float zoom, boolean filter) { Filterable filterable = region.filterable(); if (filter) { generator.getFilters().setRegion(region.getRegionX(), region.getRegionZ()); diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/region/Size.java b/TerraForgedCore/src/main/java/com/terraforged/core/region/Size.java index e9ec60d..cab8ea2 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/region/Size.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/region/Size.java @@ -19,7 +19,7 @@ public class Size { } public int indexOf(int x, int z) { - return z * total + x; + return (z * total) + x; } public static int chunkToBlock(int i) { diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/region/chunk/ChunkReader.java b/TerraForgedCore/src/main/java/com/terraforged/core/region/chunk/ChunkReader.java index 9115a9a..d203e1d 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/region/chunk/ChunkReader.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/region/chunk/ChunkReader.java @@ -5,7 +5,6 @@ import com.terraforged.core.world.terrain.Terrain; public interface ChunkReader extends ChunkHolder { - @Override Cell getCell(int dx, int dz); @Override diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/ThreadPool.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/ThreadPool.java index 507cdbd..5bccde6 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/ThreadPool.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/ThreadPool.java @@ -66,7 +66,6 @@ public class ThreadPool { for (Future future : tasks) { if (!future.isDone()) { hasMore = true; - break; } } } diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/climate/Climate.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/climate/Climate.java index a1f9529..9b0dedb 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/climate/Climate.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/climate/Climate.java @@ -25,8 +25,6 @@ public class Climate { private final Rand rand; private final Module treeLine; - private final Module heightMap; - private final Module offsetHeightMap; private final Module offsetX; private final Module offsetY; @@ -40,31 +38,9 @@ public class Climate { this.biomeNoise = new ClimateModule(context.seed, context.settings.generator); - Module warpX = Source.perlin(context.seed.next(), warpScale, 2); - Module warpZ = Source.perlin(context.seed.next(), warpScale, 2); - - Module windDirection = Source.cubic(context.seed.next(), cellSize, 1); - Module windStrength = Source.perlin(context.seed.next(), cellSize, 1) - .scale(cellSize * 1.5) - .bias(cellSize * 0.5); - this.treeLine = Source.perlin(context.seed.next(), context.settings.generator.biome.biomeSize * 2, 1) .scale(0.1).bias(0.4); - this.heightMap = Source.build(cellSeed, cellSize, 1) - .distFunc(DistanceFunc.NATURAL) - .cellFunc(CellFunc.NOISE_LOOKUP) - .source(new CellLookup(heightmap::getValue, cellSize)) - .cell() - .warp(warpX, warpZ, warpStrength); - - this.offsetHeightMap = Source.build(cellSeed, cellSize, 1) - .distFunc(DistanceFunc.NATURAL) - .cellFunc(CellFunc.NOISE_LOOKUP) - .source(new CellLookupOffset(heightmap::getValue, windDirection, windStrength, cellSize)) - .cell() - .warp(warpX, warpZ, warpStrength); - this.rand = new Rand(Source.builder().seed(context.seed.next())); this.offsetX = context.settings.generator.biomeEdgeNoise.build(context.seed.next()); this.offsetY = context.settings.generator.biomeEdgeNoise.build(context.seed.next()); @@ -76,14 +52,6 @@ public class Climate { return rand; } - public float getCellHeight(float x, float z) { - return heightMap.getValue(x, z); - } - - public float getOffsetCellHeight(float x, float z) { - return offsetHeightMap.getValue(x, z); - } - public float getOffsetX(float x, float z, int distance) { return offsetX.getValue(x, z) * distance; } @@ -98,26 +66,12 @@ public class Climate { public void apply(Cell cell, float x, float z, boolean mask) { biomeNoise.apply(cell, x, z, mask); - modify(cell, x, z); + + modifyTemp(cell, x, z); } - private void modify(Cell cell, float x, float z) { - float height = getCellHeight(x, z); - float height1 = getOffsetCellHeight(x, z); - float moistDelta = 0F; - if (height > seaLevel) { - if (height1 < seaLevel) { - moistDelta = 0.7F; - } else if (height - height1 > 0.2) { - moistDelta = height - height1; - } else if (height1 - height > 0.1) { - moistDelta = Math.max(-0.5F, height - height1) * 2F; - } - } - - float moistChange = moistureModifier * moistDelta; - cell.moisture = NoiseUtil.clamp(cell.moisture + moistChange, 0, 1); - + private void modifyTemp(Cell cell, float x, float z) { + float height = cell.value; if (height > upperHeight) { cell.temperature = Math.max(0, cell.temperature - temperatureModifier); return; diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/ContinentBlender.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/ContinentBlender.java index ecc5134..5eb9459 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/ContinentBlender.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/ContinentBlender.java @@ -15,7 +15,7 @@ public class ContinentBlender extends Blender { } @Override - public float getValue(Cell cell, float x, float z) { + public float getSelect(Cell cell, float x, float z) { return cell.continentEdge; } } diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/ContinentMultiBlender.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/ContinentMultiBlender.java index 564534a..61cf63d 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/ContinentMultiBlender.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/ContinentMultiBlender.java @@ -16,7 +16,7 @@ public class ContinentMultiBlender extends MultiBlender { } @Override - public float getValue(Cell cell, float x, float z) { + public float getSelect(Cell cell, float x, float z) { return cell.continentEdge; } } diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/VoronoiContinentModule.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/VoronoiContinentModule.java index c59145e..34ed53c 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/VoronoiContinentModule.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/VoronoiContinentModule.java @@ -52,12 +52,15 @@ public class VoronoiContinentModule implements Populator { @Override public float getValue(float x, float y) { - Cell cell = new Cell<>(); - apply(cell, x, y); - return cell.continentEdge; + if (true) { + throw new RuntimeException("no pls!"); + } else { + Cell cell = new Cell<>(); + apply(cell, x, y); + return cell.continentEdge; + } } - @Override public void apply(Cell cell, final float x, final float y) { float ox = warp.getOffsetX(x, y); diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/Heightmap.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/Heightmap.java index d5ec58a..48eda8b 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/Heightmap.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/Heightmap.java @@ -1,26 +1,18 @@ package com.terraforged.core.world.heightmap; import com.terraforged.core.cell.Cell; -import com.terraforged.core.cell.Populator; import com.terraforged.core.cell.Extent; +import com.terraforged.core.cell.Populator; import com.terraforged.core.region.Size; import com.terraforged.core.util.concurrent.ObjectPool; import com.terraforged.core.world.climate.Climate; -import com.terraforged.core.world.river.RiverManager; import com.terraforged.core.world.terrain.Terrain; -import java.rmi.UnexpectedException; - public interface Heightmap extends Populator, Extent { Climate getClimate(); - RiverManager getRiverManager(); - - @Override - default Cell getCell(int x, int z) { - throw new RuntimeException("Don't use this pls"); - } + void visit(Cell cell, float x, float z); @Override default void visit(int minX, int minZ, int maxX, int maxZ, Cell.Visitor visitor) { diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/RegionExtent.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/RegionExtent.java index 6e7cc99..dab72a0 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/RegionExtent.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/RegionExtent.java @@ -37,14 +37,6 @@ public interface RegionExtent extends Extent { return regions; } - @Override - default Cell getCell(int x, int z) { - int regionX = chunkToRegion(Size.blockToChunk(x)); - int regionZ = chunkToRegion(Size.blockToChunk(z)); - Region region = getRegion(regionX, regionZ); - return region.getCell(x, z); - } - @Override default void visit(int minX, int minZ, int maxX, int maxZ, Cell.Visitor visitor) { int minRegionX = chunkToRegion(Size.blockToChunk(minX)); diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/WorldHeightmap.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/WorldHeightmap.java index 1befc2a..cb16a1d 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/WorldHeightmap.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/WorldHeightmap.java @@ -1,9 +1,5 @@ package com.terraforged.core.world.heightmap; -import me.dags.noise.Module; -import me.dags.noise.Source; -import me.dags.noise.func.EdgeFunc; -import me.dags.noise.func.Interpolation; import com.terraforged.core.cell.Cell; import com.terraforged.core.cell.Populator; import com.terraforged.core.module.Blender; @@ -23,6 +19,10 @@ import com.terraforged.core.world.terrain.Terrain; import com.terraforged.core.world.terrain.TerrainPopulator; import com.terraforged.core.world.terrain.Terrains; import com.terraforged.core.world.terrain.provider.TerrainProvider; +import me.dags.noise.Module; +import me.dags.noise.Source; +import me.dags.noise.func.EdgeFunc; +import me.dags.noise.func.Interpolation; public class WorldHeightmap implements Heightmap { @@ -144,8 +144,10 @@ public class WorldHeightmap implements Heightmap { this.riverManager = new RiverManager(this, context); } - public RiverManager getRiverManager() { - return riverManager; + @Override + public void visit(Cell cell, float x, float z) { + continent.apply(cell, x, z); + root.apply(cell, x, z); } @Override diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/river/PosGenerator.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/river/PosGenerator.java index 0d9cba2..16da003 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/river/PosGenerator.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/river/PosGenerator.java @@ -67,8 +67,8 @@ public class PosGenerator { int pz = z + dz; int wx = (int) domain.getX(px, pz); int wz = (int) domain.getY(px, pz); - float value1 = heightmap.getValue(lookup, px, pz); - float value2 = heightmap.getValue(lookup, wx, wz); + float value1 = getHeight(px, pz); + float value2 = getHeight(wx, wz); RiverNode.Type type1 = RiverNode.getType(value1); RiverNode.Type type2 = RiverNode.getType(value2); if (type1 == type2 && type1 != RiverNode.Type.NONE) { @@ -91,8 +91,8 @@ public class PosGenerator { } int wx = (int) domain.getX(px, pz); int wz = (int) domain.getY(px, pz); - float value1 = heightmap.getValue(lookup, px, pz); - float value2 = heightmap.getValue(lookup, wx, wz); + float value1 = getHeight(px, pz); + float value2 = getHeight(wx, wz); RiverNode.Type type1 = RiverNode.getType(value1); RiverNode.Type type2 = RiverNode.getType(value2); if (type1 == type2 && type1 == point.type.opposite()) { @@ -112,8 +112,8 @@ public class PosGenerator { int pz = z + dz; int wx = (int) domain.getX(px, pz); int wz = (int) domain.getY(px, pz); - float value1 = heightmap.getValue(lookup, px, pz); - float value2 = heightmap.getValue(lookup, wx, wz); + float value1 = getHeight(px, pz); + float value2 = getHeight(wx, wz); RiverNode.Type type1 = RiverNode.getType(value1); RiverNode.Type type2 = RiverNode.getType(value2); if (type1 == type2 && type1 == match) { @@ -130,8 +130,8 @@ public class PosGenerator { int pz = z + dz; int wx = (int) domain.getX(px, pz); int wz = (int) domain.getY(px, pz); - float value1 = heightmap.getValue(lookup, px, pz); - float value2 = heightmap.getValue(lookup, wx, wz); + float value1 = getHeight(px, pz); + float value2 = getHeight(wx, wz); if (value1 > minHeight && value2 > minHeight) { return new RiverNode(px, pz, RiverNode.Type.START); } @@ -139,6 +139,11 @@ public class PosGenerator { return null; } + private float getHeight(int x, int z) { + heightmap.visit(lookup, x, z); + return lookup.value; + } + private static int index(int x, int z) { return z * 2 + x; } diff --git a/TerraForgedMod b/TerraForgedMod new file mode 160000 index 0000000..576c491 --- /dev/null +++ b/TerraForgedMod @@ -0,0 +1 @@ +Subproject commit 576c491d5a156d48b1bf1e17f95d1b8272f2e5b5 diff --git a/settings.gradle b/settings.gradle index 0c15ec1..8f3b926 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,6 @@ rootProject.name = "TerraForged" -include ":Noise2D", ":FeatureManager", ":TerraForgedCore", ":TerraForgedApp" \ No newline at end of file +include ":Noise2D" +include ":FeatureManager" +include ":TerraForgedCore" +include ":TerraForgedApp" +include ":TerraForgedMod" \ No newline at end of file