From 4c37051951cefdc60bf30612048591526ae61bee Mon Sep 17 00:00:00 2001 From: Johann Bernhardt Date: Sun, 7 Nov 2021 00:25:02 +0100 Subject: [PATCH] Added option and example for access transformers --- build.gradle | 2 ++ gradle.properties | 4 ++++ .../java/com/myname/mymodid/CommonProxy.java | 10 ++++++++++ src/main/resources/META-INF/mymodid_at.cfg | 17 +++++++++++++++++ 4 files changed, 33 insertions(+) create mode 100644 src/main/resources/META-INF/mymodid_at.cfg diff --git a/build.gradle b/build.gradle index 412b62d..573575a 100644 --- a/build.gradle +++ b/build.gradle @@ -154,6 +154,7 @@ shadowJar { from refMap manifest { attributes([ + "FMLAT" : accessTransformersFile.toString(), "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", "MixinConfigs" : mixinConfigJson, "FMLCorePluginContainsFMLMod": true, @@ -172,6 +173,7 @@ jar { from refMap manifest { attributes([ + "FMLAT" : accessTransformersFile.toString(), "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", "MixinConfigs" : mixinConfigJson, "FMLCorePluginContainsFMLMod": true, diff --git a/gradle.properties b/gradle.properties index 137898a..0cd6999 100644 --- a/gradle.properties +++ b/gradle.properties @@ -28,6 +28,10 @@ gradleTokenGroupName = GRADLETOKEN_GROUPNAME # Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api apiPackage = +# Specify the configuration file for Forge's access transformers here. I must be placed into /src/main/resources/META-INF/ +# Example value: mymodid_at.cfg +accessTransformersFile = mymodid_at.cfg + # Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled! usesMixins = true # Specify the location of your implementation of IMixinPlugin. Leave it empty otherwise. diff --git a/src/main/java/com/myname/mymodid/CommonProxy.java b/src/main/java/com/myname/mymodid/CommonProxy.java index 5c5ef7d..165825c 100644 --- a/src/main/java/com/myname/mymodid/CommonProxy.java +++ b/src/main/java/com/myname/mymodid/CommonProxy.java @@ -1,6 +1,9 @@ package com.myname.mymodid; import cpw.mods.fml.common.event.*; +import net.minecraft.block.material.Material; +import net.minecraft.client.gui.GuiScreenBook; +import net.minecraft.init.Blocks; public class CommonProxy { @@ -20,7 +23,14 @@ public class CommonProxy { // postInit "Handle interaction with other mods, complete your setup based on this." public void postInit(FMLPostInitializationEvent event) { + // Access originally package-private subclass + GuiScreenBook.NextPageButton button = null; + // Access originally private field + Material air = Blocks.air.blockMaterial; + + // Access originally protected method + Blocks.air.disableStats(); } public void serverAboutToStart(FMLServerAboutToStartEvent event) { diff --git a/src/main/resources/META-INF/mymodid_at.cfg b/src/main/resources/META-INF/mymodid_at.cfg new file mode 100644 index 0000000..1e7afd5 --- /dev/null +++ b/src/main/resources/META-INF/mymodid_at.cfg @@ -0,0 +1,17 @@ +# Override visibility of Vanilla Minecraft code only! It will not work on mods! + +# Warning: Whenever you change this file you must run 'setupDecompWorkspace' again and afterwards reimport the gradle project! + +# https://mcforge.readthedocs.io/en/latest/advanced/accesstransformers/ + +# Classes +# +public net.minecraft.client.gui.GuiScreenBook$NextPageButton + +# Fields +# +public net.minecraft.block.Block field_149764_J # blockMaterial + +# Methods +# () +public net.minecraft.block.Block func_149649_H()Lnet.minecraft.block.Block; # disableStats