Skip to content

Commit

Permalink
don't require HeightLimitView to be passed to getTop* methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Gegy committed Jul 31, 2021
1 parent 8dd4869 commit 9b2d6f4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ loader_version=0.11.6
fabric_version=0.36.1+1.17

# Mod Properties
mod_version=0.1.0
mod_version=0.1.1
maven_group=xyz.nucleoid
archives_base_name=map-templates
18 changes: 6 additions & 12 deletions src/main/java/xyz/nucleoid/map_templates/MapTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.HeightLimitView;
import net.minecraft.world.Heightmap;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeKeys;
Expand Down Expand Up @@ -173,17 +172,12 @@ public Stream<MapEntity> getEntitiesInChunk(int chunkX, int chunkY, int chunkZ)
}

// TODO: store / lookup more efficiently?
public int getTopY(int x, int z, Heightmap.Type heightmap, HeightLimitView heightLimit) {
public int getTopY(int x, int z, Heightmap.Type heightmap) {
var predicate = heightmap.getBlockPredicate();

int maxY = heightLimit.getTopY();
int minY = heightLimit.getBottomY();

var bounds = this.getBoundsOrNull();
if (bounds != null) {
maxY = bounds.max().getY();
minY = bounds.min().getY();
}
var bounds = this.getBounds();
int minY = bounds.min().getY();
int maxY = bounds.max().getY();

var mutablePos = new BlockPos.Mutable(x, 0, z);
for (int y = maxY; y >= minY; y--) {
Expand All @@ -198,8 +192,8 @@ public int getTopY(int x, int z, Heightmap.Type heightmap, HeightLimitView heigh
return 0;
}

public BlockPos getTopPos(int x, int z, Heightmap.Type heightmap, HeightLimitView heightLimit) {
int y = this.getTopY(x, z, heightmap, heightLimit);
public BlockPos getTopPos(int x, int z, Heightmap.Type heightmap) {
int y = this.getTopY(x, z, heightmap);
return new BlockPos(x, y, z);
}

Expand Down

0 comments on commit 9b2d6f4

Please sign in to comment.