|
22 | 22 | import ac.grim.grimac.player.GrimPlayer;
|
23 | 23 | import ac.grim.grimac.utils.collisions.datatypes.SimpleCollisionBox;
|
24 | 24 | import ac.grim.grimac.utils.data.packetentity.PacketEntity;
|
| 25 | +import ac.grim.grimac.utils.data.packetentity.PacketEntityHorse; |
25 | 26 | import ac.grim.grimac.utils.data.packetentity.dragon.PacketEntityEnderDragonPart;
|
26 | 27 | import ac.grim.grimac.utils.nmsutil.ReachUtils;
|
27 | 28 | import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
@@ -234,6 +235,27 @@ private CheckResult checkReach(PacketEntity reachEntity, Vector3d from, boolean
|
234 | 235 | // if the entity is not exempt and the entity is alive
|
235 | 236 | if ((!blacklisted.contains(reachEntity.getType()) && reachEntity.isLivingEntity()) || reachEntity.getType() == EntityTypes.END_CRYSTAL) {
|
236 | 237 | if (minDistance == Double.MAX_VALUE) {
|
| 238 | + // Interacting with a horse (not necessarily mounting it) forcefully sets the |
| 239 | + // rotation of the player to the horse's rotation on the client in versions 1.13 |
| 240 | + // and lower, so in that case the rotation sent in the following flying packet |
| 241 | + // is not the one used for interacting with the horse, but we used it for the reach |
| 242 | + // calculation, which leads to hitbox flags. However, the player's position is |
| 243 | + // still accurate, so this forced rotation will not cause reach falses, and we |
| 244 | + // can still check reach on horse interactions. |
| 245 | + // |
| 246 | + // This even affects attacks from the same tick as the client only ray traces |
| 247 | + // at the start of the tick, so an attack can occur first and then the interaction |
| 248 | + // happens which breaks the rotation. We exempt attacks automatically because the |
| 249 | + // horseInteractCausedForcedRotation is set as soon as an interact is received |
| 250 | + // and is only set to false on the next flying/transaction. This function here is |
| 251 | + // run either directly on attack/interact if packets have previously been cancelled |
| 252 | + // or on that next flying/transaction so we always know if the rotation was forced. |
| 253 | + // If there wasn't any interaction with a horse in a tick, attacks can still be |
| 254 | + // checked normally. |
| 255 | + if (reachEntity instanceof PacketEntityHorse && player.packetStateData.horseInteractCausedForcedRotation) { |
| 256 | + return NONE; |
| 257 | + } |
| 258 | + |
237 | 259 | cancelBuffer = 1;
|
238 | 260 | return new CheckResult(ResultType.HITBOX, "");
|
239 | 261 | } else if (minDistance > maxReach) {
|
|
0 commit comments