<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[A way to replace a specific amount of lines of code in Mixin?]]></title><description><![CDATA[<p dir="auto">Let's say that there's a function that includes a few lines of code that a person doesn't want to see and wants to replace them in a Mixin file, how can they do that?</p>
<p dir="auto">In dumb talk:</p>
<p dir="auto">Original game function code:</p>
<pre><code class="language-t">    public void onEntityPosition(EntityPositionS2CPacket packet) {
        NetworkThreadUtils.forceMainThread(packet, this, this.client);
        Entity entity = this.world.getEntityById(packet.getId());
        if (entity != null) {
            double d = packet.getX();
            double e = packet.getY();
            double f = packet.getZ();
            entity.updateTrackedPosition(d, e, f);
            if (!entity.isLogicalSideForUpdatingMovement()) {
                float g = (float)(packet.getYaw() * 360) / 256.0F;
                float h = (float)(packet.getPitch() * 360) / 256.0F;
                entity.updateTrackedPositionAndAngles(d, e, f, g, h, 3, true);
                entity.setOnGround(packet.isOnGround());
            }

        }
    }
</code></pre>
<p dir="auto">A person wants to replace/mixin out only these:</p>
<pre><code class="language-t">double d = packet.getX();
double e = packet.getY();
double f = packet.getZ();
</code></pre>
<p dir="auto">After a way of replacing them:</p>
<pre><code class="language-t">    public void onEntityPosition(EntityPositionS2CPacket packet) {
        NetworkThreadUtils.forceMainThread(packet, this, this.client);
        Entity entity = this.world.getEntityById(packet.getId());
        if (entity != null) {
            double def = 0D; // AFTER
            entity.updateTrackedPosition(d, e, f);
            if (!entity.isLogicalSideForUpdatingMovement()) {
                float g = (float)(packet.getYaw() * 360) / 256.0F;
                float h = (float)(packet.getPitch() * 360) / 256.0F;
                entity.updateTrackedPositionAndAngles(d, e, f, g, h, 3, true);
                entity.setOnGround(packet.isOnGround());
            }

        }
    }
</code></pre>
<p dir="auto">Possible? If there's anyone with a good Mixin knowledge, mind giving a solution?</p>
<p dir="auto">EDIT: My only working way of accomplishing it is by making different injections for each part.</p>
]]></description><link>https://forum.liquidbounce.net/topic/3599/a-way-to-replace-a-specific-amount-of-lines-of-code-in-mixin</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Jul 2026 05:47:22 GMT</lastBuildDate><atom:link href="https://forum.liquidbounce.net/topic/3599.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 04 Feb 2022 15:36:13 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to A way to replace a specific amount of lines of code in Mixin? on Sat, 05 Feb 2022 16:58:17 GMT]]></title><description><![CDATA[<p dir="auto">Okay, holy crap. I managed to find a way to make it work with 1 injection only... My idea was that if <code>this.positionLookSetup</code> was false (which means that player hasn't joined the server <code>yet</code>) 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 after <code>this.positionLookSetup</code>. Tested it and there are no problems on any version now, so far.</p>
]]></description><link>https://forum.liquidbounce.net/post/28485</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28485</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Sat, 05 Feb 2022 16:58:17 GMT</pubDate></item><item><title><![CDATA[Reply to A way to replace a specific amount of lines of code in Mixin? on Mon, 14 Feb 2022 14:26:20 GMT]]></title><description><![CDATA[<p dir="auto">@mems sigma cleint mixin bypass men)))</p>
]]></description><link>https://forum.liquidbounce.net/post/28673</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28673</guid><dc:creator><![CDATA[halal.club]]></dc:creator><pubDate>Mon, 14 Feb 2022 14:26:20 GMT</pubDate></item><item><title><![CDATA[Reply to A way to replace a specific amount of lines of code in Mixin? on Sat, 05 Feb 2022 16:58:17 GMT]]></title><description><![CDATA[<p dir="auto">Okay, holy crap. I managed to find a way to make it work with 1 injection only... My idea was that if <code>this.positionLookSetup</code> was false (which means that player hasn't joined the server <code>yet</code>) 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 after <code>this.positionLookSetup</code>. Tested it and there are no problems on any version now, so far.</p>
]]></description><link>https://forum.liquidbounce.net/post/28485</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28485</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Sat, 05 Feb 2022 16:58:17 GMT</pubDate></item><item><title><![CDATA[Reply to A way to replace a specific amount of lines of code in Mixin? on Sat, 05 Feb 2022 13:21:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/aftery" aria-label="Profile: aftery">@<bdi>aftery</bdi></a> I guess I will go with multiple injections and then make use of <code>Redirect</code>. I will keep searching for any better results though.</p>
]]></description><link>https://forum.liquidbounce.net/post/28483</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28483</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Sat, 05 Feb 2022 13:21:58 GMT</pubDate></item><item><title><![CDATA[Reply to A way to replace a specific amount of lines of code in Mixin? on Sat, 05 Feb 2022 12:25:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/aftery" aria-label="Profile: aftery">@<bdi>aftery</bdi></a> 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 <code>this.positionLookSetup</code> statement and modifying it (in my case cancelling callbackinfo) prevents me from joining servers. Click <a href="https://github.com/Earthcomputer/multiconnect/blob/f32fb2bd939842b53c91c43113e4c4a965ceb82e/src/main/java/net/earthcomputer/multiconnect/protocols/v1_13_2/mixin/MixinClientPlayNetworkHandler.java#L196" target="_blank" rel="noopener noreferrer nofollow ugc">here</a> 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.</p>
<p dir="auto">EDIT: Perhaps a way to cancel callbackinfo until it reaches the <code>this.positionLookSetup</code> statement would be cool.</p>
]]></description><link>https://forum.liquidbounce.net/post/28479</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28479</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Sat, 05 Feb 2022 12:25:16 GMT</pubDate></item><item><title><![CDATA[Reply to A way to replace a specific amount of lines of code in Mixin? on Sat, 05 Feb 2022 01:40:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/aftery" aria-label="Profile: aftery">@<bdi>aftery</bdi></a> 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?</p>
<p dir="auto">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: <a href="https://pastebin.com/95kfXWUM" target="_blank" rel="noopener noreferrer nofollow ugc">https://pastebin.com/95kfXWUM</a></p>
<p dir="auto">And these 3 lines are the only ones I want to somehow replace/remove:</p>
<pre><code class="language-t">        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));
</code></pre>
<p dir="auto">I should have put that function as the example instead of that random one I chose...</p>
<p dir="auto">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 <code>updatePositionAndAngles</code>, the 2nd one <code>TeleportConfirmC2SPacket</code> and so on.</p>
]]></description><link>https://forum.liquidbounce.net/post/28473</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28473</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Sat, 05 Feb 2022 01:40:08 GMT</pubDate></item><item><title><![CDATA[Reply to A way to replace a specific amount of lines of code in Mixin? on Fri, 04 Feb 2022 17:48:20 GMT]]></title><description><![CDATA[<p dir="auto">Nevermind, I will consider my method after a bit of intensive thinking.</p>
<p dir="auto">EDIT: If someone still has a better way then feel free to post.</p>
]]></description><link>https://forum.liquidbounce.net/post/28460</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28460</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Fri, 04 Feb 2022 17:48:20 GMT</pubDate></item><item><title><![CDATA[Reply to A way to replace a specific amount of lines of code in Mixin? on Fri, 04 Feb 2022 16:36:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/idk-my-name" aria-label="Profile: idk-my-name">@<bdi>idk-my-name</bdi></a> In my case it's too dangerous to use due to the fact that some other mods might potentially want to modify the same function too and if I overwrite it, only bad stuff will happen.</p>
]]></description><link>https://forum.liquidbounce.net/post/28454</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28454</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Fri, 04 Feb 2022 16:36:16 GMT</pubDate></item><item><title><![CDATA[Reply to A way to replace a specific amount of lines of code in Mixin? on Fri, 04 Feb 2022 16:26:04 GMT]]></title><description><![CDATA[<p dir="auto">@Overwrite</p>
]]></description><link>https://forum.liquidbounce.net/post/28452</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28452</guid><dc:creator><![CDATA[idk my name]]></dc:creator><pubDate>Fri, 04 Feb 2022 16:26:04 GMT</pubDate></item></channel></rss>