CCBlueX Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    I need some help with Mixin

    Kotlin/Java
    3
    5
    122
    Loading More Posts
    • 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.
    • VanillaMirror
      VanillaMirror last edited by

      As title
      i wanna find a way to do it but failed :<
      So if some one can give an helping hand for make boolean flag2 = d0 * d0 + d1 * d1 + d2 * d2 > 9.0E-4D || this.positionUpdateTicks >= 20;
      to true
      btw. flag2 is in EntityPlayerSP.onUpdateWalkingPlayer() and in EntityPlayerSP's 221
      Please added it with valid

      M 1 Reply Last reply Reply Quote 0
      • M
        mems Moderator @VanillaMirror last edited by

        @vanillamirror said in I need some help with Mixin:

        So if some one can give an helping hand for make boolean flag2 = d0 * d0 + d1 * d1 + d2 * d2 > 9.0E-4D || this.positionUpdateTicks >= 20;
        to true

        ALWAYS set to true though?

        VanillaMirror 1 Reply Last reply Reply Quote 0
        • VanillaMirror
          VanillaMirror @mems last edited by

          @mems yes

          M 1 Reply Last reply Reply Quote 0
          • M
            mems Moderator @VanillaMirror last edited by mems

            @vanillamirror said in I need some help with Mixin:

            @mems yes

            Alright, this is my method to solve this, even though there are probably a few more:

            First, you use the ModifyVariable injection, with STORE as the annotation type, then we make use of the name parameter, or whatever it's called. In your case, you are looking to target the flag2 variable's value that exists in the onUpdateWalkingPlayer function.

            This is how it's done in code:

            @ModifyVariable(method = "onUpdateWalkingPlayer", at = @At("STORE"), name = "flag2")
            

            Then you add the required function (boolean type as the variable is a boolean type):

            private boolean nameThatYouWouldLike(boolean value) {
            
            }
            

            boolean value contains the default value result that is from the flag2 variable.

            This: d0 * d0 + d1 * d1 + d2 * d2 > 9.0E-4D || this.positionUpdateTicks >= 20; in case you ask.

            Replace the nameThatYouWouldLike with whatever you want, or keep it like that, as long as it has a name.

            Finally, you add your custom code inside and in your case again it's to set the value to true. Remember, you must also use return to the new value you set, whether it's false or true, or something else. An example:

                private boolean nameThatYouWouldLike(boolean value) {
                    if (LiquidBounce.moduleManager.getModule(XRay.class).getState()) {
                        return true;
                    }
                    
                    return value;
                }
            

            return value this will return the value result from the original code, which is this: d0 * d0 + d1 * d1 + d2 * d2 > 9.0E-4D || this.positionUpdateTicks >= 20;

            return true is your modified code. (it just returns true, it won't change, as long as the statement is also true)

            This is how the full version of the example looks like:

                @ModifyVariable(method = "onUpdateWalkingPlayer", at = @At("STORE"), name = "flag2")
                private boolean nameThatYouWouldLike(boolean value) {
                    if (LiquidBounce.moduleManager.getModule(XRay.class).getState()) {
                        return true;
                    }
            
                    return value;
                }
            

            And now, I assume you know how to code, so replace this:

                    if (LiquidBounce.moduleManager.getModule(XRay.class).getState()) {
                        return true;
                    }
            

            with something of your own.

            Long ass post, but I want to make sure you understand. If you have any questions regarding that, don't hesitate to ask.

            ? 1 Reply Last reply Reply Quote 1
            • ?
              A Former User @mems last edited by A Former User

              @mems wow, a very long post with no grammar errors, 😳

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              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