From 4c4165400d7269c2e14534aa2940d5b49ba5fd1e Mon Sep 17 00:00:00 2001 From: dags- Date: Tue, 21 Jan 2020 16:53:58 +0000 Subject: [PATCH] Start work on tagging the things: - block tags for all world-gen blocks with fallbacks for mods that haven't proided the tags - started on biome tags --- .../com/terraforged/core/filter/Erosion.java | 45 ++++++++++--------- .../com/terraforged/core/filter/Filter.java | 4 +- .../terraforged/core/filter/Filterable.java | 3 +- .../terraforged/core/filter/Smoothing.java | 4 +- .../com/terraforged/core/region/Region.java | 4 +- TerraForgedCore/src/main/resources/biomes.txt | 24 +++++----- TerraForgedMod | 2 +- 7 files changed, 45 insertions(+), 41 deletions(-) diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/filter/Erosion.java b/TerraForgedCore/src/main/java/com/terraforged/core/filter/Erosion.java index eff5566..0f2f181 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/filter/Erosion.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/filter/Erosion.java @@ -1,6 +1,7 @@ package com.terraforged.core.filter; import com.terraforged.core.cell.Cell; +import com.terraforged.core.region.Size; import com.terraforged.core.settings.Settings; import com.terraforged.core.util.PosIterator; import com.terraforged.core.world.heightmap.Levels; @@ -36,8 +37,8 @@ public class Erosion implements Filter { @Override public void apply(Filterable map, int seedX, int seedZ, int iterations) { - if (erosionBrushIndices.length != map.getRawSize()) { - init(map.getRawSize(), erosionRadius); + if (erosionBrushIndices.length != map.getSize().total) { + init(map.getSize().total, erosionRadius); } applyMain(map, seedX, seedZ, iterations, random); @@ -45,21 +46,16 @@ public class Erosion implements Filter { applyNeighbours(map, seedX, seedZ, iterations, random); } - private int nextCoord(Filterable map, Random random) { - return random.nextInt(map.getRawSize() - 1); + private int nextCoord(Size size, Random random) { + return size.border + random.nextInt(size.size - 1); } private void applyMain(Filterable map, int seedX, int seedZ, int iterations, Random random) { random.setSeed(NoiseUtil.seed(seedX, seedZ)); while (iterations-- > 0) { - int posX = nextCoord(map, random); - int posZ = nextCoord(map, random); - try { - apply(map.getBacking(), posX, posZ, map.getRawSize()); - } catch (Throwable t) { - System.out.println(posX + ":" + posZ + "(" + map.getRawSize() + ")"); - throw t; - } + int posX = nextCoord(map.getSize(), random); + int posZ = nextCoord(map.getSize(), random); + apply(map.getBacking(), posX, posZ, map.getSize().total); } } @@ -79,17 +75,24 @@ public class Erosion implements Filter { } private void applyNeighbour(Filterable map, int deltaX, int deltaZ, int iterations, Random random) { - int max = map.getRawSize() - 1; - int offsetX = deltaX * map.getRawSize(); - int offsetZ = deltaZ * map.getRawSize(); + int min = -map.getSize().border; + int max = map.getSize().size + map.getSize().border - 1; + int neighbourOffsetX = deltaX * map.getSize().size; + int neighbourOffsetZ = deltaZ * map.getSize().size; while (iterations-- > 0) { - int posX = nextCoord(map, random); - int posZ = nextCoord(map, random); + int posX = nextCoord(map.getSize(), random); + int posZ = nextCoord(map.getSize(), random); + int relX = posX + neighbourOffsetX; + int relZ = posZ + neighbourOffsetZ; - int relX = posX + offsetX; - int relZ = posZ + offsetZ; - if (relX >= 0 && relX < max && relZ >= 0 && relZ < max) { - apply(map.getBacking(), relX, relZ, map.getRawSize()); + // is inside the border box + if (relX > min && relZ > min && relX < max && relZ < max) { + // shouldn't happen + if (relX > 0 && relZ > 0 && relX < map.getSize().size && relZ < map.getSize().size) { + System.out.println("err?"); + continue; + } + apply(map.getBacking(), relX, relZ, map.getSize().total); } } } diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/filter/Filter.java b/TerraForgedCore/src/main/java/com/terraforged/core/filter/Filter.java index 4b69299..893d1ef 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/filter/Filter.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/filter/Filter.java @@ -7,8 +7,8 @@ public interface Filter { void apply(Filterable map, int seedX, int seedZ, int iterations); default void iterate(Filterable map, Visitor visitor) { - for (int dz = 0; dz < map.getRawSize(); dz++) { - for (int dx = 0; dx < map.getRawSize(); dx++) { + for (int dz = 0; dz < map.getSize().total; dz++) { + for (int dx = 0; dx < map.getSize().total; dx++) { Cell cell = map.getCellRaw(dx, dz); visitor.visit(map, cell, dx, dz); } diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/filter/Filterable.java b/TerraForgedCore/src/main/java/com/terraforged/core/filter/Filterable.java index 153f7e1..0c9a964 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/filter/Filterable.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/filter/Filterable.java @@ -2,10 +2,11 @@ package com.terraforged.core.filter; import com.terraforged.core.cell.Cell; import com.terraforged.core.cell.Tag; +import com.terraforged.core.region.Size; public interface Filterable { - int getRawSize(); + Size getSize(); Cell[] getBacking(); diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/filter/Smoothing.java b/TerraForgedCore/src/main/java/com/terraforged/core/filter/Smoothing.java index be8500b..fc88f88 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/filter/Smoothing.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/filter/Smoothing.java @@ -27,8 +27,8 @@ public class Smoothing implements Filter { } private void apply(Filterable cellMap) { - int maxZ = cellMap.getRawSize() - radius; - int maxX = cellMap.getRawSize() - radius; + int maxZ = cellMap.getSize().total - radius; + int maxX = cellMap.getSize().total - radius; for (int z = radius; z < maxZ; z++) { for (int x = radius; x < maxX; x++) { Cell cell = cellMap.getCellRaw(x, z); 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 f489be7..6446780 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/region/Region.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/region/Region.java @@ -308,8 +308,8 @@ public class Region implements Extent { private class FilterRegion implements Filterable { @Override - public int getRawSize() { - return blockSize.total; + public Size getSize() { + return blockSize; } @Override diff --git a/TerraForgedCore/src/main/resources/biomes.txt b/TerraForgedCore/src/main/resources/biomes.txt index 8abd632..9622c92 100644 --- a/TerraForgedCore/src/main/resources/biomes.txt +++ b/TerraForgedCore/src/main/resources/biomes.txt @@ -1,13 +1,13 @@ -#TerraForged BiomeType Hex Colors (do not include hash/pound character) +#TerraForgedCore BiomeType Hex Colors (do not include hash/pound character) #Fri Jan 10 23:15:10 GMT 2020 -ALPINE=4b7835 -TAIGA=4b7835 -TEMPERATE_RAINFOREST=3c602b -TUNDRA=ba9d47 -TROPICAL_RAINFOREST=4aa73a -SAVANNA=389a38 -GRASSLAND=429545 -TEMPERATE_FOREST=456938 -STEPPE=c3aa61 -DESERT=e5d98f -COLD_STEPPE=a7a374 \ No newline at end of file +ALPINE=a078aa +TAIGA=5b8f52 +TEMPERATE_RAINFOREST=0aa041 +TUNDRA=93a7ac +TROPICAL_RAINFOREST=075330 +SAVANNA=97a527 +GRASSLAND=64dc3c +TEMPERATE_FOREST=32c850 +STEPPE=c8c878 +DESERT=c87137 +COLD_STEPPE=afb496 \ No newline at end of file diff --git a/TerraForgedMod b/TerraForgedMod index 2d7fb9c..9701bdc 160000 --- a/TerraForgedMod +++ b/TerraForgedMod @@ -1 +1 @@ -Subproject commit 2d7fb9c4970463935a4b5e882e5b597af633c30a +Subproject commit 9701bdce1076334c9c4fb23688ef192f8638435a