{"type": "session", "harness": "opencode", "id": "mc-0023", "name": "Writing access wideners using Mojang-mapped names"} {"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 write access wideners with Mojang mappings in Fabric?"}} {"type": "message", "message": {"role": "assistant", "content": "Access wideners allow you to make private/protected members public in Minecraft's code using Mojang-mapped names.\n\n**Access widener file (mymod.accesswidener):**\n```accesswidener\naccessWidener v2 named\n\n# Make a private method public\naccessible method net/minecraft/world/entity/LivingEntity tick ()V\n\n# Make a protected field accessible\naccessible field net/minecraft/world/level/block/Block stateDefinition Lnet/minecraft/world/level/block/state/StateDefinition;\n\n# Make a private constructor accessible\naccessible method net/minecraft/world/entity/Entity (Lnet/minecraft/world/level/Level;)V\n```\n\n**fabric.mod.json integration:**\n```json\n{\n \"schemaVersion\": 1,\n \"id\": \"mymod\",\n \"accessWidener\": \"mymod.accesswidener\",\n \"entrypoints\": {\n \"main\": [\"com.example.mymod.MyMod\"]\n }\n}\n```\n\n**Using access-widened members in code:**\n```java\npackage com.example.mymod;\n\nimport net.minecraft.world.entity.LivingEntity;\nimport net.minecraft.world.level.block.Block;\n\npublic class MyMod {\n public void modifyEntity(LivingEntity entity) {\n // Can now call tick() even though it's normally protected\n entity.tick();\n }\n\n public void accessBlockState(Block block) {\n // Access the stateDefinition field directly\n var stateDef = block.stateDefinition;\n }\n}\n```\n\n**Access widener syntax rules:**\n- Use `named` namespace for Mojang mappings\n- Method descriptors use Mojang names\n- Field descriptors use Mojang class paths\n- Only modify members in Minecraft's code, not mod code\n\n**Gradle configuration:**\n```groovy\n// build.gradle\nfabricApi {\n accessWidenerPath = file(\"mymod.accesswidener\")\n}\n```"}}