diff --git a/build.gradle b/build.gradle index 41c3d008..505ad92b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -//version: 1669411416 +//version: 1674409054 /* DO NOT CHANGE THIS FILE! Also, you may replace this file at any time if there is an update available. @@ -31,7 +31,7 @@ buildscript { url 'https://maven.minecraftforge.net' } maven { - // GTNH ForgeGradle Fork + // GTNH ForgeGradle and ASM Fork name = "GTNH Maven" url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/" } @@ -45,7 +45,9 @@ buildscript { } } dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:1.2.11' + //Overwrite the current ASM version to fix shading newer than java 8 applicatations. + classpath 'org.ow2.asm:asm-debug-all-custom:5.0.3' + classpath 'net.minecraftforge.gradle:ForgeGradle:1.2.13' } } plugins { @@ -142,6 +144,7 @@ propertyDefaultIfUnset("modrinthProjectId", "") propertyDefaultIfUnset("modrinthRelations", "") propertyDefaultIfUnset("curseForgeProjectId", "") propertyDefaultIfUnset("curseForgeRelations", "") +propertyDefaultIfUnset("minimizeShadowedDependencies", true) String javaSourceDir = "src/main/java/" String scalaSourceDir = "src/main/scala/" @@ -234,9 +237,9 @@ try { } catch (Exception ignored) { out.style(Style.Failure).text( - 'This mod must be version controlled by Git AND the repository must provide at least one tag,\n' + - 'or the VERSION override must be set! ').style(Style.SuccessHeader).text('(Do NOT download from GitHub using the ZIP option, instead\n' + - 'clone the repository, see ').style(Style.Info).text('https://gtnh.miraheze.org/wiki/Development').style(Style.SuccessHeader).println(' for details.)' + 'This mod must be version controlled by Git AND the repository must provide at least one tag,\n' + + 'or the VERSION override must be set! ').style(Style.SuccessHeader).text('(Do NOT download from GitHub using the ZIP option, instead\n' + + 'clone the repository, see ').style(Style.Info).text('https://gtnh.miraheze.org/wiki/Development').style(Style.SuccessHeader).println(' for details.)' ) versionOverride = 'NO-GIT-TAG-SET' identifiedVersion = versionOverride @@ -262,13 +265,13 @@ def jvmArguments = [] if (usesMixins.toBoolean() || forceEnableMixins.toBoolean()) { arguments += [ - "--tweakClass org.spongepowered.asm.launch.MixinTweaker" + "--tweakClass org.spongepowered.asm.launch.MixinTweaker" ] if (usesMixinDebug.toBoolean()) { jvmArguments += [ - "-Dmixin.debug.countInjections=true", - "-Dmixin.debug.verbose=true", - "-Dmixin.debug.export=true" + "-Dmixin.debug.countInjections=true", + "-Dmixin.debug.verbose=true", + "-Dmixin.debug.export=true" ] } } @@ -278,7 +281,9 @@ minecraft { runDir = 'run' if (replaceGradleTokenInFile) { - replaceIn replaceGradleTokenInFile + for (f in replaceGradleTokenInFile.split(',')) { + replaceIn f + } if (gradleTokenModId) { replace gradleTokenModId, modId } @@ -315,9 +320,13 @@ if (file('addon.gradle').exists()) { apply from: 'repositories.gradle' configurations { - implementation.extendsFrom(shadowImplementation) // TODO: remove after all uses are refactored - implementation.extendsFrom(shadowCompile) - implementation.extendsFrom(shadeCompile) + // TODO: remove Compile after all uses are refactored to Implementation + for (config in [shadowImplementation, shadowCompile, shadeCompile]) { + compileClasspath.extendsFrom(config) + runtimeClasspath.extendsFrom(config) + testCompileClasspath.extendsFrom(config) + testRuntimeClasspath.extendsFrom(config) + } } repositories { @@ -330,6 +339,12 @@ repositories { name = "GTNH Maven" url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/" } + if (usesMixinDebug.toBoolean()) { + maven { + name = "Fabric Maven" + url = "https://maven.fabricmc.net/" + } + } } } @@ -338,10 +353,14 @@ dependencies { annotationProcessor('org.ow2.asm:asm-debug-all:5.0.3') annotationProcessor('com.google.guava:guava:24.1.1-jre') annotationProcessor('com.google.code.gson:gson:2.8.6') - annotationProcessor('com.gtnewhorizon:gtnhmixins:2.1.1:processor') + annotationProcessor('com.gtnewhorizon:gtnhmixins:2.1.3:processor') + if (usesMixinDebug.toBoolean()) { + runtimeClasspath('org.jetbrains:intellij-fernflower:1.2.1.16') + testRuntimeClasspath('org.jetbrains:intellij-fernflower:1.2.1.16') + } } if (usesMixins.toBoolean() || forceEnableMixins.toBoolean()) { - compile('com.gtnewhorizon:gtnhmixins:2.1.1') + compile('com.gtnewhorizon:gtnhmixins:2.1.3') } } @@ -393,10 +412,12 @@ shadowJar { attributes(getManifestAttributes()) } - minimize() // This will only allow shading for actually used classes + if (minimizeShadowedDependencies.toBoolean()) { + minimize() // This will only allow shading for actually used classes + } configurations = [ - project.configurations.shadowImplementation, - project.configurations.shadowCompile + project.configurations.shadowImplementation, + project.configurations.shadowCompile ] dependsOn(relocateShadowJar) } @@ -428,12 +449,12 @@ afterEvaluate { if (usesMixins.toBoolean()) { tasks.compileJava { options.compilerArgs += [ - "-AreobfSrgFile=${tasks.reobf.srg}", - "-AoutSrgFile=${mixinSrg}", - "-AoutRefMapFile=${refMap}", - // Elan: from what I understand they are just some linter configs so you get some warning on how to properly code - "-XDenableSunApiLintControl", - "-XDignore.symbol.file" + "-AreobfSrgFile=${tasks.reobf.srg}", + "-AoutSrgFile=${mixinSrg}", + "-AoutRefMapFile=${refMap}", + // Elan: from what I understand they are just some linter configs so you get some warning on how to properly code + "-XDenableSunApiLintControl", + "-XDignore.symbol.file" ] } } @@ -442,8 +463,8 @@ afterEvaluate { runClient { if (developmentEnvironmentUserName) { arguments += [ - "--username", - developmentEnvironmentUserName + "--username", + developmentEnvironmentUserName ] } @@ -458,9 +479,9 @@ runServer { tasks.withType(JavaExec).configureEach { javaLauncher.set( - javaToolchains.launcherFor { - languageVersion = projectJavaVersion - } + javaToolchains.launcherFor { + languageVersion = projectJavaVersion + } ) } @@ -476,9 +497,9 @@ processResources { // replace modVersion and minecraftVersion expand "minecraftVersion": project.minecraft.version, - "modVersion": modVersion, - "modId": modId, - "modName": modName + "modVersion": modVersion, + "modId": modId, + "modName": modName } if (usesMixins.toBoolean()) { @@ -508,9 +529,9 @@ def getManifestAttributes() { if (usesMixins.toBoolean()) { manifestAttributes += [ - "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", - "MixinConfigs" : "mixins." + modId + ".json", - "ForceLoadAsMod": !containsMixinsAndOrCoreModOnly.toBoolean() + "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", + "MixinConfigs" : "mixins." + modId + ".json", + "ForceLoadAsMod": !containsMixinsAndOrCoreModOnly.toBoolean() ] } return manifestAttributes @@ -536,10 +557,12 @@ task shadowDevJar(type: ShadowJar) { attributes(getManifestAttributes()) } - minimize() // This will only allow shading for actually used classes + if (minimizeShadowedDependencies.toBoolean()) { + minimize() // This will only allow shading for actually used classes + } configurations = [ - project.configurations.shadowImplementation, - project.configurations.shadowCompile + project.configurations.shadowImplementation, + project.configurations.shadowCompile ] } @@ -633,8 +656,8 @@ publishing { pom.withXml { def badArtifacts = [:].withDefault { [] as Set } for (configuration in [ - projectConfigs.minecraft, - projectConfigs.minecraftDeps + projectConfigs.minecraft, + projectConfigs.minecraftDeps ]) { for (dependency in configuration.allDependencies) { badArtifacts[dependency.group == null ? "" : dependency.group] += dependency.name @@ -694,7 +717,7 @@ if (modrinthProjectId.size() != 0 && System.getenv("MODRINTH_TOKEN") != null) { } } if (usesMixins.toBoolean()) { - addModrinthDep("required", "version", "gtnhmixins") + addModrinthDep("required", "project", "gtnhmixins") } tasks.modrinth.dependsOn(build) tasks.publish.dependsOn(tasks.modrinth) @@ -1100,4 +1123,4 @@ def getSecondaryArtifacts() { if (!noPublishedSources) secondaryArtifacts += [sourcesJar] if (apiPackage) secondaryArtifacts += [apiJar] return secondaryArtifacts -} \ No newline at end of file +} diff --git a/dependencies.gradle b/dependencies.gradle index 41a88adf..f9dc5f45 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -1,11 +1,12 @@ // Add your dependencies here dependencies { - compile('com.github.GTNewHorizons:ForestryMC:4.4.6:dev') - compile('com.github.GTNewHorizons:NotEnoughItems:2.2.17-GTNH:dev') + implementation('com.github.GTNewHorizons:GTNHLib:0.0.10:dev') + compile('com.github.GTNewHorizons:ForestryMC:4.5.6:dev') + compile('com.github.GTNewHorizons:NotEnoughItems:2.3.21-GTNH:dev') - compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.27:api') + compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.28:api') compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev') compileOnly('curse.maven:cofh-lib-220333:2388748') -} \ No newline at end of file +} diff --git a/src/main/java/binnie/core/BinnieCore.java b/src/main/java/binnie/core/BinnieCore.java index 464a4c1b..4aaece36 100644 --- a/src/main/java/binnie/core/BinnieCore.java +++ b/src/main/java/binnie/core/BinnieCore.java @@ -51,7 +51,7 @@ import net.minecraftforge.client.event.TextureStitchEvent; name = "Binnie Core", version = BinnieCore.VERSION, useMetadata = true, - dependencies = "after:Forestry@[4.2,)") + dependencies = "after:Forestry@[4.2,),required-after:gtnhlib@[0.0.10,)") public class BinnieCore extends AbstractMod { @Mod.Instance("BinnieCore") public static BinnieCore instance; diff --git a/src/main/java/binnie/core/nei/RecipeHandlerBase.java b/src/main/java/binnie/core/nei/RecipeHandlerBase.java index ffd3a35d..d2d9e3bb 100644 --- a/src/main/java/binnie/core/nei/RecipeHandlerBase.java +++ b/src/main/java/binnie/core/nei/RecipeHandlerBase.java @@ -80,7 +80,7 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler { public void loadUsageRecipes(FluidStack ingredient) {} @Override - public List handleTooltip(GuiRecipe guiRecipe, List currenttip, int recipe) { + public List handleTooltip(GuiRecipe guiRecipe, List currenttip, int recipe) { super.handleTooltip(guiRecipe, currenttip, recipe); CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe); if (GuiContainerManager.shouldShowTooltip(guiRecipe)) { @@ -98,7 +98,7 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler { } public List provideTooltip( - GuiRecipe guiRecipe, List currenttip, CachedBaseRecipe crecipe, Point relMouse) { + GuiRecipe guiRecipe, List currenttip, CachedBaseRecipe crecipe, Point relMouse) { if (crecipe.getFluidTanks() != null) { for (PositionedFluidTank tank : crecipe.getFluidTanks()) { if (tank.position.contains(relMouse)) { @@ -111,7 +111,7 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler { @Override public List handleItemTooltip( - GuiRecipe guiRecipe, ItemStack itemStack, List currenttip, int recipe) { + GuiRecipe guiRecipe, ItemStack itemStack, List currenttip, int recipe) { super.handleItemTooltip(guiRecipe, itemStack, currenttip, recipe); CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe); Point mouse = GuiDraw.getMousePosition(); @@ -125,7 +125,7 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler { } public List provideItemTooltip( - GuiRecipe guiRecipe, + GuiRecipe guiRecipe, ItemStack itemStack, List currenttip, CachedBaseRecipe crecipe, @@ -151,7 +151,7 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler { } @Override - public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) { + public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) { if (keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) { if (this.transferFluidTank(gui, recipe, false)) { return true; @@ -165,7 +165,7 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler { } @Override - public boolean mouseClicked(GuiRecipe gui, int button, int recipe) { + public boolean mouseClicked(GuiRecipe gui, int button, int recipe) { if (button == 0) { if (this.transferFluidTank(gui, recipe, false)) { return true; @@ -178,7 +178,7 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler { return super.mouseClicked(gui, button, recipe); } - protected boolean transferFluidTank(GuiRecipe guiRecipe, int recipe, boolean usage) { + protected boolean transferFluidTank(GuiRecipe guiRecipe, int recipe, boolean usage) { CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe); if (crecipe.getFluidTanks() != null) { diff --git a/src/main/java/binnie/extratrees/FakeWorld.java b/src/main/java/binnie/extratrees/FakeWorld.java index b35eaf65..177261fd 100644 --- a/src/main/java/binnie/extratrees/FakeWorld.java +++ b/src/main/java/binnie/extratrees/FakeWorld.java @@ -3,7 +3,7 @@ package binnie.extratrees; import binnie.core.block.TileEntityMetadata; import forestry.api.arboriculture.EnumWoodType; import forestry.arboriculture.tiles.TileWood; -import java.lang.reflect.Constructor; +import java.lang.reflect.Field; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; @@ -14,9 +14,21 @@ import net.minecraft.world.WorldSettings; import net.minecraft.world.WorldSettings.GameType; import net.minecraft.world.WorldType; import net.minecraft.world.chunk.IChunkProvider; -import sun.reflect.ReflectionFactory; +import sun.misc.Unsafe; public class FakeWorld extends World { + private static Unsafe unsafe; + + static { + try { + Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe"); + theUnsafe.setAccessible(true); + unsafe = (Unsafe) theUnsafe.get(null); + } catch (ReflectiveOperationException e) { + throw new RuntimeException(e); + } + } + public static FakeWorld instance = SilentObjectCreator.create(FakeWorld.class); protected Block block; @@ -106,22 +118,10 @@ public class FakeWorld extends World { * Creating objects without calling constructors. */ public static T create(Class clazz) { - return create(clazz, Object.class); - } - - /** - * Creating objects without calling constructors. - */ - public static T create(Class clazz, Class parent) { try { - ReflectionFactory rf = ReflectionFactory.getReflectionFactory(); - Constructor objDef = parent.getDeclaredConstructor(); - Constructor intConstr = rf.newConstructorForSerialization(clazz, objDef); - return clazz.cast(intConstr.newInstance()); - } catch (RuntimeException e) { - throw e; - } catch (Exception e) { - throw new IllegalStateException("Cannot create object", e); + return clazz.cast(unsafe.allocateInstance(clazz)); + } catch (InstantiationException e) { + throw new IllegalStateException(e); } } } diff --git a/src/main/java/binnie/extratrees/genetics/ExtraTreeFruitGene.java b/src/main/java/binnie/extratrees/genetics/ExtraTreeFruitGene.java index a134ceff..e4270164 100644 --- a/src/main/java/binnie/extratrees/genetics/ExtraTreeFruitGene.java +++ b/src/main/java/binnie/extratrees/genetics/ExtraTreeFruitGene.java @@ -6,6 +6,7 @@ import binnie.extratrees.ExtraTrees; import binnie.extratrees.block.FruitPod; import binnie.extratrees.config.ConfigurationMain; import binnie.extratrees.item.Food; +import com.gtnewhorizon.gtnhlib.reflect.Fields; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import forestry.api.arboriculture.EnumTreeChromosome; @@ -18,7 +19,6 @@ import forestry.api.genetics.IAlleleSpecies; import forestry.api.genetics.IFruitFamily; import forestry.arboriculture.FruitProviderNone; import forestry.arboriculture.genetics.alleles.AlleleTreeSpecies; -import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -254,12 +254,9 @@ public enum ExtraTreeFruitGene implements IAlleleFruit, IFruitProvider { try { IAlleleFruit lemon = (IAlleleFruit) AlleleManager.alleleRegistry.getAllele("forestry.fruitLemon"); FruitProviderNone prov = (FruitProviderNone) lemon.getProvider(); - Field f = FruitProviderNone.class.getDeclaredField("family"); - Field modifiersField = Field.class.getDeclaredField("modifiers"); - f.setAccessible(true); - modifiersField.setAccessible(true); - modifiersField.setInt(f, f.getModifiers() & 0xFFFFFFEF); - f.set(prov, familyCitrus); + Fields.ofClass(FruitProviderNone.class) + .getField(Fields.LookupType.DECLARED, "family", IFruitFamily.class) + .setValue(prov, familyCitrus); } catch (Exception e) { e.printStackTrace(); } diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index a8fb16bb..070bb7b2 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -11,8 +11,8 @@ "credits": "Thanks to Sengir, MysteriousAges, Xizzzy and many others", "logoFile": "/assets/binniecore/logo.png", "parent": "", - "requiredMods": [ "Forestry" ], - "dependencies": [ "Forestry" ], + "requiredMods": [ "Forestry", "gtnhlib@[0.0.10,)" ], + "dependencies": [ "Forestry", "gtnhlib@[0.0.10,)" ], "dependants" : [ ], "useDependencyInformation" : true }, @@ -27,7 +27,7 @@ "authorList": [ "Binnie" ], "credits": "Thanks to Sengir, MysteriousAges, Xizzzy and many others", "logoFile": "/assets/extrabees/logo.png", - "parent": "", + "parent": "${modId}", "dependencies": [ "BinnieCore" ] }, { @@ -41,7 +41,7 @@ "authorList": [ "Binnie" ], "credits": "Thanks to Sengir, MysteriousAges, Xizzzy and many others", "logoFile": "/assets/extratrees/logo.png", - "parent": "", + "parent": "${modId}", "dependencies": [ "BinnieCore" ] }, { @@ -55,7 +55,7 @@ "authorList": [ "Binnie" ], "credits": "Thanks to Sengir, MysteriousAges, Xizzzy and many others", "logoFile": "/assets/botany/logo.png", - "parent": "", + "parent": "${modId}", "dependencies": [ "BinnieCore" ] }, { @@ -69,7 +69,7 @@ "authorList": [ "Binnie" ], "credits": "Thanks to Sengir, MysteriousAges, Xizzzy and many others", "logoFile": "/assets/genetics/logo.png", - "parent": "", + "parent": "${modId}", "dependencies": [ "BinnieCore" ] } ]