Access widening is a type of class tweaking used to loosen the access limits of classes, methods and fields and reflect that change in the decompiled source. This includes making them public, extendable and/or mutable.
To access fields or methods, it can be safer and simpler to use accessor mixins, but there are two situations where accessors are insufficient and access widening is necessary:
- If you need to access a
private,protectedor package-private class - If you need to override a
finalmethod, or subclass afinalclass
However, unlike accessor mixins, class tweaking only works on Vanilla Minecraft classes, and not on other mods.
Access Directives
Access widener entries start with one of three directive keywords to specify the type of modification to apply.
Accessible
accessible can target classes, methods and fields:
- Fields and Classes are made public.
- Methods are made public, and final if originally private.
Making a method or field accessible also makes its class accessible.
Extendable
extendable can target classes and methods:
- Classes are made public and non-final
- Methods are made protected and non-final
Making a method extendable also makes its class extendable.
Mutable
mutable can make a field non-final.
To make a private final field both accessible and mutable, you must make two separate entries in the file.
Transitive Directives
In order to expose certain access widener changes to mods depending on yours, you prefix the relevant directives with transitive-*:
txt
transitive-accessible
transitive-extendable
transitive-mutableSpecifying Targets
For class tweaking, classes use their internal names. For fields and methods you must specify their class name, their name, and their bytecode descriptor.
TIP
The names of targets need to correspond to your current mappings.
Format:
txt
<accessible / extendable> class <className>Example:
txt
# Makes the inner class TypeSpecificTrade in VillagerTrades public
accessible class net/minecraft/world/entity/npc/villager/VillagerTrades$TypeSpecificTradeGenerating Entries
Manually writing access widener entries is time-consuming and prone to human error. Let's look at tools that simplify a part of the process by allowing you to generate and copy entries.
mcsrc.dev
Available for all versions with an unobfuscated JAR namely 1.21.11 and above, mcsrc allows you to decompile and navigate Minecraft source in the browser and copy Mixin, access widener or access transformer targets to clipboard. The names of classes, methods and fields on mcsrc will align with Mojang Mappings.
To copy an access widener entry, first navigate to the class which you want to modify, and right-click on your target to open the popup menu.

Then, click on Copy Class Tweaker / Access Widener, and a confirmation should appear at the top of the page.

You can then paste the entry in your class tweaker file.
Minecraft Development Plugin (IntelliJ IDEA)
The Minecraft Development Plugin, also known as MCDev, is an IntelliJ IDEA plugin to assist in various aspects of Minecraft mod development. For example, it lets you copy access widener entries from the decompiled source target to the clipboard.
To copy an access widener entry, first navigate to the class which you want to modify, and right-click on your target to open the popup menu.

Then, click on Copy / Paste Special and AW Entry.

A confirmation should now pop up on the element you right-clicked.

You can then paste the entry in your class tweaker file.
Linkie
Linkie is a website that allows you to browse and translate across mappings. It also provides access widener entries for the class, method or field you're viewing.
First, make sure you have the correct version and mappings selected on the menu on the left:

Then, search for the element you want to modify, and the access widener entry will be listed as AW under the result:

You can copy it and then paste the entry in your class tweaker file.
Applying Changes
To see your changes applied, you must refresh your Gradle project by regenerating sources. The elements you targeted should have their access limits modified accordingly. If modifications do not appear, you can try validating the file and checking if any errors appear.
























