LatvianModder's Modding Tutorials

  1. Intro
  2. Setting up workspace in IntelliJ IDEA
  3. & Dependencies
  4. GitHub & Multitple mods in one Project
  5. Proxy, Sides, Event Handlers & Basic mod files
  6. Items & Recipes
  7. Blocks
  8. Block States
  9. Tile Entities
  10. Tile Entity Special Renderers
  11. Commands & Server/Client only mods
  12. Config
  13. Capabilities
  14. Guis and Containers
  15. Network & IMessages
  16. Entities
  17. Loot Tables
  18. Sounds
  19. Access Transformers
  20. Advanced IRecipes
  21. Other useful resources

Access Transformers

What are Access Transformers?

You may want to access a private field in a Minecraft class, let's use Style.bold as an example. That field has private access, meaning you can't call access it outside it's own class. Luckly, Forge has a way to help with this problem, in case you really need to access it.

How to use them?

  1. Create src/main/resources/META-INF folder, and inside it mymod_at.cfg file.
  2. Find the field or method you want to access - you can use K9#8016 bot on discord with ?mcpf (for fields) or ?mcpm (for methods) command, e.g. ?mcpf bold. You will get something like this:
    MC 1.12: net/minecraft/util/text/Style.bold
    Name: c => field_150248_c => bold
    Comment: None
    Side: BOTH
    AT: public net.minecraft.util.text.Style field_150248_c # bold

    Copy the AT part, a.k.a public net.minecraft.util.text.Style field_150248_c # bold and paste that into your .cfg file. It will sometimes give multiple responses, so make sure you use the correct one.
  3. Add this code to your build.gradle under processResources:
    jar {
    	manifest {
    		attributes 'FMLAT': 'mymod_at.cfg'
  4. Re-run setupDecompWorkspace task and refresh Gradle module and it's done! Now Style.bold is available as
    public Boolean bold;

How about final fields?

You may encounter a field that is not only private, but also final, which means you can't modify it. If you need that, it's the same setup as before, except you use public-f instead of public in your AT entry. That will remove final and make the field public. (Same thing works with methods too)