diff --git a/build.gradle b/build.gradle index 412b62d..3493d78 100644 --- a/build.gradle +++ b/build.gradle @@ -150,17 +150,26 @@ task generateAssets { } shadowJar { + def manifestAttributes = [:] + manifestAttributes += ["FMLCorePluginContainsFMLMod" : true] + + if(accessTransformersFile.isEmpty() == false) { + manifestAttributes += ["FMLAT" : accessTransformersFile.toString()] + } + if(usesMixins.toBoolean()) { from refMap manifest { - attributes([ - "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", - "MixinConfigs" : mixinConfigJson, - "FMLCorePluginContainsFMLMod": true, - "ForceLoadAsMod" : loadNormalModAfterApplingMixins.toBoolean() - ]) + manifestAttributes += [ + "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", + "MixinConfigs" : mixinConfigJson, + "ForceLoadAsMod" : loadNormalModAfterApplingMixins.toBoolean() + ] } } + manifest { + attributes(manifestAttributes) + } minimize() configurations = [project.configurations.shadowImplementation] @@ -168,17 +177,26 @@ shadowJar { } jar { + def manifestAttributes = [:] + manifestAttributes += ["FMLCorePluginContainsFMLMod" : true] + + if(accessTransformersFile.isEmpty() == false) { + manifestAttributes += ["FMLAT" : accessTransformersFile.toString()] + } + if(usesMixins.toBoolean()) { from refMap manifest { - attributes([ - "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", - "MixinConfigs" : mixinConfigJson, - "FMLCorePluginContainsFMLMod": true, - "ForceLoadAsMod" : loadNormalModAfterApplingMixins.toBoolean() - ]) + manifestAttributes += [ + "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", + "MixinConfigs" : mixinConfigJson, + "ForceLoadAsMod" : loadNormalModAfterApplingMixins.toBoolean() + ] } } + manifest { + attributes(manifestAttributes) + } if(usesShadowedDependencies.toBoolean()) { dependsOn(shadowJar) 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