A way to replace a specific amount of lines of code in Mixin?
-
This post is deleted!
-
This post is deleted!
-
-
@aftery I might be wrong, but your idea kind of reminds me of injecting at the top of the function, cancelling it all, and after that, adding the original code with the changes that I want to make. That's probably not what you mean though?
That function I posted was just a random one as an example of what I want to accomplish, by the way. The function that I actually want to make changes on is this one: https://pastebin.com/95kfXWUM
And these 3 lines are the only ones I want to somehow replace/remove:
playerEntity.updatePositionAndAngles(e, g, i, j, k); this.connection.send(new TeleportConfirmC2SPacket(packet.getTeleportId())); this.connection.send(new Full(playerEntity.getX(), playerEntity.getY(), playerEntity.getZ(), playerEntity.getYaw(), playerEntity.getPitch(), false));
I should have put that function as the example instead of that random one I chose...
EDIT: My only way to solve it that I still don't really like is by making different injections for each line. The first one would be
updatePositionAndAngles
, the 2nd oneTeleportConfirmC2SPacket
and so on. -
@aftery I have used that method too and I can say it does work, but here's where things get kinda worse. There's a mod that also injects to that function, but after the
this.positionLookSetup
statement and modifying it (in my case cancelling callbackinfo) prevents me from joining servers. Click here for more info. Essentially if my chosen version for a server is 1.13.2 and below, then I have 0 chances of joining it. If higher than 1.13.2 though, it works normally.EDIT: Perhaps a way to cancel callbackinfo until it reaches the
this.positionLookSetup
statement would be cool. -
-
-
Okay, holy crap. I managed to find a way to make it work with 1 injection only... My idea was that if
this.positionLookSetup
was false (which means that player hasn't joined the serveryet
) then keep the original code running normally. If it was set to true though, then cancel and add the custom code, and that way it will not affect the mod that sends its changes afterthis.positionLookSetup
. Tested it and there are no problems on any version now, so far. -
-