From a45590d04343f313f1c137c4834a02f20d5cad5d Mon Sep 17 00:00:00 2001 From: miozune Date: Mon, 27 Nov 2023 22:18:33 +0900 Subject: [PATCH] Migrate to new RecipeMap --- .gitignore | 13 ++++++-- build.gradle | 13 ++++---- dependencies.gradle | 4 +-- .../gttweaker/mods/gregtech/GTRecipeMap.java | 11 ++++--- .../gttweaker/mods/gregtech/RA2Builder.java | 32 ++++--------------- .../mods/gregtech/RecipeRemover.java | 32 ++++--------------- 6 files changed, 36 insertions(+), 69 deletions(-) diff --git a/.gitignore b/.gitignore index 89e03fe..5e80e0a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .gradle .settings /.idea/ +/.vscode/ /run/ /build/ /eclipse/ @@ -25,7 +26,13 @@ whitelist.json *.iml *.ipr *.iws -src/main/resources/mixins.*.json +src/main/resources/mixins.*([!.]).json *.bat -.vscode -*.bak +*.DS_Store +!gradlew.bat +.factorypath +addon.local.gradle +addon.local.gradle.kts +addon.late.local.gradle +addon.late.local.gradle.kts +layout.json diff --git a/build.gradle b/build.gradle index 6a54d13..4e31dc8 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -//version: 1695474595 +//version: 1700844281 /* DO NOT CHANGE THIS FILE! Also, you may replace this file at any time if there is an update available. @@ -302,7 +302,7 @@ if (apiPackage) { } if (accessTransformersFile) { - for (atFile in accessTransformersFile.split(",")) { + for (atFile in accessTransformersFile.split(" ")) { String targetFile = "src/main/resources/META-INF/" + atFile.trim() if (!getFile(targetFile).exists()) { throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile) @@ -646,7 +646,7 @@ repositories { def mixinProviderGroup = "io.github.legacymoddingmc" def mixinProviderModule = "unimixins" -def mixinProviderVersion = "0.1.7.1" +def mixinProviderVersion = "0.1.13" def mixinProviderSpecNoClassifer = "${mixinProviderGroup}:${mixinProviderModule}:${mixinProviderVersion}" def mixinProviderSpec = "${mixinProviderSpecNoClassifer}:dev" ext.mixinProviderSpec = mixinProviderSpec @@ -793,12 +793,12 @@ ext.java17PatchDependenciesCfg = configurations.create("java17PatchDependencies" } dependencies { - def lwjgl3ifyVersion = '1.5.0' + def lwjgl3ifyVersion = '1.5.1' if (modId != 'lwjgl3ify') { java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}") } if (modId != 'hodgepodge') { - java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.3.5') + java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.3.17') } java17PatchDependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}:forgePatches") {transitive = false} @@ -1187,9 +1187,8 @@ publishing { version = System.getenv("RELEASE_VERSION") ?: identifiedVersion } } - repositories { - if (usesMavenPublishing.toBoolean()) { + if (usesMavenPublishing.toBoolean() && System.getenv("MAVEN_USER") != null) { maven { url = mavenPublishUrl allowInsecureProtocol = mavenPublishUrl.startsWith("http://") // Mostly for the GTNH maven diff --git a/dependencies.gradle b/dependencies.gradle index 6f77d55..0b4cc03 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -22,7 +22,7 @@ * For more details, see https://docs.gradle.org/7.6/userguide/java_library_plugin.html#sec:java_library_configurations_graph */ dependencies { - api("com.github.GTNewHorizons:GT5-Unofficial:5.09.44.23:dev") - api("com.github.GTNewHorizons:GTplusplus:1.10.10:dev") + api("com.github.GTNewHorizons:GT5-Unofficial:5.09.44.92-pre:dev") + api("com.github.GTNewHorizons:GTplusplus:1.10.35-pre:dev") api("com.github.GTNewHorizons:CraftTweaker:3.2.13:dev") } diff --git a/src/main/java/gttweaker/mods/gregtech/GTRecipeMap.java b/src/main/java/gttweaker/mods/gregtech/GTRecipeMap.java index c4c20ee..c1aa216 100644 --- a/src/main/java/gttweaker/mods/gregtech/GTRecipeMap.java +++ b/src/main/java/gttweaker/mods/gregtech/GTRecipeMap.java @@ -2,18 +2,19 @@ import java.util.HashMap; -import gregtech.api.util.GT_Recipe; +import gregtech.api.recipe.RecipeMap; public class GTRecipeMap { - public static HashMap recipeMaps = new HashMap<>(); + public static HashMap> recipeMaps = new HashMap<>(); - public static GT_Recipe.GT_Recipe_Map getRecipeMap(String map) { + public static RecipeMap getRecipeMap(String map) { if (!recipeMaps.containsKey(map)) { recipeMaps.put( map, - GT_Recipe.GT_Recipe_Map.sMappings.stream() - .filter(m -> m.mUnlocalizedName.equals(map)) + RecipeMap.ALL_RECIPE_MAPS.values() + .stream() + .filter(m -> m.unlocalizedName.equals(map)) .findAny() .orElse(null)); } diff --git a/src/main/java/gttweaker/mods/gregtech/RA2Builder.java b/src/main/java/gttweaker/mods/gregtech/RA2Builder.java index f0c8013..888c630 100644 --- a/src/main/java/gttweaker/mods/gregtech/RA2Builder.java +++ b/src/main/java/gttweaker/mods/gregtech/RA2Builder.java @@ -1,14 +1,13 @@ package gttweaker.mods.gregtech; import java.util.Arrays; -import java.util.Map; import java.util.Objects; -import java.util.stream.Collectors; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import gregtech.api.enums.GT_Values; +import gregtech.api.recipe.RecipeMap; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_RecipeBuilder; import gttweaker.GTTweaker; @@ -141,7 +140,7 @@ public void addTo(String recipeMap) { MineTweakerAPI.logError("Could not build recipe!"); return; } - GT_Recipe.GT_Recipe_Map map = GTRecipeMap.getRecipeMap(recipeMap); + RecipeMap map = GTRecipeMap.getRecipeMap(recipeMap); if (map == null) { MineTweakerAPI.logError("Could not find recipe map named \"" + recipeMap + "\""); return; @@ -153,9 +152,9 @@ public void addTo(String recipeMap) { public static class RecipeAddAction implements IUndoableAction { GT_Recipe recipe; - GT_Recipe.GT_Recipe_Map map; + RecipeMap map; - public RecipeAddAction(GT_Recipe recipe, GT_Recipe.GT_Recipe_Map map) { + public RecipeAddAction(GT_Recipe recipe, RecipeMap map) { this.recipe = recipe; this.map = map; } @@ -172,27 +171,8 @@ public boolean canUndo() { @Override public void undo() { - map.mRecipeList.remove(recipe); - map.mRecipeItemMap.entrySet() - .stream() - .filter( - e -> e.getValue() - .removeIf(r -> r == recipe) - && e.getValue() - .isEmpty()) - .map(Map.Entry::getKey) - .collect(Collectors.toSet()) - .forEach(k -> map.mRecipeItemMap.remove(k)); - map.mRecipeFluidMap.entrySet() - .stream() - .filter( - e -> e.getValue() - .removeIf(r -> r == recipe) - && e.getValue() - .isEmpty()) - .map(Map.Entry::getKey) - .collect(Collectors.toSet()) - .forEach(k -> map.mRecipeFluidMap.remove(k)); + map.getBackend() + .removeRecipe(recipe); } @Override diff --git a/src/main/java/gttweaker/mods/gregtech/RecipeRemover.java b/src/main/java/gttweaker/mods/gregtech/RecipeRemover.java index 208392c..c1580f1 100644 --- a/src/main/java/gttweaker/mods/gregtech/RecipeRemover.java +++ b/src/main/java/gttweaker/mods/gregtech/RecipeRemover.java @@ -1,13 +1,12 @@ package gttweaker.mods.gregtech; import java.util.Arrays; -import java.util.Map; import java.util.Objects; -import java.util.stream.Collectors; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; +import gregtech.api.recipe.RecipeMap; import gregtech.api.util.GT_Recipe; import gttweaker.GTTweaker; import minetweaker.IUndoableAction; @@ -24,7 +23,7 @@ public class RecipeRemover { @ZenMethod public static void remove(String map, IIngredient[] inputs, IIngredient[] fluidInputs) { - GT_Recipe.GT_Recipe_Map recipeMap = GTRecipeMap.getRecipeMap(map); + RecipeMap recipeMap = GTRecipeMap.getRecipeMap(map); if (recipeMap == null) { MineTweakerAPI.logError("Could not find recipe map named \"" + map + "\""); return; @@ -52,36 +51,17 @@ public static void remove(String map, IIngredient[] inputs, IIngredient[] fluidI public static class RecipeRemoveAction implements IUndoableAction { GT_Recipe recipe; - GT_Recipe.GT_Recipe_Map map; + RecipeMap map; - public RecipeRemoveAction(GT_Recipe recipe, GT_Recipe.GT_Recipe_Map map) { + public RecipeRemoveAction(GT_Recipe recipe, RecipeMap map) { this.recipe = recipe; this.map = map; } @Override public void apply() { - map.mRecipeList.remove(recipe); - map.mRecipeItemMap.entrySet() - .stream() - .filter( - e -> e.getValue() - .removeIf(r -> r == recipe) - && e.getValue() - .size() == 0) - .map(Map.Entry::getKey) - .collect(Collectors.toSet()) - .forEach(k -> map.mRecipeItemMap.remove(k)); - map.mRecipeFluidMap.entrySet() - .stream() - .filter( - e -> e.getValue() - .removeIf(r -> r == recipe) - && e.getValue() - .size() == 0) - .map(Map.Entry::getKey) - .collect(Collectors.toSet()) - .forEach(k -> map.mRecipeFluidMap.remove(k)); + map.getBackend() + .removeRecipe(recipe); } @Override