mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-29 22:35:06 +01:00
Versioned Inventories for funnel input
(cherry picked from commit c8357b2d6ee6215d5d35ec74dd20f71b829c1811)
This commit is contained in:
parent
f551107e6d
commit
9072693c0e
2 changed files with 12 additions and 3 deletions
|
@ -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.kinetics.belt.transport.TransportedItemStack;
|
||||||
import com.simibubi.create.content.logistics.tunnel.BrassTunnelBlockEntity;
|
import com.simibubi.create.content.logistics.tunnel.BrassTunnelBlockEntity;
|
||||||
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
|
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 com.simibubi.create.foundation.utility.NBTHelper;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.LightTexture;
|
import net.minecraft.client.renderer.LightTexture;
|
||||||
|
@ -73,6 +74,7 @@ public class BeltBlockEntity extends KineticBlockEntity {
|
||||||
protected BlockPos controller;
|
protected BlockPos controller;
|
||||||
protected BeltInventory inventory;
|
protected BeltInventory inventory;
|
||||||
protected LazyOptional<IItemHandler> itemHandler;
|
protected LazyOptional<IItemHandler> itemHandler;
|
||||||
|
public VersionedInventoryTrackerBehaviour invVersionTracker;
|
||||||
|
|
||||||
public CompoundTag trackerUpdateTag;
|
public CompoundTag trackerUpdateTag;
|
||||||
|
|
||||||
|
@ -98,6 +100,7 @@ public class BeltBlockEntity extends KineticBlockEntity {
|
||||||
.setInsertionHandler(this::tryInsertingFromSide).considerOccupiedWhen(this::isOccupied));
|
.setInsertionHandler(this::tryInsertingFromSide).considerOccupiedWhen(this::isOccupied));
|
||||||
behaviours.add(new TransportedItemStackHandlerBehaviour(this, this::applyToAllItems)
|
behaviours.add(new TransportedItemStackHandlerBehaviour(this, this::applyToAllItems)
|
||||||
.withStackPlacement(this::getWorldPositionOf));
|
.withStackPlacement(this::getWorldPositionOf));
|
||||||
|
behaviours.add(invVersionTracker = new VersionedInventoryTrackerBehaviour(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -45,7 +45,6 @@ public class BeltFunnelInteractionHandler {
|
||||||
float funnelEntry = segment + .5f;
|
float funnelEntry = segment + .5f;
|
||||||
if (funnelState.getValue(BeltFunnelBlock.SHAPE) == Shape.EXTENDED)
|
if (funnelState.getValue(BeltFunnelBlock.SHAPE) == Shape.EXTENDED)
|
||||||
funnelEntry += .499f * (beltMovementPositive ? -1 : 1);
|
funnelEntry += .499f * (beltMovementPositive ? -1 : 1);
|
||||||
|
|
||||||
boolean hasCrossed = nextOffset > funnelEntry && beltMovementPositive
|
boolean hasCrossed = nextOffset > funnelEntry && beltMovementPositive
|
||||||
|| nextOffset < funnelEntry && !beltMovementPositive;
|
|| nextOffset < funnelEntry && !beltMovementPositive;
|
||||||
if (!hasCrossed)
|
if (!hasCrossed)
|
||||||
|
@ -73,9 +72,12 @@ public class BeltFunnelInteractionHandler {
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if(beltInventory.belt.invVersionTracker.stillWaiting(inserting))
|
||||||
|
continue;
|
||||||
|
|
||||||
int amountToExtract = funnelBE.getAmountToExtract();
|
int amountToExtract = funnelBE.getAmountToExtract();
|
||||||
ExtractionCountMode modeToExtract = funnelBE.getModeToExtract();
|
ExtractionCountMode modeToExtract = funnelBE.getModeToExtract();
|
||||||
|
|
||||||
ItemStack toInsert = currentItem.stack.copy();
|
ItemStack toInsert = currentItem.stack.copy();
|
||||||
if (amountToExtract > toInsert.getCount() && modeToExtract != ExtractionCountMode.UPTO)
|
if (amountToExtract > toInsert.getCount() && modeToExtract != ExtractionCountMode.UPTO)
|
||||||
if (blocking)
|
if (blocking)
|
||||||
|
@ -92,14 +94,18 @@ public class BeltFunnelInteractionHandler {
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
|
else
|
||||||
|
beltInventory.belt.invVersionTracker.awaitNewVersion(inserting);
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack remainder = inserting.insert(toInsert);
|
ItemStack remainder = inserting.insert(toInsert);
|
||||||
if (toInsert.equals(remainder, false))
|
if (toInsert.equals(remainder, false)) {
|
||||||
|
beltInventory.belt.invVersionTracker.awaitNewVersion(inserting);
|
||||||
if (blocking)
|
if (blocking)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
int notFilled = currentItem.stack.getCount() - toInsert.getCount();
|
int notFilled = currentItem.stack.getCount() - toInsert.getCount();
|
||||||
if (!remainder.isEmpty()) {
|
if (!remainder.isEmpty()) {
|
||||||
|
|
Loading…
Reference in a new issue