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
This commit is contained in:
dags- 2020-01-21 16:53:58 +00:00
parent c9bd456493
commit 4c4165400d
7 changed files with 45 additions and 41 deletions

View File

@ -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);
}
}
}

View File

@ -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);
}

View File

@ -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<T extends Tag> {
int getRawSize();
Size getSize();
Cell<T>[] getBacking();

View File

@ -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);

View File

@ -308,8 +308,8 @@ public class Region implements Extent {
private class FilterRegion implements Filterable<Terrain> {
@Override
public int getRawSize() {
return blockSize.total;
public Size getSize() {
return blockSize;
}
@Override

View File

@ -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
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

@ -1 +1 @@
Subproject commit 2d7fb9c4970463935a4b5e882e5b597af633c30a
Subproject commit 9701bdce1076334c9c4fb23688ef192f8638435a