Use chunk instead of instance to check if an entity is on ground

This commit is contained in:
TheMode 2021-04-12 04:45:11 +02:00
parent bd90de0df2
commit 4932262750

View File

@ -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) {