diff --git a/assets/Data/game/voxelTypes.json b/assets/Data/game/voxelTypes.json index 5fbd37a6..f286abd9 100644 --- a/assets/Data/game/voxelTypes.json +++ b/assets/Data/game/voxelTypes.json @@ -46,6 +46,11 @@ "id" : 8, "name" : "Rock (Slate)", "texture" : "/Textures/Ground/rock3_256.png" + }, + { + "id" : 9, + "name" : "Farmland", + "texture" : "/Textures/Ground/farmland_1.png" } ] } \ No newline at end of file diff --git a/assets/Textures/Ground/farmland_1.png b/assets/Textures/Ground/farmland_1.png new file mode 100644 index 00000000..351637a2 Binary files /dev/null and b/assets/Textures/Ground/farmland_1.png differ diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index 0f112d3f..e84a4090 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -2044,6 +2044,8 @@ Utilities for turning mesh gen algos into renderable entities Back off farm plots from roads by road radius Farm plots properly save/load to/from disk Farm plots place dirt +Farmland voxel type +Farm plots place farmland diff --git a/src/main/java/electrosphere/server/physics/terrain/generation/ProceduralChunkGenerator.java b/src/main/java/electrosphere/server/physics/terrain/generation/ProceduralChunkGenerator.java index 01437087..daccad40 100644 --- a/src/main/java/electrosphere/server/physics/terrain/generation/ProceduralChunkGenerator.java +++ b/src/main/java/electrosphere/server/physics/terrain/generation/ProceduralChunkGenerator.java @@ -226,7 +226,7 @@ public class ProceduralChunkGenerator implements ChunkGenerator { values[x][y][z] = voxel.type; } //apply macro data - if(macroData != null && this.applyMacroData(macroData, realX, realY, realZ, voxel)){ + if(macroData != null && this.applyMacroData(macroData, realX, realY, realZ, surfaceHeight, voxel)){ weights[x][y][z] = voxel.weight; values[x][y][z] = voxel.type; } @@ -274,6 +274,7 @@ public class ProceduralChunkGenerator implements ChunkGenerator { private boolean applyMacroData( List objects, double realX, double realY, double realZ, + double surfaceHeight, GeneratedVoxel voxel ){ boolean rVal = false; @@ -282,11 +283,13 @@ public class ProceduralChunkGenerator implements ChunkGenerator { if(object instanceof Road){ Road road = (Road)object; //broad phase intersection - if(road.getAABB().testPoint(realX, realY, realZ)){ - if(GeomUtils.pointIntersectsLineSegment(realPt, road.getPoint1(), road.getPoint2(), road.getRadius())){ - if(voxel.type != ServerTerrainChunk.VOXEL_TYPE_AIR){ - voxel.type = 1; - rVal = true; + if(Math.abs(realY - surfaceHeight) < 3){ + if(road.getAABB().testPoint(realX, realY, realZ)){ + if(GeomUtils.pointIntersectsLineSegment(realPt, road.getPoint1(), road.getPoint2(), road.getRadius())){ + if(voxel.type != ServerTerrainChunk.VOXEL_TYPE_AIR){ + voxel.type = 1; + rVal = true; + } } } } @@ -309,11 +312,13 @@ public class ProceduralChunkGenerator implements ChunkGenerator { } } else if(object instanceof Town){ } else if(object instanceof MacroRegion region){ - if(region.getRegion().getAABB().testPoint(realPt)){ - if(region.getRegion().intersects(realPt)){ - if(voxel.type != ServerTerrainChunk.VOXEL_TYPE_AIR){ - voxel.type = 1; - rVal = true; + if(Math.abs(realY - surfaceHeight) < 3){ + if(region.getRegion().getAABB().testPoint(realPt)){ + if(region.getRegion().intersects(realPt)){ + if(voxel.type != ServerTerrainChunk.VOXEL_TYPE_AIR){ + voxel.type = 9; + rVal = true; + } } } }