3 | Creating a tweaker
How to create a tweaker
What is a tweaker?
A tweaker allows arguments to be passed into it, and then allow you to inject your mixins into the Minecraft class loader
Making the class
So first, go to the mixins folder in your project heirachy
project
-> src
-> java
-> group_name
-> project_name
-> mixins <-- Go hereIn the previous tutorial, in the build.gradle file, we set the tweakclass variable to something like so
tweakClass = "me.ddozzi.exampleclient.mixins.ExampleClientTweaker"Take the last part of that (the tweaker class name), and in the mixins folder create a class by that name. An image is shown below.

Writing the tweaker
First, you need to implement the ITweaker interface, just add implements ITweaker to your class definition
Next, you should add the launch arguments array, this will store any launch arguments needed for later
Now we need to handle the launch arguments, or options, so you can simply just override acceptOptions
Add the args to our launchArgs array, so we can use them later
We're going to only deal with 3 options, so we can easily define them as a set of constants
Now we need to
Check if the launch args contains each constant, if not add it
Check if the profile isn't
null(profile contains metadata about the game, for example, the version)
We can do this by checking with a few if statements like so
You also need to define a function for injection into the class loader
For the injection function, you must first initialize MixinBootsrap, which is trivially done
Next, we need to register out mixin configuration file and retrieve the default mixin environment
Just like in the build.gradle file, substitute PROJECT_NAME with your project's name
Now we just need to check if there is no current obfuscation set, then set the obfuscation context to the notch obfuscation
Now we need to inform Minecraft that this modification is running on the client side
Lastly, we just add the boiler plate which allows Minecraft to retrieve the launch arguments and the launch target
You should now be able to run the client!

Last updated
Was this helpful?