Skip to content

Commit

Permalink
Backport Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dragon-Seeker committed Dec 2, 2023
1 parent 123be7c commit 9965b3d
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 55 deletions.
18 changes: 7 additions & 11 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -9,7 +10,7 @@
import java.util.ArrayList;
import java.util.List;

public class AlloyForgeryEmiRecipeHandler implements EmiRecipeHandler<AlloyForgeScreenHandler> {
public class AlloyForgeryEmiRecipeHandler implements StandardRecipeHandler<AlloyForgeScreenHandler> {
@Override
public List<Slot> getInputSources(AlloyForgeScreenHandler handler) {
List<Slot> slots = new ArrayList<>();
Expand All @@ -31,7 +32,7 @@ public List<Slot> getCraftingSlots(AlloyForgeScreenHandler handler) {

@Override
public @Nullable Slot getOutputSlot(AlloyForgeScreenHandler handler) {
return EmiRecipeHandler.super.getOutputSlot(handler);
return StandardRecipeHandler.super.getOutputSlot(handler);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void setMutableStack(EmiIngredient stack) {
}

@Override
protected EmiIngredient getStack() {
public EmiIngredient getStack() {
return mutableStack;
}
}
58 changes: 34 additions & 24 deletions src/main/java/wraith/alloyforgery/data/DelayedTagGroupLoader.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -67,26 +65,38 @@ public Map<Identifier, Collection<T>> buildGroup(Map<Identifier, List<TrackedEnt
@Nullable @Override public Collection<T> tag(Identifier id) { return map.get(id); }
};

DependencyTracker<Identifier, TagDependencies> 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<Identifier, Identifier> 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<Identifier> 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ public ItemStack getOutput() {
*/
@ApiStatus.Internal
public ItemStack getBaseOutput() {
return this.output.copy();
}

public ItemStack getOutput(int forgeTier) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -25,7 +25,7 @@
*/
public class BlastFurnaceRecipeAdapter implements RecipeInjector.AddRecipes {

private static final TagKey<Item> DUSTS_TAG = TagKey.of(RegistryKeys.ITEM, new Identifier("c", "dusts"));
private static final TagKey<Item> DUSTS_TAG = TagKey.of(Registry.ITEM_KEY, new Identifier("c", "dusts"));

/**
* Recipe tag for all {@link RecipeType#BLASTING} recipes to be disallowed for adaption
Expand Down Expand Up @@ -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.<AlloyForgeRecipe.OverrideRange, ItemStack>builder();

Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/wraith/alloyforgery/utils/RecipeInjector.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -57,7 +57,7 @@ public RecipeInjector(RecipeManager manager){
* @param <T> Type of the given Recipe
*/
public <T extends Recipe<C>, 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!");
}

Expand Down
6 changes: 2 additions & 4 deletions src/main/resources/alloy_forgery.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -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 <init> (Ljava/util/List;)V
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

0 comments on commit 9965b3d

Please sign in to comment.