Skip to content

Commit

Permalink
Make world generate in layers again
Browse files Browse the repository at this point in the history
  - Top layer is now randomly offset by 1 or 2 blocks
  - Top layer of world is always grass
  - The three layers below the top layer are dirt
  - The rest of the layers down to Y=1 are stone
  - The bottom layer remains bedrock
  • Loading branch information
Nixinova committed Jul 24, 2024
1 parent d70b07d commit 8b7211b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 25 deletions.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
- Added block face culling
- World now only generates along the positive axes
- World now abides by worldSize option again
- World now generates in layers again
- Top layer is now randomly offset by 1 or 2 blocks
- Top layer of world is always grass
- The three layers below the top layer are dirt
- The rest of the layers down to Y=1 are stone
- The bottom layer remains bedrock

## 0.0.17_3
*2024-07-24 23:03*
Expand Down
37 changes: 12 additions & 25 deletions src/com/nixinova/world/World.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,41 +99,28 @@ public void setTextureAt(int blockX, int blockY, int blockZ, Render texture) {

// NOTE: does not abide by this.minCorner
private void mapBlockTextures() {
int arrSize[] = new int[] { this.maxCorner.x+1, this.maxCorner.y+1, this.maxCorner.z+1 };
this.blockTextures = new Render[arrSize[0]][arrSize[1]][arrSize[2]];
int maxX = this.maxCorner.x + 1;
int maxY = this.maxCorner.y + 1;
int maxZ = this.maxCorner.z + 1;
this.blockTextures = new Render[maxX][maxY][maxZ];

Random random = new Random(Options.seed);

for (int x = 0; x < arrSize[0]; x++) {
for (int y = 0; y < arrSize[1]; y++) {
for (int z = 0; z < arrSize[2]; z++) {

if (y < 0)
continue;
for (int x = 0; x < this.maxCorner.x; x++) {
for (int z = 0; z < this.maxCorner.z; z++) {
int localGroundY = GROUND_Y + random.nextInt(2);

for (int y = 0; y < this.maxCorner.y; y++) {
Block block;

if (y == 0)
block = Block.BEDROCK;
else if ((y * 2.5 < x + z) && y <= GROUND_Y - 4)
else if (y <= localGroundY - 4)
block = Block.STONE;
else if ((y * 2.5 < x + z) && y <= GROUND_Y - 1)
block = Block.DIRT;
else if ((y * 2.5 < x + z) && y <= GROUND_Y)
block = Block.GRASS;
else if ((y * 1.5 > x + z) && y <= GROUND_Y - 1)
else if (y <= localGroundY - 1)
block = Block.DIRT;
else if ((y * 1.5 > x + z) && y <= GROUND_Y)
block = Block.GRASS;
/*
else if (y <= GROUND_Y - 4)
block = random.nextInt(y) > 1 ? Block.DIRT : Block.STONE;
else if (y <= GROUND_Y - 2)
block = Block.DIRT;
else if (y <= GROUND_Y)
block = Block.GRASS;
else if (y <= GROUND_Y + 1 && random.nextBoolean())
else if (y <= localGroundY)
block = Block.GRASS;
//*/
else
block = Block.AIR;

Expand Down

0 comments on commit 8b7211b

Please sign in to comment.