Skip to content

Latest commit

 

History

17 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🪡 TweakFabric

A Fabric implementation of TweakSuite


⚠️ Wait!

If you don't already know what TweakSuite does, read its README.


The Process

  1. You write de-obfuscated Yarn or Mojang code.
  2. You run the execute Gradle task.
  3. TweakFabric compiles, remaps, decompiles, and sends your code to the game.
  4. Minecraft executes it. During runtime.

Getting Started

  1. Either build the client-side mod, or download it from the latest release.
  2. Launch Fabric with the mod installed
  3. Run the command /tweakfabric new or clone the template repo to a directory of your choosing.
  4. Write code, hit execute and watch the magic happen.

Limitations

On official mappings, classes with identical names in separate directories cannot compile.

Since we are working with Minecraft's client-side internals, we must tiptoe around how we access classes. When we happen to be using official mappings, Minecraft's classes don't have a package structure.

This makes it impossible to import them in a Java file, and thus when we remap our code, we must compile it in the same base package as every other Minecraft class, so it can reference Minecraft's classes.

This is only an issue on mojang's official mappings, because intermediary and yarn have their classes in organized subdirectories. If you want to use subdirectories, go with intermediary or yarn mappings. Usually, use intermediary by default, and on a few clients, you can reconfigure which mappings it should use.


Re-running Entrypoints

TweakSuite caches the latest entrypoint(s) per-compilation.

With TweakFabric, you can re-run the most recent entrypoint(s), using the keybind L by default.

This will re-run any code, regardless of safety, so be careful here.


The Kill Switch

This will attempt to stop TweakSuite's code execution.

You have two options:

  1. An in-game keybind (K by default)
  2. The killProcesses Gradle task

Realistically, you’ll only need this if you get stuck in a while (true) loop.
And while I could tell you not to write infinite loops... let’s be real. They’re fun, and useful for testing. So, the kill switch exists.

Safe infinite loop examples

Try to write safe infinite loops, like the following:

while (ThreadManager.permits()) {
    // this is safe
}

while (true) { // this is also safe
    ThreadManager.beg();
}

while (true) { // still safe
    ThreadManager.sleepMS(100);
}

while (ThreadManager.sleepSec(1)) {
    // safe again
}
How it works
  1. First, it asks nicely. If your code is merciful enough to use ThreadManager in the loop, the thread should honor the kill request. Terms and conditions apply for concurrency.

  2. Then, it chooses violence. If permit checking isn’t implemented (or was ignored), it escalates to Thread#stop() or ThreadKiller.kill(), depending on your JDK. This is unsafe, but it might work.

  3. If that still doesn’t work: You’re on your own. I suggest you reflect on your decisions, and then start using ThreadManager.


Sincerely,
Redot ❤️

About

A runtime class remapping and injection tool for Fabric clients.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages