diff --git a/CHANGELOG.md b/CHANGELOG.md index ef85fbe30..100101c94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - The Pattern now shows the recipe in the tooltip. - When a Pattern is created for a recipe, the Pattern will have a different texture and name to differentiate between empty patterns. - The Pattern Grid now has additional support for encoding stonecutter and smithing table recipes. +- The Pattern output is now always rendered in the Pattern Grid result slot. ### Fixed diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridContainerMenu.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridContainerMenu.java index 34baf8a06..5fd7de946 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridContainerMenu.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternGridContainerMenu.java @@ -25,6 +25,7 @@ import net.minecraft.world.Container; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.inventory.ResultContainer; +import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.SmithingTemplateItem; @@ -58,6 +59,8 @@ public class PatternGridContainerMenu extends AbstractGridContainerMenu { private PatternGridListener listener; @Nullable private PatternGridBlockEntity patternGrid; + @Nullable + private Slot patternOutputSlot; public PatternGridContainerMenu(final int syncId, final Inventory playerInventory, @@ -198,7 +201,7 @@ private void addPatternSlots(final int playerInventoryY) { playerInventoryY - Y_OFFSET_BETWEEN_PLAYER_INVENTORY_AND_PATTERN_INPUT_SLOT, PatternGridBlockEntity::isValidPattern )); - addSlot(new ValidatedSlot( + patternOutputSlot = addSlot(new ValidatedSlot( patternOutput, 0, 152, @@ -224,6 +227,11 @@ public void set(final ItemStack stack) { transferManager.addTransfer(patternOutput, playerInventory); } + @Nullable + Slot getPatternOutputSlot() { + return patternOutputSlot; + } + private void addCraftingMatrixSlots(final int playerInventoryY) { for (int y = 0; y < 3; ++y) { for (int x = 0; x < 3; ++x) { diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternRendering.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternRendering.java index 2aba85846..3c8108885 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternRendering.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/PatternRendering.java @@ -7,6 +7,7 @@ import java.util.Optional; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.Screen; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; @@ -16,7 +17,18 @@ private PatternRendering() { } public static boolean canDisplayOutput(final ItemStack stack) { - return stack.getItem() instanceof PatternProviderItem && Screen.hasShiftDown(); + if (!(stack.getItem() instanceof PatternProviderItem)) { + return false; + } + if (Screen.hasShiftDown()) { + return true; + } + final Screen screen = Minecraft.getInstance().screen; + if (screen instanceof PatternGridScreen patternGridScreen) { + return patternGridScreen.getMenu().getPatternOutputSlot() != null + && patternGridScreen.getMenu().getPatternOutputSlot().getItem() == stack; + } + return false; } public static Optional getOutput(final ItemStack stack) {