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:
parent
c9bd456493
commit
4c4165400d
@ -1,6 +1,7 @@
|
|||||||
package com.terraforged.core.filter;
|
package com.terraforged.core.filter;
|
||||||
|
|
||||||
import com.terraforged.core.cell.Cell;
|
import com.terraforged.core.cell.Cell;
|
||||||
|
import com.terraforged.core.region.Size;
|
||||||
import com.terraforged.core.settings.Settings;
|
import com.terraforged.core.settings.Settings;
|
||||||
import com.terraforged.core.util.PosIterator;
|
import com.terraforged.core.util.PosIterator;
|
||||||
import com.terraforged.core.world.heightmap.Levels;
|
import com.terraforged.core.world.heightmap.Levels;
|
||||||
@ -36,8 +37,8 @@ public class Erosion implements Filter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(Filterable<?> map, int seedX, int seedZ, int iterations) {
|
public void apply(Filterable<?> map, int seedX, int seedZ, int iterations) {
|
||||||
if (erosionBrushIndices.length != map.getRawSize()) {
|
if (erosionBrushIndices.length != map.getSize().total) {
|
||||||
init(map.getRawSize(), erosionRadius);
|
init(map.getSize().total, erosionRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
applyMain(map, seedX, seedZ, iterations, random);
|
applyMain(map, seedX, seedZ, iterations, random);
|
||||||
@ -45,21 +46,16 @@ public class Erosion implements Filter {
|
|||||||
applyNeighbours(map, seedX, seedZ, iterations, random);
|
applyNeighbours(map, seedX, seedZ, iterations, random);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int nextCoord(Filterable<?> map, Random random) {
|
private int nextCoord(Size size, Random random) {
|
||||||
return random.nextInt(map.getRawSize() - 1);
|
return size.border + random.nextInt(size.size - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyMain(Filterable<?> map, int seedX, int seedZ, int iterations, Random random) {
|
private void applyMain(Filterable<?> map, int seedX, int seedZ, int iterations, Random random) {
|
||||||
random.setSeed(NoiseUtil.seed(seedX, seedZ));
|
random.setSeed(NoiseUtil.seed(seedX, seedZ));
|
||||||
while (iterations-- > 0) {
|
while (iterations-- > 0) {
|
||||||
int posX = nextCoord(map, random);
|
int posX = nextCoord(map.getSize(), random);
|
||||||
int posZ = nextCoord(map, random);
|
int posZ = nextCoord(map.getSize(), random);
|
||||||
try {
|
apply(map.getBacking(), posX, posZ, map.getSize().total);
|
||||||
apply(map.getBacking(), posX, posZ, map.getRawSize());
|
|
||||||
} catch (Throwable t) {
|
|
||||||
System.out.println(posX + ":" + posZ + "(" + map.getRawSize() + ")");
|
|
||||||
throw t;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,17 +75,24 @@ public class Erosion implements Filter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void applyNeighbour(Filterable<?> map, int deltaX, int deltaZ, int iterations, Random random) {
|
private void applyNeighbour(Filterable<?> map, int deltaX, int deltaZ, int iterations, Random random) {
|
||||||
int max = map.getRawSize() - 1;
|
int min = -map.getSize().border;
|
||||||
int offsetX = deltaX * map.getRawSize();
|
int max = map.getSize().size + map.getSize().border - 1;
|
||||||
int offsetZ = deltaZ * map.getRawSize();
|
int neighbourOffsetX = deltaX * map.getSize().size;
|
||||||
|
int neighbourOffsetZ = deltaZ * map.getSize().size;
|
||||||
while (iterations-- > 0) {
|
while (iterations-- > 0) {
|
||||||
int posX = nextCoord(map, random);
|
int posX = nextCoord(map.getSize(), random);
|
||||||
int posZ = nextCoord(map, random);
|
int posZ = nextCoord(map.getSize(), random);
|
||||||
|
int relX = posX + neighbourOffsetX;
|
||||||
|
int relZ = posZ + neighbourOffsetZ;
|
||||||
|
|
||||||
int relX = posX + offsetX;
|
// is inside the border box
|
||||||
int relZ = posZ + offsetZ;
|
if (relX > min && relZ > min && relX < max && relZ < max) {
|
||||||
if (relX >= 0 && relX < max && relZ >= 0 && relZ < max) {
|
// shouldn't happen
|
||||||
apply(map.getBacking(), relX, relZ, map.getRawSize());
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,8 @@ public interface Filter {
|
|||||||
void apply(Filterable<?> map, int seedX, int seedZ, int iterations);
|
void apply(Filterable<?> map, int seedX, int seedZ, int iterations);
|
||||||
|
|
||||||
default void iterate(Filterable<?> map, Visitor visitor) {
|
default void iterate(Filterable<?> map, Visitor visitor) {
|
||||||
for (int dz = 0; dz < map.getRawSize(); dz++) {
|
for (int dz = 0; dz < map.getSize().total; dz++) {
|
||||||
for (int dx = 0; dx < map.getRawSize(); dx++) {
|
for (int dx = 0; dx < map.getSize().total; dx++) {
|
||||||
Cell<?> cell = map.getCellRaw(dx, dz);
|
Cell<?> cell = map.getCellRaw(dx, dz);
|
||||||
visitor.visit(map, cell, dx, dz);
|
visitor.visit(map, cell, dx, dz);
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,11 @@ package com.terraforged.core.filter;
|
|||||||
|
|
||||||
import com.terraforged.core.cell.Cell;
|
import com.terraforged.core.cell.Cell;
|
||||||
import com.terraforged.core.cell.Tag;
|
import com.terraforged.core.cell.Tag;
|
||||||
|
import com.terraforged.core.region.Size;
|
||||||
|
|
||||||
public interface Filterable<T extends Tag> {
|
public interface Filterable<T extends Tag> {
|
||||||
|
|
||||||
int getRawSize();
|
Size getSize();
|
||||||
|
|
||||||
Cell<T>[] getBacking();
|
Cell<T>[] getBacking();
|
||||||
|
|
||||||
|
@ -27,8 +27,8 @@ public class Smoothing implements Filter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void apply(Filterable<?> cellMap) {
|
private void apply(Filterable<?> cellMap) {
|
||||||
int maxZ = cellMap.getRawSize() - radius;
|
int maxZ = cellMap.getSize().total - radius;
|
||||||
int maxX = cellMap.getRawSize() - radius;
|
int maxX = cellMap.getSize().total - radius;
|
||||||
for (int z = radius; z < maxZ; z++) {
|
for (int z = radius; z < maxZ; z++) {
|
||||||
for (int x = radius; x < maxX; x++) {
|
for (int x = radius; x < maxX; x++) {
|
||||||
Cell<?> cell = cellMap.getCellRaw(x, z);
|
Cell<?> cell = cellMap.getCellRaw(x, z);
|
||||||
|
@ -308,8 +308,8 @@ public class Region implements Extent {
|
|||||||
private class FilterRegion implements Filterable<Terrain> {
|
private class FilterRegion implements Filterable<Terrain> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRawSize() {
|
public Size getSize() {
|
||||||
return blockSize.total;
|
return blockSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -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
|
#Fri Jan 10 23:15:10 GMT 2020
|
||||||
ALPINE=4b7835
|
ALPINE=a078aa
|
||||||
TAIGA=4b7835
|
TAIGA=5b8f52
|
||||||
TEMPERATE_RAINFOREST=3c602b
|
TEMPERATE_RAINFOREST=0aa041
|
||||||
TUNDRA=ba9d47
|
TUNDRA=93a7ac
|
||||||
TROPICAL_RAINFOREST=4aa73a
|
TROPICAL_RAINFOREST=075330
|
||||||
SAVANNA=389a38
|
SAVANNA=97a527
|
||||||
GRASSLAND=429545
|
GRASSLAND=64dc3c
|
||||||
TEMPERATE_FOREST=456938
|
TEMPERATE_FOREST=32c850
|
||||||
STEPPE=c3aa61
|
STEPPE=c8c878
|
||||||
DESERT=e5d98f
|
DESERT=c87137
|
||||||
COLD_STEPPE=a7a374
|
COLD_STEPPE=afb496
|
@ -1 +1 @@
|
|||||||
Subproject commit 2d7fb9c4970463935a4b5e882e5b597af633c30a
|
Subproject commit 9701bdce1076334c9c4fb23688ef192f8638435a
|
Loading…
Reference in New Issue
Block a user