Skip to content

Commit

Permalink
Fix hardcoded world height. (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdielKavash authored and Dream-Master committed Jan 16, 2024
1 parent 49cc146 commit b422192
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public boolean generate(World world, Random random, int x, int y, int z) {
// check if we're on dirt or grass
Block blockUnder = world.getBlock(x, y - 1, z);
if (blockUnder != Blocks.grass && blockUnder != Blocks.dirt && blockUnder != Blocks.mycelium
|| y >= 256 - treeHeight - 1) {
|| y >= world.getHeight() - treeHeight - 1) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/twilightforest/world/TFGenCanopyOak.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public boolean generate(World world, Random random, int x, int y, int z) {

// check if we're on dirt or grass
Material materialUnder = world.getBlock(x, y - 1, z).getMaterial();
if ((materialUnder != Material.grass && materialUnder != Material.ground) || y >= TFWorld.MAXHEIGHT - 12) {
if ((materialUnder != Material.grass && materialUnder != Material.ground) || y >= world.getHeight() - 12) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/twilightforest/world/TFGenCanopyTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public boolean generate(World world, Random random, int x, int y, int z) {

// check if we're on dirt or grass
Material materialUnder = world.getBlock(x, y - 1, z).getMaterial();
if ((materialUnder != Material.grass && materialUnder != Material.ground) || y >= TFWorld.MAXHEIGHT - 12) {
if ((materialUnder != Material.grass && materialUnder != Material.ground) || y >= world.getHeight() - 12) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/twilightforest/world/TFGenLargeWinter.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public boolean generate(World world, Random random, int x, int y, int z) {

// check if we're on dirt or grass
Block blockUnder = world.getBlock(x, y - 1, z);
if (blockUnder != Blocks.grass && blockUnder != Blocks.dirt || y >= TFWorld.MAXHEIGHT - treeHeight) {
if (blockUnder != Blocks.grass && blockUnder != Blocks.dirt || y >= world.getHeight() - treeHeight) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/twilightforest/world/TFGenMangroveTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public TFGenMangroveTree(boolean par1) {
@Override
public boolean generate(World world, Random random, int x, int y, int z) {
// we only start over water
if ((this.checkForWater && world.getBlock(x, y - 1, z) != Blocks.water) || y >= 128 - 18 - 1) {
if ((this.checkForWater && world.getBlock(x, y - 1, z) != Blocks.water) || y >= world.getHeight() - 18 - 1) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/twilightforest/world/TFGenMinersTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public boolean generate(World world, Random rand, int x, int y, int z) {

// check soil
Material materialUnder = world.getBlock(x, y - 1, z).getMaterial();
if ((materialUnder != Material.grass && materialUnder != Material.ground) || y >= TFWorld.MAXHEIGHT - 12) {
if ((materialUnder != Material.grass && materialUnder != Material.ground) || y >= world.getHeight() - 12) {
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/twilightforest/world/TFGenSmallTwilightOak.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public boolean generate(World world, Random rand, int x, int y, int z) {
int height = rand.nextInt(3) + this.minTreeHeight;
boolean allClear = true;

if (y >= 1 && y + height + 1 <= 256) {
if (y >= 1 && y + height + 1 <= world.getHeight()) {
int cy;
byte width;
int cz;
Expand Down Expand Up @@ -77,7 +77,7 @@ public boolean generate(World world, Random rand, int x, int y, int z) {
} else {
Block blockUsing = world.getBlock(x, y - 1, z);

if ((blockUsing == Blocks.grass || blockUsing == Blocks.dirt) && y < 256 - height - 1) {
if ((blockUsing == Blocks.grass || blockUsing == Blocks.dirt) && y < world.getHeight() - height - 1) {
this.setBlock(world, x, y - 1, z, Blocks.dirt);
width = 3;
byte var18 = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/twilightforest/world/TFGenSortingTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public TFGenSortingTree(boolean notify) {
public boolean generate(World world, Random rand, int x, int y, int z) {
// check soil
Material materialUnder = world.getBlock(x, y - 1, z).getMaterial();
if ((materialUnder != Material.grass && materialUnder != Material.ground) || y >= TFWorld.MAXHEIGHT - 12) {
if ((materialUnder != Material.grass && materialUnder != Material.ground) || y >= world.getHeight() - 12) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/twilightforest/world/TFGenTreeOfTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public boolean generate(World world, Random random, int x, int y, int z) {
int diameter = 1;

// do we have enough height?
if (y < 1 || y + height + diameter > TFWorld.MAXHEIGHT) {
if (y < 1 || y + height + diameter > world.getHeight()) {
// System.out.println("Failed with hollow tree of height " +
// height);
return false;
Expand Down

0 comments on commit b422192

Please sign in to comment.