diff --git a/gradle.properties b/gradle.properties index d1da6eb7..d8d1711b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.daemon=false mod_id=sophisticatedbackpacks mod_group_id=sophisticatedbackpacks -mod_version=3.21.0 +mod_version=3.21.1 sonar_project_key=sophisticatedbackpacks:SophisticatedBackpacks github_package_url=https://maven.pkg.github.com/P3pp3rF1y/SophisticatedBackpacks @@ -31,5 +31,5 @@ crafting_tweaks_cf_file_id=4596466 chipped_cf_file_id=5077656 resourcefullib_cf_file_id=5070629 athena_cf_file_id=4764357 -sc_version=[1.20.1-1.0.3,1.20.4) +sc_version=[1.20.1-1.0.4,1.20.4) parchment_version=2023.09.03-1.20.1 \ No newline at end of file diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/compat/jei/SBPPlugin.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/compat/jei/SBPPlugin.java index 883ae80d..5344f088 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/compat/jei/SBPPlugin.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/compat/jei/SBPPlugin.java @@ -12,7 +12,9 @@ import net.minecraft.client.renderer.Rect2i; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.CraftingRecipe; import net.minecraft.world.item.crafting.ShapedRecipe; +import net.minecraft.world.item.crafting.SmithingRecipe; import net.p3pp3rf1y.sophisticatedbackpacks.SophisticatedBackpacks; import net.p3pp3rf1y.sophisticatedbackpacks.api.CapabilityBackpackWrapper; import net.p3pp3rf1y.sophisticatedbackpacks.client.gui.BackpackScreen; @@ -90,6 +92,7 @@ public void registerRecipes(IRecipeRegistration registration) { public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) { registration.addRecipeCatalyst(new ItemStack(ModItems.CRAFTING_UPGRADE.get()), RecipeTypes.CRAFTING); registration.addRecipeCatalyst(new ItemStack(ModItems.STONECUTTER_UPGRADE.get()), RecipeTypes.STONECUTTING); + registration.addRecipeCatalyst(new ItemStack(ModItems.SMITHING_UPGRADE.get()), RecipeTypes.SMITHING); additionalCatalystRegistrar.accept(registration); } @@ -97,12 +100,28 @@ public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) { public void registerRecipeTransferHandlers(IRecipeTransferRegistration registration) { IRecipeTransferHandlerHelper handlerHelper = registration.getTransferHelper(); IStackHelper stackHelper = registration.getJeiHelpers().getStackHelper(); - registration.addRecipeTransferHandler(new CraftingContainerRecipeTransferHandlerBase(handlerHelper, stackHelper) { + registration.addRecipeTransferHandler(new CraftingContainerRecipeTransferHandlerBase(handlerHelper, stackHelper) { @Override public Class getContainerClass() { return BackpackContainer.class; } + + @Override + public mezz.jei.api.recipe.RecipeType getRecipeType() { + return RecipeTypes.CRAFTING; + } }, RecipeTypes.CRAFTING); - } + registration.addRecipeTransferHandler(new CraftingContainerRecipeTransferHandlerBase(handlerHelper, stackHelper) { + @Override + public Class getContainerClass() { + return BackpackContainer.class; + } + + @Override + public mezz.jei.api.recipe.RecipeType getRecipeType() { + return RecipeTypes.SMITHING; + } + }, RecipeTypes.SMITHING); + } } diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/smithing/SmithingUpgradeContainer.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/smithing/SmithingUpgradeContainer.java index c8aec7f8..f4fe8dc7 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/smithing/SmithingUpgradeContainer.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/smithing/SmithingUpgradeContainer.java @@ -1,19 +1,25 @@ package net.p3pp3rf1y.sophisticatedbackpacks.upgrades.smithing; import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.Container; import net.minecraft.world.SimpleContainer; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.*; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.RecipeType; +import net.p3pp3rf1y.sophisticatedcore.common.gui.ICraftingContainer; import net.p3pp3rf1y.sophisticatedcore.common.gui.SlotSuppliedHandler; import net.p3pp3rf1y.sophisticatedcore.common.gui.UpgradeContainerBase; import net.p3pp3rf1y.sophisticatedcore.common.gui.UpgradeContainerType; import net.p3pp3rf1y.sophisticatedcore.upgrades.IUpgradeWrapper; import net.p3pp3rf1y.sophisticatedcore.util.NBTHelper; +import net.p3pp3rf1y.sophisticatedcore.util.RecipeHelper; -public class SmithingUpgradeContainer extends UpgradeContainerBase { +import java.util.List; + +public class SmithingUpgradeContainer extends UpgradeContainerBase implements ICraftingContainer { private static final String DATA_SHIFT_CLICK_INTO_STORAGE = "shiftClickIntoStorage"; private final Slot resultSlot; private Runnable onResultChanged = () -> {}; @@ -83,6 +89,26 @@ public Slot getResultSlot() { return smithingMenuDelegate.getSlot(SmithingMenu.RESULT_SLOT); } + @Override + public List getRecipeSlots() { + return List.of(getTemplateSlot(), getBaseSlot(), getAdditionalSlot()); + } + + @Override + public Container getCraftMatrix() { + return smithingMenuDelegate.getInputSlots(); + } + + @Override + public void setRecipeUsed(ResourceLocation recipeId) { + smithingMenuDelegate.setSelectedRecipe(recipeId); + } + + @Override + public RecipeType getRecipeType() { + return RecipeType.SMITHING; + } + private class PersistableSmithingMenu extends SmithingMenu { public PersistableSmithingMenu(Inventory playerInventory) { @@ -155,5 +181,13 @@ public void slotsChanged(Container pInventory) { createResult(); onResultChanged.run(); } + + public Container getInputSlots() { + return inputSlots; + } + + public void setSelectedRecipe(ResourceLocation recipeId) { + RecipeHelper.safeGetRecipeFor(RecipeType.SMITHING, inputSlots, recipeId).ifPresent(recipe -> selectedRecipe = recipe); + } } } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 8ad779d2..d2312d32 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -38,6 +38,7 @@ protected net.minecraft.world.inventory.AnvilMenu f_39001_ # itemName protected net.minecraft.world.inventory.ItemCombinerMenu m_266254_(Lnet/minecraft/world/inventory/ItemCombinerMenuSlotDefinition;)V # createInputSlots protected net.minecraft.world.inventory.ItemCombinerMenu m_266190_(I)Lnet/minecraft/world/SimpleContainer; # createContainer protected net.minecraft.world.inventory.ItemCombinerMenu m_266430_(Lnet/minecraft/world/inventory/ItemCombinerMenuSlotDefinition;)V # createResultSlot +protected net.minecraft.world.inventory.SmithingMenu f_40242_ # selectedRecipe public net.minecraft.client.gui.screens.inventory.SmithingScreen f_265883_ # EMPTY_SLOT_SMITHING_TEMPLATES public net.minecraft.client.gui.screens.inventory.SmithingScreen f_266014_ # ERROR_TOOLTIP public net.minecraft.client.gui.screens.inventory.SmithingScreen f_266043_ # MISSING_TEMPLATE_TOOLTIP \ No newline at end of file