diff options
author | Martin Robertz <dream-master@gmx.net> | 2023-02-16 19:53:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-16 19:53:30 +0100 |
commit | ca2921bb10732d32f52e2782f06b1bf1d0e3215d (patch) | |
tree | 0f7b01ba39e9796ff584a6ec837a13eaecd4bc39 | |
parent | 34ac0d137b8b72ade9962e0eb4a9068cb94ec115 (diff) | |
parent | d4971ee872e4186da6361c9afd86133304b7ae8d (diff) | |
download | GT5-Unofficial-ca2921bb10732d32f52e2782f06b1bf1d0e3215d.tar.gz GT5-Unofficial-ca2921bb10732d32f52e2782f06b1bf1d0e3215d.tar.bz2 GT5-Unofficial-ca2921bb10732d32f52e2782f06b1bf1d0e3215d.zip |
Merge pull request #157 from GTNewHorizons/fix/eoh-recipe-generator
Fix EOH recipes not being generated in some dimensions
5 files changed, 210 insertions, 124 deletions
diff --git a/build.gradle b/build.gradle index 5ff6d7186a..b808930520 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -//version: 1675268365 +//version: 1676031737 /* DO NOT CHANGE THIS FILE! Also, you may replace this file at any time if there is an update available. @@ -9,11 +9,15 @@ import com.diffplug.blowdryer.Blowdryer import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import com.gtnewhorizons.retrofuturagradle.ObfuscationAttribute import com.gtnewhorizons.retrofuturagradle.mcp.ReobfuscatedJar +import com.gtnewhorizons.retrofuturagradle.minecraft.RunMinecraftTask import com.matthewprenger.cursegradle.CurseArtifact import com.matthewprenger.cursegradle.CurseRelation import com.modrinth.minotaur.dependencies.ModDependency import com.modrinth.minotaur.dependencies.VersionDependency +import cpw.mods.fml.relauncher.Side +import org.gradle.api.tasks.options.Option; import org.gradle.internal.logging.text.StyledTextOutput.Style import org.gradle.internal.logging.text.StyledTextOutputFactory import org.jetbrains.gradle.ext.* @@ -23,6 +27,7 @@ import java.nio.file.Paths import java.util.concurrent.TimeUnit import java.util.zip.ZipEntry import java.util.zip.ZipOutputStream +import javax.inject.Inject buildscript { repositories { @@ -66,7 +71,7 @@ plugins { id 'com.diffplug.spotless' version '6.7.2' apply false id 'com.modrinth.minotaur' version '2.+' apply false id 'com.matthewprenger.cursegradle' version '1.4.0' apply false - id 'com.gtnewhorizons.retrofuturagradle' version '1.1.4' + id 'com.gtnewhorizons.retrofuturagradle' version '1.1.6' } boolean settingsupdated = verifySettingsGradle() settingsupdated = verifyGitAttributes() || settingsupdated @@ -186,11 +191,21 @@ configurations { } if (enableModernJavaSyntax.toBoolean()) { + repositories { + mavenCentral { + mavenContent { + includeGroup("me.eigenraven.java8unsupported") + } + } + } + dependencies { annotationProcessor 'com.github.bsideup.jabel:jabel-javac-plugin:1.0.0' compileOnly('com.github.bsideup.jabel:jabel-javac-plugin:1.0.0') { transitive = false // We only care about the 1 annotation class } + // Allow using jdk.unsupported classes like sun.misc.Unsafe in the compiled code, working around JDK-8206937. + patchedMinecraft('me.eigenraven.java8unsupported:java-8-unsupported-shim:1.0.0') } tasks.withType(JavaCompile).configureEach { @@ -401,6 +416,16 @@ configurations.configureEach { } } } + def obfuscationAttr = it.attributes.getAttribute(ObfuscationAttribute.OBFUSCATION_ATTRIBUTE) + if (obfuscationAttr != null && obfuscationAttr.name == ObfuscationAttribute.SRG) { + resolutionStrategy.eachDependency { DependencyResolveDetails details -> + // Remap CoFH core cursemaven dev jar to the obfuscated version for runObfClient/Server + if (details.requested.group == 'curse.maven' && details.requested.name.endsWith('-69162') && details.requested.version == '2388751') { + details.useVersion '2388750' + details.because 'Pick obfuscated jar' + } + } + } } // Ensure tests have access to minecraft classes @@ -637,6 +662,138 @@ tasks.named("processResources", ProcessResources).configure { } } +ext.java17Toolchain = (JavaToolchainSpec spec) -> { + spec.languageVersion.set(JavaLanguageVersion.of(17)) + spec.vendor.set(JvmVendorSpec.matching("jetbrains")) +} + +ext.java17DependenciesCfg = configurations.create("java17Dependencies") +ext.java17PatchDependenciesCfg = configurations.create("java17PatchDependencies") + +dependencies { + def lwjgl3ifyVersion = '1.1.21' + def asmVersion = '9.4' + if (modId != 'lwjgl3ify') { + java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}") + } + if (modId != 'hodgepodge') { + java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.0.31') + } + + java17PatchDependencies('net.minecraft:launchwrapper:1.15') {transitive = false} + java17PatchDependencies("org.ow2.asm:asm:${asmVersion}") + java17PatchDependencies("org.ow2.asm:asm-commons:${asmVersion}") + java17PatchDependencies("org.ow2.asm:asm-tree:${asmVersion}") + java17PatchDependencies("org.ow2.asm:asm-analysis:${asmVersion}") + java17PatchDependencies("org.ow2.asm:asm-util:${asmVersion}") + java17PatchDependencies('org.ow2.asm:asm-deprecated:7.1') + java17PatchDependencies("org.apache.commons:commons-lang3:3.12.0") + java17PatchDependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}:forgePatches") +} + +ext.java17JvmArgs = [ + // Java 9+ support + "--illegal-access=warn", + "-Dfile.encoding=UTF-8", + "-Djava.security.manager=allow", + "--add-opens", "java.base/jdk.internal.loader=ALL-UNNAMED", + "--add-opens", "java.base/java.net=ALL-UNNAMED", + "--add-opens", "java.base/java.nio=ALL-UNNAMED", + "--add-opens", "java.base/java.io=ALL-UNNAMED", + "--add-opens", "java.base/java.lang=ALL-UNNAMED", + "--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED", + "--add-opens", "java.base/java.text=ALL-UNNAMED", + "--add-opens", "java.base/java.util=ALL-UNNAMED", + "--add-opens", "java.base/jdk.internal.reflect=ALL-UNNAMED", + "--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED", + "--add-opens", "java.desktop/sun.awt.image=ALL-UNNAMED", + "--add-modules", "jdk.dynalink", + "--add-opens", "jdk.dynalink/jdk.dynalink.beans=ALL-UNNAMED", + "--add-modules", "java.sql.rowset", + "--add-opens", "java.sql.rowset/javax.sql.rowset.serial=ALL-UNNAMED" +] + +ext.hotswapJvmArgs = [ + // DCEVM advanced hot reload + "-XX:+AllowEnhancedClassRedefinition", + "-XX:HotswapAgent=fatjar" +] + +ext.setupHotswapAgentTask = tasks.register("setupHotswapAgent") { + group = "GTNH Buildscript" + description = "Installs a recent version of HotSwapAgent into the Java 17 JetBrains runtime directory" + def hsaUrl = 'https://github.com/HotswapProjects/HotswapAgent/releases/download/1.4.2-SNAPSHOT/hotswap-agent-1.4.2-SNAPSHOT.jar' + def targetFolderProvider = javaToolchains.launcherFor(java17Toolchain).map {it.metadata.installationPath.dir("lib/hotswap")} + def targetFilename = "hotswap-agent.jar" + onlyIf { + !targetFolderProvider.get().file(targetFilename).asFile.exists() + } + doLast { + def targetFolder = targetFolderProvider.get() + targetFolder.asFile.mkdirs() + download.run { + src hsaUrl + dest targetFolder.file(targetFilename).asFile + overwrite false + tempAndMove true + } + } +} + +public abstract class RunHotswappableMinecraftTask extends RunMinecraftTask { + // IntelliJ doesn't seem to allow commandline arguments so we also support an env variable + private boolean enableHotswap = Boolean.valueOf(System.getenv("HOTSWAP")); + + @Input + public boolean getEnableHotswap() { return enableHotswap } + @Option(option = "hotswap", description = "Enables HotSwapAgent for enhanced class reloading under a debugger") + public boolean setEnableHotswap(boolean enable) { enableHotswap = enable } + + @Inject + public RunHotswappableMinecraftTask(Side side, String superTask) { + super(side) + + this.lwjglVersion = 3 + this.javaLauncher = project.javaToolchains.launcherFor(project.java17Toolchain) + this.extraJvmArgs.addAll(project.java17JvmArgs) + this.extraJvmArgs.addAll(project.provider(() -> enableHotswap ? project.hotswapJvmArgs : [])) + + this.classpath(project.java17PatchDependenciesCfg) + if (side == Side.CLIENT) { + this.classpath(project.minecraftTasks.lwjgl3Configuration) + } + // Use a raw provider instead of map to not create a dependency on the task + this.classpath(project.provider(() -> project.tasks.named(superTask, RunMinecraftTask).get().classpath)) + this.classpath.filter { file -> + !file.path.contains("2.9.4-nightly-20150209") // Remove lwjgl2 + } + this.classpath(project.java17DependenciesCfg) + + if (!(project.usesMixins.toBoolean() || project.forceEnableMixins.toBoolean())) { + this.extraArgs.addAll("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker") + } + } +} + +def runClient17Task = tasks.register("runClient17", RunHotswappableMinecraftTask, Side.CLIENT, "runClient") +runClient17Task.configure { + setup(project) + group = "Modded Minecraft" + description = "Runs the modded client using Java 17, lwjgl3ify and Hodgepodge" + dependsOn(setupHotswapAgentTask, mcpTasks.launcherSources.classesTaskName, minecraftTasks.taskDownloadVanillaAssets, mcpTasks.taskPackagePatchedMc, 'jar') + mainClass = "GradleStart" +} + +def runServer17Task = tasks.register("runServer17", RunHotswappableMinecraftTask, Side.SERVER, "runServer") +runServer17Task.configure { + setup(project) + group = "Modded Minecraft" + description = "Runs the modded server using Java 17, lwjgl3ify and Hodgepodge" + dependsOn(setupHotswapAgentTask, mcpTasks.launcherSources.classesTaskName, minecraftTasks.taskDownloadVanillaAssets, mcpTasks.taskPackagePatchedMc, 'jar') + mainClass = "GradleStartServer" + extraArgs.add("nogui") +} + def getManifestAttributes() { def manifestAttributes = [:] if (!containsMixinsAndOrCoreModOnly.toBoolean() && (usesMixins.toBoolean() || coreModClass)) { @@ -706,7 +863,7 @@ if (usesShadowedDependencies.toBoolean()) { javaComponent.withVariantsFromConfiguration(configurations.shadowRuntimeElements) { skip() } - for (runTask in ["runClient", "runServer"]) { + for (runTask in ["runClient", "runServer", "runClient17", "runServer17"]) { tasks.named(runTask).configure { dependsOn("shadowJar") } @@ -755,6 +912,20 @@ idea { "2. Run Server"(Gradle) { taskNames = ["runServer"] } + "1a. Run Client (Java 17)"(Gradle) { + taskNames = ["runClient17"] + } + "2a. Run Server (Java 17)"(Gradle) { + taskNames = ["runServer17"] + } + "1b. Run Client (Java 17, Hotswap)"(Gradle) { + taskNames = ["runClient17"] + envs = ["HOTSWAP": "true"] + } + "2b. Run Server (Java 17, Hotswap)"(Gradle) { + taskNames = ["runServer17"] + envs = ["HOTSWAP": "true"] + } "3. Run Obfuscated Client"(Gradle) { taskNames = ["runObfClient"] } diff --git a/dependencies.gradle b/dependencies.gradle index 118d614277..657e29fe44 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -2,27 +2,17 @@ dependencies { shadowImplementation('com.github.GTNewHorizons:AVRcore:1.0.1') - compile("com.github.GTNewHorizons:GT5-Unofficial:5.09.41.275:dev") - compile('com.github.GTNewHorizons:ModularUI:1.0.61:dev') - compile('com.github.GTNewHorizons:Yamcl:0.5.84:dev') - compile('com.github.GTNewHorizons:NotEnoughItems:2.3.29-GTNH:dev') - compile('com.github.GTNewHorizons:CodeChickenLib:1.1.8:dev') - compile('com.github.GTNewHorizons:CodeChickenCore:1.1.11:dev') - compile('com.github.GTNewHorizons:StructureLib:1.2.2:dev') - compile('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev') - compile('com.github.GTNewHorizons:GTNEIOrePlugin:1.0.26:dev') + api("com.github.GTNewHorizons:GT5-Unofficial:5.09.41.275:dev") + api('com.github.GTNewHorizons:Yamcl:0.5.84:dev') + implementation('com.github.GTNewHorizons:GTNEIOrePlugin:1.0.27:dev') - compileOnly("com.github.GTNewHorizons:TinkersGregworks:master-SNAPSHOT:dev") { - transitive = false - } + compileOnly("com.github.GTNewHorizons:TinkersGregworks:master-SNAPSHOT:dev") {transitive = false} compileOnly('com.github.GTNewHorizons:OpenModularTurrets:2.2.11-247:dev') {transitive=false} compileOnly('com.github.GTNewHorizons:OpenComputers:1.8.0.9-GTNH:dev') {transitive=false} compileOnly('com.github.GTNewHorizons:GTplusplus:1.7.213:dev') {transitive=false} - compileOnly('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-156-GTNH:dev') {transitive=false} compileOnly('curse.maven:cofh-lib-220333:2388748') {transitive=false} compileOnly('curse.maven:computercraft-67504:2269339') {transitive=false} compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev') {transitive=false} - } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/recipes/EMRecipeMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/recipes/EMRecipeMap.java deleted file mode 100644 index 2aad1b9e40..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/recipes/EMRecipeMap.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.github.technus.tectech.mechanics.elementalMatter.core.recipes; - -import java.util.HashMap; -import java.util.Map; - -import com.github.technus.tectech.mechanics.elementalMatter.core.maps.EMConstantStackMap; -import com.github.technus.tectech.mechanics.elementalMatter.core.maps.IEMMapRead; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.EMDefinitionStack; -import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.IEMStack; - -/** - * Created by Tec on 02.03.2017. - */ -public class EMRecipeMap<T> { // TODO FIX - // Multimap for multiple recipes from the same thing - you know parameters might differ the output - - private final Map<EMConstantStackMap, Map<Integer, EMRecipe<T>>> recipes; - - public EMRecipeMap() { - recipes = new HashMap<>(); - } - - public EMRecipe<T> put(EMRecipe<T> in) { - Map<Integer, EMRecipe<T>> r = getRecipes().computeIfAbsent(in.getInEM(), k -> new HashMap<>()); - return r.put(in.getID(), in); // IF THIS RETURN SHIT, it means that inputs are using the exact same types of - // matter as input - - // (non amount wise collision) - // It is either bad, or unimportant if you use different id's - } - - public void putAll(EMRecipe<T>... contents) { - for (EMRecipe<T> recipe : contents) { - put(recipe); - } - } - - public EMRecipe<T> remove(IEMMapRead<EMDefinitionStack> map, int id) { - Map<Integer, EMRecipe<T>> recipesMap = getRecipes().get(map); - return recipesMap != null ? recipesMap.remove(id) : null; // todo check, suspicious but ok, equals and hashcode - // methods are adjusted for that - } - - public Map<Integer, EMRecipe<T>> remove(IEMMapRead<EMDefinitionStack> map) { - return getRecipes().remove(map); // todo check, suspicious but ok, equals and hashcode methods are adjusted for - // that - } - - // Recipe founding should not check amounts - this checks if the types of matter in map are equal to any recipe! - // Return a recipeShortMap when the content of input is equal (ignoring amounts and instance data) - @Deprecated - public Map<Integer, EMRecipe<T>> findExact(IEMMapRead<? extends IEMStack> in) { - return getRecipes().get(in); // suspicious but ok, equals and hashcode methods are adjusted for that - } - - // this does check if the map contains all the requirements for any recipe, and the required amounts - // Return a recipeShortMap when the content of input matches the recipe input - does not ignore amounts but ignores - // instance data! - public Map<Integer, EMRecipe<T>> findMatch(IEMMapRead<? extends IEMStack> in) { - for (Map.Entry<EMConstantStackMap, Map<Integer, EMRecipe<T>>> cElementalDefinitionStackMapHashMapEntry : getRecipes() - .entrySet()) { - if (in.containsAllAmounts(cElementalDefinitionStackMapHashMapEntry.getKey())) { - return cElementalDefinitionStackMapHashMapEntry.getValue(); - } - } - return null; - } - - public Map<EMConstantStackMap, Map<Integer, EMRecipe<T>>> getRecipes() { - return recipes; - } - - // To check for instance data and other things use recipe extensions! -} diff --git a/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java index 99f25832eb..98f24260eb 100644 --- a/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java +++ b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipe.java @@ -270,6 +270,7 @@ public class EyeOfHarmonyRecipe { public static void processHelper(HashMapHelper outputMap, Materials material, double mainMultiplier, double probability) { + if (material == null) return; outputMap.add(material.mDirectSmelting, (material.mOreMultiplier * 2) * mainMultiplier * probability); int index = 0; @@ -287,21 +288,25 @@ public class EyeOfHarmonyRecipe { double mainMultiplier = timeInSeconds * 384.0; - normalOreDimWrapper.oreVeinToProbabilityInDimension.forEach((veinInfo, probability) -> { - processHelper(outputMap, veinInfo.mPrimaryVeinMaterial, mainMultiplier, probability); - processHelper(outputMap, veinInfo.mSecondaryMaterial, mainMultiplier, probability); - // 8.0 to replicate void miner getDropsVanillaVeins method yields. - processHelper(outputMap, veinInfo.mBetweenMaterial, mainMultiplier / 8.0, probability); - processHelper(outputMap, veinInfo.mSporadicMaterial, mainMultiplier / 8.0, probability); - }); + if (normalOreDimWrapper != null) { + normalOreDimWrapper.oreVeinToProbabilityInDimension.forEach((veinInfo, probability) -> { + processHelper(outputMap, veinInfo.mPrimaryVeinMaterial, mainMultiplier, probability); + processHelper(outputMap, veinInfo.mSecondaryMaterial, mainMultiplier, probability); + // 8.0 to replicate void miner getDropsVanillaVeins method yields. + processHelper(outputMap, veinInfo.mBetweenMaterial, mainMultiplier / 8.0, probability); + processHelper(outputMap, veinInfo.mSporadicMaterial, mainMultiplier / 8.0, probability); + }); + } // Iterate over small ores in dimension and add them, kinda hacky but works and is close enough. - smallOreDimWrapper.oreVeinToProbabilityInDimension.forEach( - (veinInfo, probability) -> processHelper( - outputMap, - veinInfo.getOreMaterial(), - mainMultiplier, - probability)); + if (smallOreDimWrapper != null) { + smallOreDimWrapper.oreVeinToProbabilityInDimension.forEach( + (veinInfo, probability) -> processHelper( + outputMap, + veinInfo.getOreMaterial(), + mainMultiplier, + probability)); + } ArrayList<Pair<Materials, Long>> outputList = new ArrayList<>(); diff --git a/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipeStorage.java b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipeStorage.java index cd5d20aed6..78e97f4c46 100644 --- a/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipeStorage.java +++ b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipeStorage.java @@ -51,30 +51,23 @@ public class EyeOfHarmonyRecipeStorage { .getOrDefault(dimAbbreviation, null); GT5OreSmallHelper.SmallOreDimensionWrapper smallOre = GT5OreSmallHelper.dimToSmallOreWrapper .getOrDefault(dimAbbreviation, null); - - if ((normalOre == null) || (smallOre == null)) { - System.out.println( - dimAbbreviation - + " dimension not found in dimToOreWrapper. Report error to GTNH team."); + if (normalOre == null && smallOre == null) { + // no ores are generated in this dimension. fail silently continue; } - try { - put( - dimAbbreviation, - new EyeOfHarmonyRecipe( - normalOre, - smallOre, - blockDimensionDisplay, - 0.6 + blockDimensionDisplay.getDimensionRocketTier() / 10.0, - BILLION * (blockDimensionDisplay.getDimensionRocketTier() + 1), - BILLION * (blockDimensionDisplay.getDimensionRocketTier() + 1), - timeCalculator(blockDimensionDisplay.getDimensionRocketTier()), - blockDimensionDisplay.getDimensionRocketTier(), - 1.0 - 0.05 * blockDimensionDisplay.getDimensionRocketTier())); - } catch (Exception e) { - e.printStackTrace(); - } + put( + dimAbbreviation, + new EyeOfHarmonyRecipe( + normalOre, + smallOre, + blockDimensionDisplay, + 0.6 + blockDimensionDisplay.getDimensionRocketTier() / 10.0, + BILLION * (blockDimensionDisplay.getDimensionRocketTier() + 1), + BILLION * (blockDimensionDisplay.getDimensionRocketTier() + 1), + timeCalculator(blockDimensionDisplay.getDimensionRocketTier()), + blockDimensionDisplay.getDimensionRocketTier(), + 1.0 - 0.05 * blockDimensionDisplay.getDimensionRocketTier())); } } } |