Files

22 lines
583 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# NPC.js — findGroundY() (satır 510)
[← NPC.js](index.md) · [← Master](../../wiki.md)
```javascript
function findGroundY(world, x, y, z) {
var yi = Math.floor(y);
for (var dy = 10; dy >= -10; dy--) {
var cy = yi + dy;
try {
var b1 = world.getBlock(x, cy, z);
var b2 = world.getBlock(x, cy + 1, z);
var b3 = world.getBlock(x, cy + 2, z);
if (!b1.isAir() && b2.isAir() && b3.isAir()) {
return cy + 1;
}
} catch(e) {}
}
return y;
}
```