@sudofox opened this Issue on October 4th 2021

Description

When riding an entity, such as a horse, a pig, or a minecart, the onPostMotion event is never triggered, thus never handled, which breaks some auras such as FeedAura and KillAura (interestingly, not MultiAura)

 ag "EVENTS.add\(PostMotionListener"
src/main/java/net/wurstclient/hacks/KillauraHack.java
173:            EVENTS.add(PostMotionListener.class, this);

src/main/java/net/wurstclient/hacks/SneakHack.java
49:             EVENTS.add(PostMotionListener.class, this);

src/main/java/net/wurstclient/hacks/FeedAuraHack.java
95:             EVENTS.add(PostMotionListener.class, this);

Old Description

When inside a minecart, FeedAura does not seem to be used. I am trying to breed sheep automatically for a farm.

I considered hitboxes of minecart riding were maybe interfering, but I both tried riding by myself as well as on top of a saddle-pig inside selfsame minecart (which should raise my hitbox) and it didn't seem to make a difference.

I can hold right click to feed the sheep from the minecart just fine.

@sudofox commented on October 8th 2021

I've tested a bit further and found that riding any entity also has the same effect: minecarts, pigs, horses, and so on.

PR #438 bases ShearAuraHack off of FeedAura and suffers from the same issue -- but it does make it easier to tell that it's not working because sheep having wool is a good visual indicator. (I patched @ShayBox's changes into the latest commit from this repo and built it in order to test)

I'll see if I can work out what's going on here

@sudofox commented on October 8th 2021

I cloned MobEsp and put in the same chunk of code used for ShearEsp and, with that being more complex, it doesn't seem to be a failure in actually finding the entities to target.

https://user-images.githubusercontent.com/3847441/136615946-c04237bc-7c2c-4250-b00b-8a066abd6a42.mp4

After a bit more digging, I found that while riding another entity, while it is finding the entity and it is trying to shear them, the post-motion bit is not taking place.

WURST.getRotationFaker().faceVectorPacket(target.getBoundingBox().getCenter());

I suspect that riding another entity is affecting the rotation-faker somehow. onPostMotion inside the ShearAuraHack (and thus also the FeedAura) is not fired at all while riding the horse in my test world.

@sudofox commented on October 8th 2021

I threw in some debug logging here and observed for certain that PostMotionEvent is never fired when riding an entity.

diff --git a/src/main/java/net/wurstclient/mixin/ClientPlayerEntityMixin.java b/src/main/java/net/wurstclient/mixin/ClientPlayerEntityMixin.java
index ad44d35e..7303a68b 100644
--- a/src/main/java/net/wurstclient/mixin/ClientPlayerEntityMixin.java
+++ b/src/main/java/net/wurstclient/mixin/ClientPlayerEntityMixin.java
@@ -40,6 +40,7 @@ import net.wurstclient.events.PostMotionListener.PostMotionEvent;
 import net.wurstclient.events.PreMotionListener.PreMotionEvent;
 import net.wurstclient.events.UpdateListener.UpdateEvent;
 import net.wurstclient.hacks.FullbrightHack;
+import net.wurstclient.util.ChatUtils;
 import net.wurstclient.mixinterface.IClientPlayerEntity;

 <a class='mention' href='https://github.com/Mixin'>@Mixin</a>(ClientPlayerEntity.class)
@@ -115,6 +116,7 @@ public class ClientPlayerEntityMixin extends AbstractClientPlayerEntity
        <a class='mention' href='https://github.com/Inject'>@Inject</a>(at = {<a class='mention' href='https://github.com/At'>@At</a>("TAIL")}, method = {"sendMovementPackets()V"})
        private void onSendMovementPacketsTAIL(CallbackInfo ci)
        {
+               ChatUtils.message("FIRING PostMotionEvent.");
                EventManager.fire(PostMotionEvent.INSTANCE);
        }

https://user-images.githubusercontent.com/3847441/136619715-5a0d3b2a-2fef-4db3-a834-c46875e02cc2.mp4

@sudofox commented on October 8th 2021

I can make it work if I don't rely on the PostMotion event and instead follow the same method that MultiAura uses of sending the PlayerMoveC2SPacket.

I suggest auditing uses of the PostMotion event as a trigger for actions throughout the client to ensure that they behave properly when PostMotion is not fired.