From a7ea99872a23eaef80bcd5ab7d0ba39c105c55e9 Mon Sep 17 00:00:00 2001 From: GlodBlock <1356392126@qq.com> Date: Tue, 11 Jun 2024 15:55:35 +0800 Subject: [PATCH] fix interface can't pull items from network --- .../java/appeng/helpers/DualityInterface.java | 4 +++- .../inventory/AppEngNetworkInventory.java | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/java/appeng/helpers/DualityInterface.java b/src/main/java/appeng/helpers/DualityInterface.java index 6e57f7f361c..bf2d5f80b43 100644 --- a/src/main/java/appeng/helpers/DualityInterface.java +++ b/src/main/java/appeng/helpers/DualityInterface.java @@ -64,6 +64,7 @@ import appeng.parts.misc.PartInterface; import appeng.tile.inventory.AppEngInternalAEInventory; import appeng.tile.inventory.AppEngInternalInventory; +import appeng.tile.inventory.AppEngInternalOversizedInventory; import appeng.tile.inventory.AppEngNetworkInventory; import appeng.tile.networking.TileCableBus; import appeng.util.ConfigManager; @@ -97,6 +98,7 @@ import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.wrapper.RangedWrapper; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.*; @@ -881,7 +883,7 @@ private boolean usePlan(final int x, final IAEItemStack itemStack) { } private InventoryAdaptor getAdaptor(final int slot) { - return new AdaptorItemHandler(new RangedWrapper(this.storage, slot, slot + 1)); + return new AdaptorItemHandler(((AppEngNetworkInventory) this.storage).getBufferWrapper(slot)); } private boolean handleCrafting(final int x, final InventoryAdaptor d, final IAEItemStack itemStack) { diff --git a/src/main/java/appeng/tile/inventory/AppEngNetworkInventory.java b/src/main/java/appeng/tile/inventory/AppEngNetworkInventory.java index 1237e8ac5fb..e3c61cf63d2 100644 --- a/src/main/java/appeng/tile/inventory/AppEngNetworkInventory.java +++ b/src/main/java/appeng/tile/inventory/AppEngNetworkInventory.java @@ -10,6 +10,7 @@ import appeng.util.inv.IAEAppEngInventory; import appeng.util.item.AEItemStack; import net.minecraft.item.ItemStack; +import net.minecraftforge.items.wrapper.RangedWrapper; import javax.annotation.Nonnull; import java.util.function.Supplier; @@ -45,4 +46,22 @@ public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate } } + @Nonnull + private ItemStack insertToBuffer(int slot, @Nonnull ItemStack stack, boolean simulate) { + return super.insertItem(slot, stack, simulate); + } + + public RangedWrapper getBufferWrapper(int selectSlot) { + return new RangedWrapper(this, selectSlot, selectSlot + 1) { + @Override + @Nonnull + public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { + if (slot == 0) { + return AppEngNetworkInventory.this.insertToBuffer(selectSlot, stack, simulate); + } + return stack; + } + }; + } + }