diff --git a/src/main/java/com/simibubi/create/content/kinetics/belt/BeltBlockEntity.java b/src/main/java/com/simibubi/create/content/kinetics/belt/BeltBlockEntity.java index e8e33eb82..c96111e40 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/belt/BeltBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/kinetics/belt/BeltBlockEntity.java @@ -30,6 +30,7 @@ import com.simibubi.create.content.kinetics.belt.transport.ItemHandlerBeltSegmen import com.simibubi.create.content.kinetics.belt.transport.TransportedItemStack; import com.simibubi.create.content.logistics.tunnel.BrassTunnelBlockEntity; import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour; +import com.simibubi.create.foundation.blockEntity.behaviour.inventory.VersionedInventoryTrackerBehaviour; import com.simibubi.create.foundation.utility.NBTHelper; import net.minecraft.client.renderer.LightTexture; @@ -73,6 +74,7 @@ public class BeltBlockEntity extends KineticBlockEntity { protected BlockPos controller; protected BeltInventory inventory; protected LazyOptional itemHandler; + public VersionedInventoryTrackerBehaviour invVersionTracker; public CompoundTag trackerUpdateTag; @@ -98,6 +100,7 @@ public class BeltBlockEntity extends KineticBlockEntity { .setInsertionHandler(this::tryInsertingFromSide).considerOccupiedWhen(this::isOccupied)); behaviours.add(new TransportedItemStackHandlerBehaviour(this, this::applyToAllItems) .withStackPlacement(this::getWorldPositionOf)); + behaviours.add(invVersionTracker = new VersionedInventoryTrackerBehaviour(this)); } @Override diff --git a/src/main/java/com/simibubi/create/content/kinetics/belt/transport/BeltFunnelInteractionHandler.java b/src/main/java/com/simibubi/create/content/kinetics/belt/transport/BeltFunnelInteractionHandler.java index db37e8afb..3b214e46e 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/belt/transport/BeltFunnelInteractionHandler.java +++ b/src/main/java/com/simibubi/create/content/kinetics/belt/transport/BeltFunnelInteractionHandler.java @@ -45,7 +45,6 @@ public class BeltFunnelInteractionHandler { float funnelEntry = segment + .5f; if (funnelState.getValue(BeltFunnelBlock.SHAPE) == Shape.EXTENDED) funnelEntry += .499f * (beltMovementPositive ? -1 : 1); - boolean hasCrossed = nextOffset > funnelEntry && beltMovementPositive || nextOffset < funnelEntry && !beltMovementPositive; if (!hasCrossed) @@ -73,9 +72,12 @@ public class BeltFunnelInteractionHandler { else continue; + if(beltInventory.belt.invVersionTracker.stillWaiting(inserting)) + continue; + int amountToExtract = funnelBE.getAmountToExtract(); ExtractionCountMode modeToExtract = funnelBE.getModeToExtract(); - + ItemStack toInsert = currentItem.stack.copy(); if (amountToExtract > toInsert.getCount() && modeToExtract != ExtractionCountMode.UPTO) if (blocking) @@ -92,14 +94,18 @@ public class BeltFunnelInteractionHandler { return true; else continue; + else + beltInventory.belt.invVersionTracker.awaitNewVersion(inserting); } ItemStack remainder = inserting.insert(toInsert); - if (toInsert.equals(remainder, false)) + if (toInsert.equals(remainder, false)) { + beltInventory.belt.invVersionTracker.awaitNewVersion(inserting); if (blocking) return true; else continue; + } int notFilled = currentItem.stack.getCount() - toInsert.getCount(); if (!remainder.isEmpty()) {