Skip to content

Commit

Permalink
fix interface can't pull items from network
Browse files Browse the repository at this point in the history
  • Loading branch information
GlodBlock committed Jun 11, 2024
1 parent 9a25543 commit a7ea998
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/appeng/helpers/DualityInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.*;

Expand Down Expand Up @@ -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) {
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/appeng/tile/inventory/AppEngNetworkInventory.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
};
}

}

0 comments on commit a7ea998

Please sign in to comment.