Added more grass variants
- Added flat grass tiles with varying opaqueness - Renamed Test:Grass to Test:GrassOpaque - Added Chernozem
@ -48,12 +48,11 @@ class PlanetTerrainGenerator {
|
|||||||
this.parent = generator;
|
this.parent = generator;
|
||||||
|
|
||||||
int seaLevel = (int) parent.getPlanet().getRadius();
|
int seaLevel = (int) parent.getPlanet().getRadius();
|
||||||
SurfaceFloatField adjustedHeightMap = (f, n, w) -> heightMap.get(f, n, w) + generator.getPlanet().getRadius();
|
|
||||||
|
|
||||||
this.surfaceGenerators = AbsFace.mapToFaces(
|
this.surfaceGenerators = AbsFace.mapToFaces(
|
||||||
face -> new SurfaceTerrainGenerator(
|
face -> new SurfaceTerrainGenerator(
|
||||||
new Surface(face, seaLevel),
|
new Surface(face, seaLevel),
|
||||||
adjustedHeightMap,
|
heightMap,
|
||||||
layers
|
layers
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -47,6 +47,7 @@ public class SurfaceTerrainGenerator {
|
|||||||
|
|
||||||
Vec3 offset = new Vec3(chunk.getMinX(), chunk.getMinY(), chunk.getMinZ());
|
Vec3 offset = new Vec3(chunk.getMinX(), chunk.getMinY(), chunk.getMinZ());
|
||||||
AxisRotations.relativize(offset, chunk.getUp(), offset);
|
AxisRotations.relativize(offset, chunk.getUp(), offset);
|
||||||
|
offset.z -= surface.getSeaLevel();
|
||||||
|
|
||||||
SurfaceWorldContext context = surface.createContext(server, chunk, 0);
|
SurfaceWorldContext context = surface.createContext(server, chunk, 0);
|
||||||
|
|
||||||
|
@ -101,6 +101,10 @@ public class TestContent {
|
|||||||
register(new BlockRenderOpaqueCube("Test:Dirt", getBlockTexture("Dirt")));
|
register(new BlockRenderOpaqueCube("Test:Dirt", getBlockTexture("Dirt")));
|
||||||
register(new BlockLogic("Test:Dirt"));
|
register(new BlockLogic("Test:Dirt"));
|
||||||
|
|
||||||
|
register(new BlockData("Test:Chernozem"));
|
||||||
|
register(new BlockRenderOpaqueCube("Test:Chernozem", getBlockTexture("Chernozem")));
|
||||||
|
register(new BlockLogic("Test:Chernozem"));
|
||||||
|
|
||||||
register(new BlockData("Test:Stone"));
|
register(new BlockData("Test:Stone"));
|
||||||
register(new BlockRenderOpaqueCube("Test:Stone", getBlockTexture("Stone")));
|
register(new BlockRenderOpaqueCube("Test:Stone", getBlockTexture("Stone")));
|
||||||
register(new BlockLogic("Test:Stone"));
|
register(new BlockLogic("Test:Stone"));
|
||||||
@ -167,9 +171,19 @@ public class TestContent {
|
|||||||
private static void registerTiles() {
|
private static void registerTiles() {
|
||||||
Set<String> placeableBlacklist = new HashSet<>();
|
Set<String> placeableBlacklist = new HashSet<>();
|
||||||
|
|
||||||
register(new TileData("Test:Grass"));
|
for (String variant : new String[] {
|
||||||
register(new TestTileRenderGrass("Test:Grass", getTileTexture("GrassTop"), getTileTexture("GrassSide")));
|
"Opaque",
|
||||||
register(new TestTileLogicGrass("Test:Grass"));
|
"Patches",
|
||||||
|
"Web",
|
||||||
|
"Threads"
|
||||||
|
}) {
|
||||||
|
String fullName = "Grass" + variant;
|
||||||
|
String id = "Test:" + fullName;
|
||||||
|
|
||||||
|
register(new TileData(id));
|
||||||
|
register(new TestTileRenderGrass(id, getTileTexture(fullName + "Top"), getTileTexture(fullName + "Side"), variant.equals("Opaque")));
|
||||||
|
register(new TestTileLogicGrass(id));
|
||||||
|
}
|
||||||
|
|
||||||
register(new TileData("Test:Stones"));
|
register(new TileData("Test:Stones"));
|
||||||
register(new TileRenderTransparentSurface("Test:Stones", getTileTexture("Stones")));
|
register(new TileRenderTransparentSurface("Test:Stones", getTileTexture("Stones")));
|
||||||
|
@ -26,15 +26,18 @@ public class TestTileRenderGrass extends TileRenderSurface {
|
|||||||
|
|
||||||
private final Texture topTexture;
|
private final Texture topTexture;
|
||||||
private final Texture sideTexture;
|
private final Texture sideTexture;
|
||||||
|
private final boolean isOpaque;
|
||||||
|
|
||||||
public TestTileRenderGrass(
|
public TestTileRenderGrass(
|
||||||
String id,
|
String id,
|
||||||
Texture top,
|
Texture top,
|
||||||
Texture side
|
Texture side,
|
||||||
|
boolean isOpaque
|
||||||
) {
|
) {
|
||||||
super(id);
|
super(id);
|
||||||
this.topTexture = top;
|
this.topTexture = top;
|
||||||
this.sideTexture = side;
|
this.sideTexture = side;
|
||||||
|
this.isOpaque = isOpaque;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -44,7 +47,7 @@ public class TestTileRenderGrass extends TileRenderSurface {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isOpaque(RelFace face) {
|
public boolean isOpaque(RelFace face) {
|
||||||
return face == RelFace.UP;
|
return isOpaque && face == RelFace.UP;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ public class TestGenerationConfig {
|
|||||||
"Test:Grass",
|
"Test:Grass",
|
||||||
f -> multiply(
|
f -> multiply(
|
||||||
tweak(octaves(FIELDS.primitive(), 2, 2), 40, 0.5, 1.2),
|
tweak(octaves(FIELDS.primitive(), 2, 2), 40, 0.5, 1.2),
|
||||||
squash(tweak(FIELDS.get("Test:Forest", f), 1, -0.7, 1), 10),
|
squash(tweak(FIELDS.get("Test:Forest", f), 1, -1, 1), 10),
|
||||||
anti(squash(FIELDS.get("Test:Cliff", f), 10))
|
anti(squash(FIELDS.get("Test:Cliff", f), 10))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -25,6 +25,8 @@ import com.google.common.collect.ImmutableSet;
|
|||||||
|
|
||||||
import ru.windcorp.progressia.common.util.ArrayFloatRangeMap;
|
import ru.windcorp.progressia.common.util.ArrayFloatRangeMap;
|
||||||
import ru.windcorp.progressia.common.util.FloatRangeMap;
|
import ru.windcorp.progressia.common.util.FloatRangeMap;
|
||||||
|
import ru.windcorp.progressia.common.world.block.BlockData;
|
||||||
|
import ru.windcorp.progressia.common.world.block.BlockDataRegistry;
|
||||||
import ru.windcorp.progressia.common.world.rels.RelFace;
|
import ru.windcorp.progressia.common.world.rels.RelFace;
|
||||||
import ru.windcorp.progressia.common.world.tile.TileData;
|
import ru.windcorp.progressia.common.world.tile.TileData;
|
||||||
import ru.windcorp.progressia.common.world.tile.TileDataRegistry;
|
import ru.windcorp.progressia.common.world.tile.TileDataRegistry;
|
||||||
@ -46,13 +48,21 @@ public class TestGrassFeature extends SurfaceTopLayerFeature {
|
|||||||
private final SurfaceFloatField grassiness;
|
private final SurfaceFloatField grassiness;
|
||||||
private final double scatterDensity = 1.0 / (3 * 3);
|
private final double scatterDensity = 1.0 / (3 * 3);
|
||||||
|
|
||||||
private final TileData grass = TileDataRegistry.getInstance().get("Test:Grass");
|
private final BlockData chernozem = BlockDataRegistry.getInstance().get("Test:Chernozem");
|
||||||
|
|
||||||
private final FloatRangeMap<TileData> grasses = new ArrayFloatRangeMap<>();
|
private final FloatRangeMap<TileData> flatGrasses = new ArrayFloatRangeMap<>();
|
||||||
{
|
{
|
||||||
grasses.put(0.6f, 1, TileDataRegistry.getInstance().get("Test:TallGrass"));
|
flatGrasses.put(0.4f, Float.POSITIVE_INFINITY, TileDataRegistry.getInstance().get("Test:GrassOpaque"));
|
||||||
grasses.put(0.4f, 0.6f, TileDataRegistry.getInstance().get("Test:MediumGrass"));
|
flatGrasses.put(0.2f, 0.4f, TileDataRegistry.getInstance().get("Test:GrassPatches"));
|
||||||
grasses.put(0.1f, 0.4f, TileDataRegistry.getInstance().get("Test:LowGrass"));
|
flatGrasses.put(0.1f, 0.2f, TileDataRegistry.getInstance().get("Test:GrassWeb"));
|
||||||
|
flatGrasses.put(0.05f, 0.1f, TileDataRegistry.getInstance().get("Test:GrassThreads"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private final FloatRangeMap<TileData> herbGrasses = new ArrayFloatRangeMap<>();
|
||||||
|
{
|
||||||
|
herbGrasses.put(0.6f, 1, TileDataRegistry.getInstance().get("Test:TallGrass"));
|
||||||
|
herbGrasses.put(0.4f, 0.6f, TileDataRegistry.getInstance().get("Test:MediumGrass"));
|
||||||
|
herbGrasses.put(0.1f, 0.4f, TileDataRegistry.getInstance().get("Test:LowGrass"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private final List<TileData> scatter = ImmutableList.of(
|
private final List<TileData> scatter = ImmutableList.of(
|
||||||
@ -81,11 +91,7 @@ public class TestGrassFeature extends SurfaceTopLayerFeature {
|
|||||||
}
|
}
|
||||||
context.pop();
|
context.pop();
|
||||||
|
|
||||||
double grassiness = this.grassiness.get(context);
|
growGrass(context, this.grassiness.get(context));
|
||||||
if (grassiness > 0.1) {
|
|
||||||
growGrass(context, grassiness);
|
|
||||||
}
|
|
||||||
|
|
||||||
placeScatter(context);
|
placeScatter(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,21 +103,28 @@ public class TestGrassFeature extends SurfaceTopLayerFeature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void growGrass(SurfaceBlockContext context, double grassiness) {
|
private void growGrass(SurfaceBlockContext context, double grassiness) {
|
||||||
for (RelFace face : RelFace.getFaces()) {
|
TileData flatGrass = flatGrasses.get((float) grassiness);
|
||||||
if (face == RelFace.DOWN)
|
if (flatGrass != null) {
|
||||||
continue;
|
for (RelFace face : RelFace.getFaces()) {
|
||||||
|
if (face == RelFace.DOWN)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (context.pushRelative(face).logic().getBlock().isTransparent()) {
|
||||||
|
context.pop();
|
||||||
|
context.addTile(face, flatGrass);
|
||||||
|
} else {
|
||||||
|
context.pop();
|
||||||
|
}
|
||||||
|
|
||||||
if (context.pushRelative(face).logic().getBlock().isTransparent()) {
|
|
||||||
context.pop();
|
|
||||||
context.addTile(face, grass);
|
|
||||||
} else {
|
|
||||||
context.pop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (grassiness > 0.8 && context.getBlock().getId().equals("Test:Dirt")) {
|
||||||
|
context.setBlock(chernozem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context.getRandom().nextDouble() < grassiness) {
|
if (context.getRandom().nextDouble() < grassiness) {
|
||||||
TileData herbGrass = grasses.get((float) grassiness);
|
TileData herbGrass = herbGrasses.get((float) grassiness);
|
||||||
if (herbGrass != null) {
|
if (herbGrass != null) {
|
||||||
context.addTile(RelFace.UP, herbGrass);
|
context.addTile(RelFace.UP, herbGrass);
|
||||||
}
|
}
|
||||||
|
BIN
src/main/resources/assets/textures/blocks/Chernozem.png
Normal file
After Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.9 KiB |
BIN
src/main/resources/assets/textures/tiles/GrassPatchesSide.png
Normal file
After Width: | Height: | Size: 5.5 KiB |
BIN
src/main/resources/assets/textures/tiles/GrassPatchesTop.png
Normal file
After Width: | Height: | Size: 9.7 KiB |
BIN
src/main/resources/assets/textures/tiles/GrassThreadsSide.png
Normal file
After Width: | Height: | Size: 5.1 KiB |
BIN
src/main/resources/assets/textures/tiles/GrassThreadsTop.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
src/main/resources/assets/textures/tiles/GrassWebSide.png
Normal file
After Width: | Height: | Size: 5.1 KiB |
BIN
src/main/resources/assets/textures/tiles/GrassWebTop.png
Normal file
After Width: | Height: | Size: 9.8 KiB |