You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The entity checking algorithm occasionally grabs the wrong entity if another is too close to the player. Sometimes it will grab an entity behind the player, sometimes it'll grab an entity to the side, etc.
Another issue is that if there's a smaller entity (I.E. squid) in front of a larger entity (I.E. skeleton), the algorithm will return neither and will cause the preceding command to fail.
The algorithm is as follows.
publicstaticEntitygetEntityInCrosshairs(Playerplayer) {
intrange = 10;
Block[] blocks = player.getLineOfSight(null, range).toArray(newBlock[0]);
List<Entity> near = player.getNearbyEntities(range, range, range);
for (Blockblock : blocks) {
for (Entityentity : near) {
if (entity.getLocation().distance(block.getLocation()) < 2) {
returnentity;
}
}
}
returnnull;
}
The entity checking algorithm occasionally grabs the wrong entity if another is too close to the player. Sometimes it will grab an entity behind the player, sometimes it'll grab an entity to the side, etc.
Another issue is that if there's a smaller entity (I.E. squid) in front of a larger entity (I.E. skeleton), the algorithm will return neither and will cause the preceding command to fail.
The algorithm is as follows.
It can also be found here.
The text was updated successfully, but these errors were encountered: