File size: 2,564 Bytes
d517dc9
 
 
 
1
2
3
4
5
{"type": "session", "harness": "opencode", "id": "mc-0024", "name": "Applying source patches across different mapping sets"}
{"type": "message", "message": {"role": "system", "content": "You are an expert Minecraft modder who understands mapping systems (Mojang, Yarn, Intermediary) and how to work with unobfuscated/deobfuscated Minecraft source code."}}
{"type": "message", "message": {"role": "user", "content": "How do I create source patches that work across different mapping sets?"}}
{"type": "message", "message": {"role": "assistant", "content": "Source patches must account for different mapping names to be reusable across mapping sets.\n\n**Patch format with mapping metadata:**\n```patch\n--- a/src/main/java/com/example/mymod/BlockMixin.java\n+++ b/src/main/java/com/example/mymod/BlockMixin.java\n@@ -10,7 +10,7 @@\n import net.minecraft.world.level.block.Block;\n \n @Mixin(Block.class)\n-public class BlockMixin {\n+public abstract class BlockMixin {\n     @Inject(method = \"defaultBlockState\", at = @At(\"HEAD\"))\n     private void onGetDefaultBlockState(CallbackInfoReturnable<BlockState> cir) {\n-        // Old code\n+        // New code using Mojang names\n     }\n }\n```\n\n**Mapping-aware patch generation:**\n```java\nimport dev.enooloox.mappingio.*;\n\npublic class MappingAwarePatcher {\n    public static String translatePatch(String patch, Mappings sourceMappings, Mappings targetMappings) {\n        MappingSourceNamespaceRemapper remapper = new MappingSourceNamespaceRemapper(sourceMappings);\n        \n        // Parse patch and replace method/field names\n        String[] lines = patch.split(\"\\n\");\n        StringBuilder result = new StringBuilder();\n        \n        for (String line : lines) {\n            if (line.startsWith(\"+\") || line.startsWith(\"-\")) {\n                line = remapper.rename(line, \"named\", \"intermediary\");\n            }\n            result.append(line).append(\"\\n\");\n        }\n        return result.toString();\n    }\n}\n```\n\n**Git patch workflow:**\n```bash\n# Create patch with Mojang names\ngit diff > mojang-patch.diff\n\n# Convert to Yarn names\njava -jar mapping-tools.jar convert \\\n  --input mojang-patch.diff \\\n  --from mojang \\\n  --to yarn \\\n  --output yarn-patch.diff\n\n# Apply converted patch\ngit apply yarn-patch.diff\n```\n\n**Best practices:**\n1. Always specify which mapping set your patch uses\n2. Use intermediary names for maximum compatibility\n3. Test patches against both mapping sets\n4. Document mapping dependencies in patch headers"}}