Fix ME Interfaces not pulling items from storage (#454)

This commit is contained in:
Yang Xizhi
2024-06-13 10:57:37 +08:00
committed by GitHub
parent 9a255432f5
commit efe726ecdd
2 changed files with 22 additions and 1 deletions
@@ -64,6 +64,7 @@ import appeng.parts.automation.UpgradeInventory;
import appeng.parts.misc.PartInterface; import appeng.parts.misc.PartInterface;
import appeng.tile.inventory.AppEngInternalAEInventory; import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.tile.inventory.AppEngInternalInventory; import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.AppEngInternalOversizedInventory;
import appeng.tile.inventory.AppEngNetworkInventory; import appeng.tile.inventory.AppEngNetworkInventory;
import appeng.tile.networking.TileCableBus; import appeng.tile.networking.TileCableBus;
import appeng.util.ConfigManager; import appeng.util.ConfigManager;
@@ -97,6 +98,7 @@ import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.RangedWrapper; import net.minecraftforge.items.wrapper.RangedWrapper;
import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.*; import java.util.*;
@@ -881,7 +883,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
} }
private InventoryAdaptor getAdaptor(final int slot) { 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) { private boolean handleCrafting(final int x, final InventoryAdaptor d, final IAEItemStack itemStack) {
@@ -10,6 +10,7 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.util.inv.IAEAppEngInventory; import appeng.util.inv.IAEAppEngInventory;
import appeng.util.item.AEItemStack; import appeng.util.item.AEItemStack;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.items.wrapper.RangedWrapper;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.function.Supplier; import java.util.function.Supplier;
@@ -45,4 +46,22 @@ public class AppEngNetworkInventory extends AppEngInternalOversizedInventory {
} }
} }
@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;
}
};
}
} }