Skip to content

Commit f8e8c47

Browse files
authored
Merge pull request Creators-of-Create#6285 from JensenJ-Modding/mc1.18/dev
Versioned Inventories for funnel input
2 parents d84a7fa + 66ccb66 commit f8e8c47

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/main/java/com/simibubi/create/content/kinetics/belt/BeltBlockEntity.java

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.simibubi.create.content.kinetics.belt.transport.TransportedItemStack;
3131
import com.simibubi.create.content.logistics.tunnel.BrassTunnelBlockEntity;
3232
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
33+
import com.simibubi.create.foundation.blockEntity.behaviour.inventory.VersionedInventoryTrackerBehaviour;
3334
import com.simibubi.create.foundation.utility.NBTHelper;
3435

3536
import net.minecraft.client.renderer.LightTexture;
@@ -73,6 +74,7 @@ public class BeltBlockEntity extends KineticBlockEntity {
7374
protected BlockPos controller;
7475
protected BeltInventory inventory;
7576
protected LazyOptional<IItemHandler> itemHandler;
77+
public VersionedInventoryTrackerBehaviour invVersionTracker;
7678

7779
public CompoundTag trackerUpdateTag;
7880

@@ -98,6 +100,7 @@ public void addBehaviours(List<BlockEntityBehaviour> behaviours) {
98100
.setInsertionHandler(this::tryInsertingFromSide).considerOccupiedWhen(this::isOccupied));
99101
behaviours.add(new TransportedItemStackHandlerBehaviour(this, this::applyToAllItems)
100102
.withStackPlacement(this::getWorldPositionOf));
103+
behaviours.add(invVersionTracker = new VersionedInventoryTrackerBehaviour(this));
101104
}
102105

103106
@Override

src/main/java/com/simibubi/create/content/kinetics/belt/transport/BeltFunnelInteractionHandler.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public static boolean checkForFunnels(BeltInventory beltInventory, TransportedIt
4545
float funnelEntry = segment + .5f;
4646
if (funnelState.getValue(BeltFunnelBlock.SHAPE) == Shape.EXTENDED)
4747
funnelEntry += .499f * (beltMovementPositive ? -1 : 1);
48-
4948
boolean hasCrossed = nextOffset > funnelEntry && beltMovementPositive
5049
|| nextOffset < funnelEntry && !beltMovementPositive;
5150
if (!hasCrossed)
@@ -73,9 +72,12 @@ public static boolean checkForFunnels(BeltInventory beltInventory, TransportedIt
7372
else
7473
continue;
7574

75+
if(beltInventory.belt.invVersionTracker.stillWaiting(inserting))
76+
continue;
77+
7678
int amountToExtract = funnelBE.getAmountToExtract();
7779
ExtractionCountMode modeToExtract = funnelBE.getModeToExtract();
78-
80+
7981
ItemStack toInsert = currentItem.stack.copy();
8082
if (amountToExtract > toInsert.getCount() && modeToExtract != ExtractionCountMode.UPTO)
8183
if (blocking)
@@ -92,14 +94,18 @@ public static boolean checkForFunnels(BeltInventory beltInventory, TransportedIt
9294
return true;
9395
else
9496
continue;
97+
else
98+
beltInventory.belt.invVersionTracker.awaitNewVersion(inserting);
9599
}
96100

97101
ItemStack remainder = inserting.insert(toInsert);
98-
if (toInsert.equals(remainder, false))
102+
if (toInsert.equals(remainder, false)) {
103+
beltInventory.belt.invVersionTracker.awaitNewVersion(inserting);
99104
if (blocking)
100105
return true;
101106
else
102107
continue;
108+
}
103109

104110
int notFilled = currentItem.stack.getCount() - toInsert.getCount();
105111
if (!remainder.isEmpty()) {

0 commit comments

Comments
 (0)