From 5a1eabeac48b56f34b47e1561b099c2152bad722 Mon Sep 17 00:00:00 2001 From: Mrbysco Date: Wed, 13 Mar 2024 01:02:49 +0100 Subject: [PATCH] Fix hopping item interface --- .../mod/tile/TileEntityItemInterface.java | 15 +++++++-------- .../actuallyadditions/mod/util/WorldUtil.java | 5 +++-- .../compat/SlotlessableItemHandlerWrapper.java | 2 ++ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemInterface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemInterface.java index 4cbb46ac6..6936c4c8a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemInterface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemInterface.java @@ -198,16 +198,15 @@ public class TileEntityItemInterface extends TileEntityBase { int slotsQueried = 0; for (GenericItemHandlerInfo info : this.genericInfos) { + if (!info.isLoaded()) continue; for (SlotlessableItemHandlerWrapper handler : info.handlers) { - Optional normalHandler = Optional.ofNullable(handler.getNormalHandler()); - slotsQueried += normalHandler.map(cap -> { - int queried = 0; - for (int i = 0; i < cap.getSlots(); i++) { - this.itemHandlerInfos.put(queried, new IItemHandlerInfo(cap, i, info.relayInQuestion)); - queried++; + IItemHandler normalHandler = handler.getNormalHandler(); + if (normalHandler != null) { + for (int i = 0; i < normalHandler.getSlots(); i++) { + this.itemHandlerInfos.put(slotsQueried, new IItemHandlerInfo(normalHandler, i, info.relayInQuestion)); + slotsQueried++; } - return queried; - }).orElse(0); + } // TODO: [port] add back // if (ActuallyAdditions.commonCapsLoaded) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java index e9314a161..367b2c862 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java @@ -41,6 +41,7 @@ import net.neoforged.neoforge.event.EventHooks; import net.neoforged.neoforge.event.level.BlockEvent.BreakEvent; import net.neoforged.neoforge.fluids.FluidStack; import net.neoforged.neoforge.fluids.capability.IFluidHandler; +import net.neoforged.neoforge.items.IItemHandler; import java.util.ArrayList; import java.util.List; @@ -94,7 +95,7 @@ public final class WorldUtil { } if (!StackUtil.isValid(extracted)) { -/* IItemHandler handler = extractWrapper.getNormalHandler(); + IItemHandler handler = extractWrapper.getNormalHandler(); if (handler != null) { for (int i = Math.max(0, slotStart); i < Math.min(slotEnd, handler.getSlots()); i++) { if (filter == null || !filter.needsCheck() || filter.check(handler.getStackInSlot(i))) { @@ -105,7 +106,7 @@ public final class WorldUtil { } } } - }*/ + } } return extracted; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/SlotlessableItemHandlerWrapper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/SlotlessableItemHandlerWrapper.java index 45fd25917..0735d608b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/SlotlessableItemHandlerWrapper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/SlotlessableItemHandlerWrapper.java @@ -16,6 +16,7 @@ public class SlotlessableItemHandlerWrapper { //TODO: Check if we need this wrapper at all? The previous implementation used CommonCapabilities ISlotlessItemhandler private final IItemHandler normalHandler; + @Deprecated private final Object slotlessHandler; public SlotlessableItemHandlerWrapper(IItemHandler normalHandler, Object slotlessHandler) { @@ -27,6 +28,7 @@ public class SlotlessableItemHandlerWrapper { return this.normalHandler; } + @Deprecated public Object getSlotlessHandler() { return this.slotlessHandler; }