Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

LiquidBounce Forum

  1. Home
  2. General
  3. A way to replace a specific amount of lines of code in Mixin?

A way to replace a specific amount of lines of code in Mixin?

Scheduled Pinned Locked Moved Solved General
14 Posts 5 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I idk my name

    @Overwrite

    ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #3

    @idk-my-name 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.

    S 1 Reply Last reply
    0
    • ? A Former User

      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?

      In dumb talk:

      Original game function code:

          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());
                  }
      
              }
          }
      

      A person wants to replace/mixin out only these:

      double d = packet.getX();
      double e = packet.getY();
      double f = packet.getZ();
      

      After a way of replacing them:

          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());
                  }
      
              }
          }
      

      Possible? If there's anyone with a good Mixin knowledge, mind giving a solution?

      EDIT: My only working way of accomplishing it is by making different injections for each part.

      S Offline
      S Offline
      SigmaClient 0
      wrote on last edited by SigmaClient 0
      #4
      This post is deleted!
      1 Reply Last reply
      0
      • ? A Former User

        @idk-my-name 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.

        S Offline
        S Offline
        SigmaClient 0
        wrote on last edited by
        #5
        This post is deleted!
        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by A Former User
          #6

          Nevermind, I will consider my method after a bit of intensive thinking.

          EDIT: If someone still has a better way then feel free to post.

          1 Reply Last reply
          0
          • System has marked this topic as solved on
          • A Offline
            A Offline
            Aftery
            wrote on last edited by
            #7
            This post is deleted!
            ? 1 Reply Last reply
            0
            • A Aftery

              This post is deleted!

              ? Offline
              ? Offline
              A Former User
              wrote on last edited by A Former User
              #8

              @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 one TeleportConfirmC2SPacket and so on.

              A 1 Reply Last reply
              0
              • ? A Former User

                @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 one TeleportConfirmC2SPacket and so on.

                A Offline
                A Offline
                Aftery
                wrote on last edited by Aftery
                #9
                This post is deleted!
                ? 1 Reply Last reply
                0
                • A Aftery

                  This post is deleted!

                  ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by A Former User
                  #10

                  @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.

                  A 1 Reply Last reply
                  0
                  • ? A Former User

                    @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.

                    A Offline
                    A Offline
                    Aftery
                    wrote on last edited by
                    #11
                    This post is deleted!
                    ? 1 Reply Last reply
                    0
                    • A Aftery

                      This post is deleted!

                      ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #12

                      @aftery I guess I will go with multiple injections and then make use of Redirect. I will keep searching for any better results though.

                      1 Reply Last reply
                      0
                      • System has marked this topic as unsolved on
                      • System has marked this topic as solved on
                      • ? Offline
                        ? Offline
                        A Former User
                        wrote on last edited by A Former User
                        #13

                        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 server yet) 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 this.positionLookSetup. Tested it and there are no problems on any version now, so far.

                        H 1 Reply Last reply
                        1
                        • System has marked this topic as unsolved on
                        • System has marked this topic as solved on
                        • ? A Former User

                          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 server yet) 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 this.positionLookSetup. Tested it and there are no problems on any version now, so far.

                          H Offline
                          H Offline
                          halal.club
                          wrote on last edited by
                          #14

                          @mems sigma cleint mixin bypass men)))

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          About
                          • Terms of Service
                          • Privacy Policy
                          • Status
                          • Contact Us
                          Downloads
                          • Releases
                          • Source code
                          • License
                          Docs
                          • Tutorials
                          • CustomHUD
                          • AutoSettings
                          • ScriptAPI
                          Community
                          • Forum
                          • Guilded
                          • YouTube
                          • Twitter
                          • D.Tube
                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups