mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-22 08:02:31 +01:00
Use chunk instead of instance to check if an entity is on ground
This commit is contained in:
parent
bd90de0df2
commit
4932262750
@ -53,8 +53,8 @@ public final class EntityUtils {
|
||||
}
|
||||
|
||||
public static boolean isOnGround(@NotNull Entity entity) {
|
||||
final Instance instance = entity.getInstance();
|
||||
if (instance == null)
|
||||
final Chunk chunk = entity.getChunk();
|
||||
if (chunk == null)
|
||||
return false;
|
||||
|
||||
final Position entityPosition = entity.getPosition();
|
||||
@ -62,7 +62,9 @@ public final class EntityUtils {
|
||||
// TODO: check entire bounding box
|
||||
final BlockPosition blockPosition = entityPosition.toBlockPosition().subtract(0, 1, 0);
|
||||
try {
|
||||
final short blockStateId = instance.getBlockStateId(blockPosition);
|
||||
final short blockStateId = chunk.getBlockStateId(blockPosition.getX(),
|
||||
blockPosition.getY(),
|
||||
blockPosition.getZ());
|
||||
final Block block = Block.fromStateId(blockStateId);
|
||||
return block.isSolid();
|
||||
} catch (NullPointerException e) {
|
||||
|
Loading…
Reference in New Issue
Block a user