Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix interface can't pull items from network #454

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
};
}

}
Loading