Skip to content

Commit

Permalink
Add Random parameter to Structure#draw
Browse files Browse the repository at this point in the history
  • Loading branch information
BenCheung0422 committed Jul 22, 2023
1 parent bc6c095 commit 64a8de6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/client/java/minicraft/level/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -918,19 +918,19 @@ private void generateSpawnerStructures() {
setTile(sp.x / 16, sp.y / 16, Tiles.get("dirt"));
}

Structure.mobDungeonCenter.draw(this, sp.x / 16, sp.y / 16, random.nextInt(3) * 5 + 90);
Structure.mobDungeonCenter.draw(this, sp.x / 16, sp.y / 16, random.nextInt(3) * 5 + 90, random);

if (getTile(sp.x / 16, sp.y / 16 - 4) == Tiles.get("dirt")) {
Structure.mobDungeonNorth.draw(this, sp.x / 16, sp.y / 16 - 5, random.nextInt(3) * 5 + 90);
Structure.mobDungeonNorth.draw(this, sp.x / 16, sp.y / 16 - 5, random.nextInt(3) * 5 + 90, random);
}
if (getTile(sp.x / 16, sp.y / 16 + 4) == Tiles.get("dirt")) {
Structure.mobDungeonSouth.draw(this, sp.x / 16, sp.y / 16 + 5, random.nextInt(3) * 5 + 90);
Structure.mobDungeonSouth.draw(this, sp.x / 16, sp.y / 16 + 5, random.nextInt(3) * 5 + 90, random);
}
if (getTile(sp.x / 16 + 4, sp.y / 16) == Tiles.get("dirt")) {
Structure.mobDungeonEast.draw(this, sp.x / 16 + 5, sp.y / 16, random.nextInt(3) * 5 + 90);
Structure.mobDungeonEast.draw(this, sp.x / 16 + 5, sp.y / 16, random.nextInt(3) * 5 + 90, random);
}
if (getTile(sp.x / 16 - 4, sp.y / 16) == Tiles.get("dirt")) {
Structure.mobDungeonWest.draw(this, sp.x / 16 - 5, sp.y / 16, random.nextInt(3) * 5 + 90);
Structure.mobDungeonWest.draw(this, sp.x / 16 - 5, sp.y / 16, random.nextInt(3) * 5 + 90, random);
}

add(sp);
Expand Down Expand Up @@ -1037,9 +1037,9 @@ private void generateVillages() {
yo += random.nextInt(5) - 2;

if (twoDoors) {
Structure.villageHouseTwoDoor.draw(this, x + xo, y + yo, random.nextInt(7) * 5 + 60);
Structure.villageHouseTwoDoor.draw(this, x + xo, y + yo, random.nextInt(7) * 5 + 60, random);
} else {
Structure.villageHouseNormal.draw(this, x + xo, y + yo, random.nextInt(7) * 5 + 60);
Structure.villageHouseNormal.draw(this, x + xo, y + yo, random.nextInt(7) * 5 + 60, random);
}

// Make the village look ruined
Expand Down
3 changes: 1 addition & 2 deletions src/client/java/minicraft/level/Structure.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public void draw(Level level, int xt, int yt) {
level.add(furniture.get(p).copy(), xt+p.x, yt+p.y, true);
}

public void draw(Level level, int xt, int yt, float integrity) {
Random random = new Random();
public void draw(Level level, int xt, int yt, float integrity, Random random) {
for (TilePoint p: tiles)
if (random.nextInt(100) < integrity) level.setTile(xt+p.x, yt+p.y, p.t);

Expand Down

0 comments on commit 64a8de6

Please sign in to comment.