From 9965b3dd57bee18ed574cfef30d7714f40c1278e Mon Sep 17 00:00:00 2001 From: Dragon-Seeker Date: Fri, 1 Dec 2023 19:31:13 -0600 Subject: [PATCH] Backport Fixes --- gradle.properties | 18 +++--- .../block/ForgeControllerBlockEntity.java | 2 +- .../emi/AlloyForgeryEmiRecipeHandler.java | 7 ++- .../compat/emi/CustomButtonWidget.java | 2 - .../compat/emi/CustomSlotWidget.java | 2 +- .../data/DelayedTagGroupLoader.java | 58 +++++++++++-------- .../alloyforgery/data/RecipeTagLoader.java | 2 +- .../alloyforgery/recipe/AlloyForgeRecipe.java | 1 + .../recipe/BlastFurnaceRecipeAdapter.java | 12 ++-- .../alloyforgery/utils/RecipeInjector.java | 4 +- .../resources/alloy_forgery.accesswidener | 6 +- 11 files changed, 59 insertions(+), 55 deletions(-) diff --git a/gradle.properties b/gradle.properties index 488a4ee..d472318 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,23 +5,19 @@ org.gradle.jvmargs=-Xmx1G minecraft_base_version=1.19 minecraft_version=1.19.2 yarn_mappings=1.19.2+build.28 -loader_version=0.14.22 +loader_version=0.14.25 # Mod Properties mod_version=2.1.1 maven_group=io.wispforest archives_base_name=alloy-forgery # Dependencies -fabric_version=0.64.0+1.19.2 - +fabric_version=0.77.0+1.19.2 # https://maven.shedaniel.me/me/shedaniel/RoughlyEnoughItems-fabric/ -rei_version=9.0.472 -arch_version = 6.3.49 - +rei_version=9.1.668 +arch_version=6.5.82 # https://www.curseforge.com/minecraft/mc-mods/modmenu/files -modmenu_version=4.1.1 - +modmenu_version=4.2.0-beta.2 # https://maven.wispforest.io/io/wispforest/owo-lib -owo_version=0.8.5+1.19 - +owo_version=0.9.3+1.19 # https://maven.terraformersmc.com/releases/dev/emi/emi -emi_version=0.5.2+1.19.2 +emi_version=1.0.8+1.19.2 diff --git a/src/main/java/wraith/alloyforgery/block/ForgeControllerBlockEntity.java b/src/main/java/wraith/alloyforgery/block/ForgeControllerBlockEntity.java index b7bd92b..8a4e876 100644 --- a/src/main/java/wraith/alloyforgery/block/ForgeControllerBlockEntity.java +++ b/src/main/java/wraith/alloyforgery/block/ForgeControllerBlockEntity.java @@ -273,7 +273,7 @@ public void tick() { if (remainderList != null) this.handleForgingRemainders(remainderList); var outputStack = this.getStack(10); - var recipeOutput = recipe.craft(this, this.world.getRegistryManager()); + var recipeOutput = recipe.craft(this); recipe.consumeIngredients(this); diff --git a/src/main/java/wraith/alloyforgery/compat/emi/AlloyForgeryEmiRecipeHandler.java b/src/main/java/wraith/alloyforgery/compat/emi/AlloyForgeryEmiRecipeHandler.java index b5d3d28..68e9f89 100644 --- a/src/main/java/wraith/alloyforgery/compat/emi/AlloyForgeryEmiRecipeHandler.java +++ b/src/main/java/wraith/alloyforgery/compat/emi/AlloyForgeryEmiRecipeHandler.java @@ -1,6 +1,7 @@ package wraith.alloyforgery.compat.emi; -import dev.emi.emi.api.EmiRecipeHandler; +import dev.emi.emi.api.recipe.handler.EmiRecipeHandler; +import dev.emi.emi.api.recipe.handler.StandardRecipeHandler; import dev.emi.emi.api.recipe.EmiRecipe; import net.minecraft.screen.slot.Slot; import org.jetbrains.annotations.Nullable; @@ -9,7 +10,7 @@ import java.util.ArrayList; import java.util.List; -public class AlloyForgeryEmiRecipeHandler implements EmiRecipeHandler { +public class AlloyForgeryEmiRecipeHandler implements StandardRecipeHandler { @Override public List getInputSources(AlloyForgeScreenHandler handler) { List slots = new ArrayList<>(); @@ -31,7 +32,7 @@ public List getCraftingSlots(AlloyForgeScreenHandler handler) { @Override public @Nullable Slot getOutputSlot(AlloyForgeScreenHandler handler) { - return EmiRecipeHandler.super.getOutputSlot(handler); + return StandardRecipeHandler.super.getOutputSlot(handler); } @Override diff --git a/src/main/java/wraith/alloyforgery/compat/emi/CustomButtonWidget.java b/src/main/java/wraith/alloyforgery/compat/emi/CustomButtonWidget.java index fcc927e..e9cfb85 100644 --- a/src/main/java/wraith/alloyforgery/compat/emi/CustomButtonWidget.java +++ b/src/main/java/wraith/alloyforgery/compat/emi/CustomButtonWidget.java @@ -1,7 +1,6 @@ package wraith.alloyforgery.compat.emi; import com.mojang.blaze3d.systems.RenderSystem; -import dev.emi.emi.EmiPort; import dev.emi.emi.api.widget.Bounds; import dev.emi.emi.api.widget.ButtonWidget; import dev.emi.emi.api.widget.Widget; @@ -37,7 +36,6 @@ public Bounds getBounds() { @Override public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { - EmiPort.setPositionTexShader(); RenderSystem.setShaderTexture(0, AlloyForgeryEmiRecipe.GUI_TEXTURE); int v = 68; boolean active = this.isActive.getAsBoolean(); diff --git a/src/main/java/wraith/alloyforgery/compat/emi/CustomSlotWidget.java b/src/main/java/wraith/alloyforgery/compat/emi/CustomSlotWidget.java index 707dd65..95aa5d7 100644 --- a/src/main/java/wraith/alloyforgery/compat/emi/CustomSlotWidget.java +++ b/src/main/java/wraith/alloyforgery/compat/emi/CustomSlotWidget.java @@ -20,7 +20,7 @@ public void setMutableStack(EmiIngredient stack) { } @Override - protected EmiIngredient getStack() { + public EmiIngredient getStack() { return mutableStack; } } diff --git a/src/main/java/wraith/alloyforgery/data/DelayedTagGroupLoader.java b/src/main/java/wraith/alloyforgery/data/DelayedTagGroupLoader.java index 99ed1db..a976f7c 100644 --- a/src/main/java/wraith/alloyforgery/data/DelayedTagGroupLoader.java +++ b/src/main/java/wraith/alloyforgery/data/DelayedTagGroupLoader.java @@ -1,12 +1,10 @@ package wraith.alloyforgery.data; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; +import com.google.common.collect.*; import com.mojang.logging.LogUtils; import net.minecraft.recipe.Recipe; -import net.minecraft.registry.tag.TagEntry; -import net.minecraft.registry.tag.TagGroupLoader; -import net.minecraft.resource.DependencyTracker; +import net.minecraft.tag.TagEntry; +import net.minecraft.tag.TagGroupLoader; import net.minecraft.util.Identifier; import net.minecraft.util.Pair; import org.jetbrains.annotations.Nullable; @@ -67,26 +65,38 @@ public Map> buildGroup(Map tag(Identifier id) { return map.get(id); } }; - DependencyTracker dependencyTracker = new DependencyTracker<>(); - - tags.forEach((id, entries) -> dependencyTracker.add(id, new TagDependencies(entries))); - - dependencyTracker.traverse((id, dependencies) -> { - var pair = this.resolveAll(valueGetter, dependencies.entries()); - - var missingReferences = pair.getLeft(); - - if(!missingReferences.isEmpty()){ - LOGGER.error( - "Couldn't load the given entries within tag {}: {}", - id, - missingReferences.stream().map(Objects::toString).collect(Collectors.joining(", ")) + Multimap multimap = HashMultimap.create(); + tags.forEach( + (tagId, entries) -> entries.forEach(entry -> entry.entry().forEachRequiredTagId(referencedTagId -> addReference(multimap, tagId, referencedTagId))) + ); + tags.forEach( + (tagId, entries) -> entries.forEach(entry -> entry.entry().forEachOptionalTagId(referencedTagId -> addReference(multimap, tagId, referencedTagId))) + ); + Set set = Sets.newHashSet(); + tags.keySet() + .forEach( + tagId -> resolveAll( + tags, + multimap, + set, + tagId, + (tagId2, entries) -> { + var pair = this.resolveAll(valueGetter, entries); + + var missingReferences = pair.getLeft(); + + if(!missingReferences.isEmpty()){ + LOGGER.error( + "Couldn't load the given entries within tag {}: {}", + tagId2, + missingReferences.stream().map(Objects::toString).collect(Collectors.joining(", ")) + ); + } + + map.put(tagId2, pair.getRight()); + } + ) ); - } - - map.put(id, pair.getRight()); - }); - return map; } } diff --git a/src/main/java/wraith/alloyforgery/data/RecipeTagLoader.java b/src/main/java/wraith/alloyforgery/data/RecipeTagLoader.java index bcf012d..2333250 100644 --- a/src/main/java/wraith/alloyforgery/data/RecipeTagLoader.java +++ b/src/main/java/wraith/alloyforgery/data/RecipeTagLoader.java @@ -5,7 +5,7 @@ import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener; import net.minecraft.recipe.Recipe; -import net.minecraft.registry.tag.TagGroupLoader; +import net.minecraft.tag.TagGroupLoader; import net.minecraft.resource.LifecycledResourceManager; import net.minecraft.resource.ResourceManager; import net.minecraft.resource.SinglePreparationResourceReloader; diff --git a/src/main/java/wraith/alloyforgery/recipe/AlloyForgeRecipe.java b/src/main/java/wraith/alloyforgery/recipe/AlloyForgeRecipe.java index 4c6df71..6a80d23 100644 --- a/src/main/java/wraith/alloyforgery/recipe/AlloyForgeRecipe.java +++ b/src/main/java/wraith/alloyforgery/recipe/AlloyForgeRecipe.java @@ -234,6 +234,7 @@ public ItemStack getOutput() { */ @ApiStatus.Internal public ItemStack getBaseOutput() { + return this.output.copy(); } public ItemStack getOutput(int forgeTier) { diff --git a/src/main/java/wraith/alloyforgery/recipe/BlastFurnaceRecipeAdapter.java b/src/main/java/wraith/alloyforgery/recipe/BlastFurnaceRecipeAdapter.java index 347e243..d10c832 100644 --- a/src/main/java/wraith/alloyforgery/recipe/BlastFurnaceRecipeAdapter.java +++ b/src/main/java/wraith/alloyforgery/recipe/BlastFurnaceRecipeAdapter.java @@ -6,10 +6,10 @@ import net.minecraft.recipe.BlastingRecipe; import net.minecraft.recipe.Recipe; import net.minecraft.recipe.RecipeType; -import net.minecraft.registry.Registries; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.tag.TagKey; +import net.minecraft.tag.TagKey; +import net.minecraft.tag.TagKey; import net.minecraft.util.Identifier; +import net.minecraft.util.registry.Registry; import wraith.alloyforgery.AlloyForgery; import wraith.alloyforgery.forges.ForgeDefinition; import wraith.alloyforgery.utils.RecipeInjector; @@ -25,7 +25,7 @@ */ public class BlastFurnaceRecipeAdapter implements RecipeInjector.AddRecipes { - private static final TagKey DUSTS_TAG = TagKey.of(RegistryKeys.ITEM, new Identifier("c", "dusts")); + private static final TagKey DUSTS_TAG = TagKey.of(Registry.ITEM_KEY, new Identifier("c", "dusts")); /** * Recipe tag for all {@link RecipeType#BLASTING} recipes to be disallowed for adaption @@ -53,7 +53,7 @@ public void addRecipes(RecipeInjector instance) { path = path.replace("blasting", "forging"); } - var mainOutput = recipe.getOutput(null); + var mainOutput = recipe.getOutput(); var extraOutput = ImmutableMap.builder(); @@ -113,7 +113,7 @@ private static boolean isDustRecipe(Recipe blastRecipe){ for (ItemStack stack : inputIngredient.getMatchingStacks()) { if(stack.isIn(DUSTS_TAG)) return true; - Identifier id = Registries.ITEM.getId(stack.getItem()); + Identifier id = Registry.ITEM.getId(stack.getItem()); if(id.getPath().contains("dust")) return true; } diff --git a/src/main/java/wraith/alloyforgery/utils/RecipeInjector.java b/src/main/java/wraith/alloyforgery/utils/RecipeInjector.java index 90126ba..dbf0471 100644 --- a/src/main/java/wraith/alloyforgery/utils/RecipeInjector.java +++ b/src/main/java/wraith/alloyforgery/utils/RecipeInjector.java @@ -9,7 +9,7 @@ import net.minecraft.recipe.Recipe; import net.minecraft.recipe.RecipeManager; import net.minecraft.recipe.RecipeType; -import net.minecraft.registry.Registries; +import net.minecraft.util.registry.Registry; import net.minecraft.server.MinecraftServer; import net.minecraft.util.Identifier; import org.slf4j.Logger; @@ -57,7 +57,7 @@ public RecipeInjector(RecipeManager manager){ * @param Type of the given Recipe */ public , C extends Inventory> void addRecipe(T recipe){ - if(Registries.RECIPE_TYPE.getId(recipe.getType()) == null){ + if(Registry.RECIPE_TYPE.getId(recipe.getType()) == null){ throw new IllegalStateException("Unable to add Recipe for a RecipeType not registered!"); } diff --git a/src/main/resources/alloy_forgery.accesswidener b/src/main/resources/alloy_forgery.accesswidener index 53567d3..3cd5da1 100644 --- a/src/main/resources/alloy_forgery.accesswidener +++ b/src/main/resources/alloy_forgery.accesswidener @@ -5,8 +5,6 @@ accessible class net/minecraft/block/entity/BlockEntityType$BlockEntityFactory accessible class net/minecraft/recipe/Ingredient$Entry accessible class net/minecraft/recipe/Ingredient$StackEntry accessible class net/minecraft/recipe/Ingredient$TagEntry -accessible field net/minecraft/item/ItemStackSet HASH_STRATEGY Lit/unimi/dsi/fastutil/Hash$Strategy; -accessible class net/minecraft/registry/tag/TagGroupLoader$TagDependencies - -accessible method net/minecraft/registry/tag/TagGroupLoader$TagDependencies (Ljava/util/List;)V \ No newline at end of file +accessible method net/minecraft/tag/TagGroupLoader addReference (Lcom/google/common/collect/Multimap;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)V +accessible method net/minecraft/tag/TagGroupLoader resolveAll (Ljava/util/Map;Lcom/google/common/collect/Multimap;Ljava/util/Set;Lnet/minecraft/util/Identifier;Ljava/util/function/BiConsumer;)V \ No newline at end of file