-
Notifications
You must be signed in to change notification settings - Fork 1
Patching Merged Resources
It may be tempting to write patches for tags and other 'merged' resources (called 'resource stacks' in Minecraft's code), but this comes with some caveats. First, let us clarify what a merged resource is exactly. A merged resource is any resource (file) that Minecraft merges together when it reads them. Tags are a perfect example of this — all copies of a given tag are merged together into one list of tag entries. Other examples include language files (these are also merged across namespaces) and the sounds.json file.
Here's a list of all merged resources (as of 1.21.1):
- Block states (everything under
blockstates/), although any duplicate definitions appear to only cause errors - Font definitions (everything under
font/) - Language files (everything under
lang/) - Sound definitions (
sounds.json) - Tags (everything under
tags/) - Texture atlas definitions (everything under
atlases/) - On NeoForge, data maps (everything under
data_maps/) and the Global Loot Modifiers list (neoforge:loot_modifiers/global_loot_modifiers.json)
Now, the problem with patching these merged resources is that many versions of the resource could exist at once — so which one is the patch supposed to apply to? Patched takes the stance that the patch should apply to only the version of the file in the same pack. This avoids accidentally patching potentially thousands of files, reducing both error potential and performance impact.
This limitation might seem like it defeats the purpose of patching these files. After all, what good is patching your version of a tag when what you really want to patch is Minecraft's definition, or someone else's? However, there's still some things you can do. For example, conditional tag additions/removal based on the runtime environment (like what mods are loaded, or config options). Unfortunately, in practice this is not very motivating since tags support optional entries and therefore the need for conditional additions is virtually nonexistent.
One of the biggest appeals of patching tags is the ability to remove entries from these tags, without needing to completely redefine the tag. However, you do not need Patched to do this — (Neo)Forge supports tag entry removal using the remove key (surprisingly since tags were introduced), and while Fabric/Quilt do not seem to have equivalents, someone could easily create a mod to fill in the gap. Then it would be as simple as having your entries-to-remove in every loader-specific remove section, or duplicating one section to the others using Patched's copy operation.