From 615dd09e83c7fe70dffa13a4bc551a856e86580d Mon Sep 17 00:00:00 2001 From: Adrian Date: Fri, 5 Jun 2015 16:21:18 +0200 Subject: [PATCH] allow for multiple simultaneous round-robin filter tracking in diamond item pipe --- .../transport/pipes/PipeItemsDiamond.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/common/buildcraft/transport/pipes/PipeItemsDiamond.java b/common/buildcraft/transport/pipes/PipeItemsDiamond.java index 6fd77473..86e665dc 100644 --- a/common/buildcraft/transport/pipes/PipeItemsDiamond.java +++ b/common/buildcraft/transport/pipes/PipeItemsDiamond.java @@ -142,6 +142,25 @@ public class PipeItemsDiamond extends Pipe implements IDiamo return false; } + private void clearDest(PipeEventItem.FindDest event) { + for (ForgeDirection dir : event.destinations) { + if (filters.filterCounts[dir.ordinal()] > 0) { + for (int slot = 0; slot < 9; ++slot) { + int v = dir.ordinal() * 9 + slot; + if ((usedFilters & (1 << v)) == 0) { + continue; + } + + ItemStack filter = getFilters().getStackInSlot(v); + + if (StackHelper.isMatchingItemOrList(filter, event.item.getItemStack())) { + usedFilters ^= 1 << v; + } + } + } + } + } + @PipeEventPriority(priority = -4194304) public void eventHandler(PipeEventItem.FindDest event) { // We're running last and we can safely assume that nothing else @@ -153,7 +172,7 @@ public class PipeItemsDiamond extends Pipe implements IDiamo } if (usedFilters != 0) { - usedFilters = 0; + clearDest(event); if (findDest(event)) { return; }