Fix orchestrated crafter transfers, vanilla craft ticks, and ingredient consumption.
Incoming pipes now use the output recipe as their transfer filter. The output pipe ticks the crafter while triggered, reapplies slot locks after GUI edits, and writes the remaining grid so Paper still consumes ingredients when the result is intercepted. Co-authored-by: Cursor <cursoragent@cursor.com>
@@ -11,7 +11,12 @@ import org.bukkit.event.EventHandler;
11
11
import org.bukkit.event.EventPriority;
12
12
import org.bukkit.event.Listener;
13
13
import org.bukkit.event.block.CrafterCraftEvent;
14
import org.bukkit.event.inventory.InventoryClickEvent;
15
import org.bukkit.event.inventory.InventoryCloseEvent;
16
import org.bukkit.event.inventory.InventoryDragEvent;
17
import org.bukkit.event.inventory.InventoryType;
14
18
import org.bukkit.inventory.Inventory;
19
import org.bukkit.inventory.ItemCraftResult;
15
20
import org.bukkit.inventory.ItemStack;
16
21
import org.bukkit.plugin.Plugin;
17
22
@@ -356,14 +361,18 @@ public final class CrafterPipeManager implements Listener {
356
361
if (!validItem(result)) return;
357
362
358
363
boolean routed = routeOutgoing(plugin, network.outgoing, result.clone());
364
if (!routed) {
365
if (network.attemptingCraft) event.setCancelled(true);
366
return;
367
}
368
369
// Paper skips ingredient consumption when the result is empty, so apply
370
// the vanilla remainder ourselves, then suppress the world/front drop.
371
consumeCraftGrid(block);
372
event.setResult(new ItemStack(Material.AIR));
359
373
if (network.attemptingCraft) {
360
if (!routed) {
361
event.setCancelled(true);
362
return;
363
}
364
374
network.craftSucceeded = true;
365
} else if (!routed) {
366
return;
375
network.attemptingCraft = false;
367
376
}
368
377
369
378
if (network.orchestrator != null) {
@@ -372,14 +381,90 @@ public final class CrafterPipeManager implements Listener {
372
381
} else {
373
382
playTransferAnimation(plugin, network.outgoing);
374
383
}
375
event.setCancelled(true);
376
event.setResult(new ItemStack(Material.AIR));
377
384
if (network.outgoing.destBlock != null) {
378
385
OptimizedTransferPlanner.invalidateBlock(plugin, network.outgoing.destBlock);
379
386
}
380
387
OptimizedTransferPlanner.invalidateBlock(plugin, block);
381
388
}
382
389
390
private static void consumeCraftGrid(Block block) {
391
Inventory inventory = HopperStyleEndpoints.inventoryOf(block);
392
if (inventory == null) return;
393
ItemStack[] matrix = new ItemStack[9];
394
for (int slot = 0; slot < 9; slot++) {
395
ItemStack item = inventory.getItem(slot);
396
matrix[slot] = validItem(item) ? item.clone() : null;
397
}
398
ItemCraftResult preview = null;
399
try {
400
preview = Bukkit.craftItemResult(matrix, block.getWorld());
401
if (preview == null || !validItem(preview.getResult())) {
402
ItemStack[] airFilled = new ItemStack[9];
403
for (int slot = 0; slot < 9; slot++) {
404
airFilled[slot] = matrix[slot] == null ? new ItemStack(Material.AIR) : matrix[slot];
405
}
406
preview = Bukkit.craftItemResult(airFilled, block.getWorld());
407
}
408
} catch (Throwable ignored) {}
409
410
ItemStack[] remaining = preview == null ? null : preview.getResultingMatrix();
411
if (remaining != null) {
412
int limit = Math.min(9, inventory.getSize());
413
for (int slot = 0; slot < limit; slot++) {
414
ItemStack item = slot < remaining.length ? remaining[slot] : null;
415
inventory.setItem(slot, validItem(item) ? item.clone() : null);
416
}
417
return;
418
}
419
420
int limit = Math.min(9, inventory.getSize());
421
for (int slot = 0; slot < limit; slot++) {
422
ItemStack have = inventory.getItem(slot);
423
if (!validItem(have)) continue;
424
ItemStack leftover = craftingRemainder(have);
425
if (have.getAmount() <= 1) inventory.setItem(slot, leftover);
426
else {
427
ItemStack reduced = have.clone();
428
reduced.setAmount(have.getAmount() - 1);
429
inventory.setItem(slot, reduced);
430
}
431
}
432
}
433
434
private static ItemStack craftingRemainder(ItemStack item) {
435
Material remainder = item.getType().getCraftingRemainingItem();
436
if (remainder == null || remainder.isAir()) return null;
437
return new ItemStack(remainder, 1);
438
}
439
440
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
441
public void onCrafterClick(InventoryClickEvent event) {
442
scheduleSlotLockRepair(event.getInventory());
443
}
444
445
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
446
public void onCrafterDrag(InventoryDragEvent event) {
447
scheduleSlotLockRepair(event.getInventory());
448
}
449
450
@EventHandler(priority = EventPriority.MONITOR)
451
public void onCrafterClose(InventoryCloseEvent event) {
452
scheduleSlotLockRepair(event.getInventory());
453
}
454
455
private static void scheduleSlotLockRepair(Inventory inventory) {
456
if (plugin == null || inventory == null || inventory.getType() != InventoryType.CRAFTER) return;
457
var location = inventory.getLocation();
458
if (location == null || location.getWorld() == null) return;
459
Block block = location.getBlock();
460
Network network = networkAt(block);
461
if (network == null || network.orchestrator == null) return;
462
Bukkit.getScheduler().runTask(plugin, () -> {
463
Network live = networkAt(block);
464
if (live != null && live.orchestrator != null) applySlotLocksNow(live);
465
});
466
}
467
383
468
private enum RunResult { MOVED, NO_MOVE, CRAFT_FAILED }
384
469
385
470
private static RunResult tryCraft(Object owner, Network network) {
@@ -388,11 +473,9 @@ public final class CrafterPipeManager implements Listener {
388
473
389
474
Block block = world.getBlockAt(network.pos.x, network.pos.y, network.pos.z);
390
475
if (block.getType() != Material.CRAFTER) return RunResult.NO_MOVE;
391
if (isBusy(block)) return RunResult.NO_MOVE;
476
if (isBusy(block) || network.attemptingCraft) return RunResult.NO_MOVE;
392
477
393
if (!Objects.equals(appliedSlotMask.get(network.pos), network.recipeMask)) {
394
applySlotLocksNow(network);
395
}
478
applySlotLocksNow(network);
396
479
397
480
Inventory crafterInv = HopperStyleEndpoints.inventoryOf(block);
398
481
if (crafterInv == null) return RunResult.NO_MOVE;
@@ -401,7 +484,7 @@ public final class CrafterPipeManager implements Listener {
401
484
if (hasJunk(grid, network.recipe)) return RunResult.CRAFT_FAILED;
402
485
if (!gridMatchesRecipe(grid, network.recipe)) return RunResult.NO_MOVE;
403
486
404
return triggerCraft(owner, network, block) ? RunResult.MOVED : RunResult.CRAFT_FAILED;
487
return pulseCraft(network, block) ? RunResult.MOVED : RunResult.NO_MOVE;
405
488
}
406
489
407
490
private static ItemStack[] readGrid(Inventory inventory) {
@@ -442,27 +525,38 @@ public final class CrafterPipeManager implements Listener {
442
525
return true;
443
526
}
444
527
445
private static boolean triggerCraft(Object owner, Network network, Block block) {
528
/**
529
* Vanilla crafter crafts on its scheduled block tick while TRIGGERED is true.
530
* Setting powered/triggered alone does not schedule that tick.
531
*/
532
private static boolean pulseCraft(Network network, Block block) {
533
if (!(block.getBlockData() instanceof org.bukkit.block.data.type.Crafter data)) return false;
446
534
network.attemptingCraft = true;
447
535
network.craftSucceeded = false;
448
536
try {
449
if (block.getBlockData() instanceof org.bukkit.block.data.type.Crafter data) {
450
data.setTriggered(true);
537
if (data.isCrafting()) {
538
data.setCrafting(false);
451
539
block.setBlockData(data, false);
452
540
}
541
data = (org.bukkit.block.data.type.Crafter) block.getBlockData();
542
data.setTriggered(true);
543
block.setBlockData(data, false);
453
544
block.tick();
454
if (block.getBlockData() instanceof org.bukkit.block.data.type.Crafter data) {
455
data.setTriggered(false);
456
block.setBlockData(data, false);
545
if (!network.craftSucceeded && block.getBlockData() instanceof org.bukkit.block.data.type.Crafter still
546
&& still.isCrafting()) {
547
still.setCrafting(false);
548
block.setBlockData(still, false);
549
block.tick();
457
550
}
458
551
return network.craftSucceeded;
459
552
} catch (Throwable ignored) {
460
553
return false;
461
554
} finally {
462
network.attemptingCraft = false;
463
if (network.outgoing != null && network.outgoing.destBlock != null) {
464
OptimizedTransferPlanner.invalidateBlock(owner, network.outgoing.destBlock);
555
if (block.getBlockData() instanceof org.bukkit.block.data.type.Crafter after) {
556
after.setTriggered(false);
557
block.setBlockData(after, false);
465
558
}
559
network.attemptingCraft = false;
466
560
}
467
561
}
468
562
@@ -587,12 +681,18 @@ public final class CrafterPipeManager implements Listener {
587
681
}
588
682
589
683
private static void applySlotLocks(CrafterPos pos, Crafter crafter, int mask) {
590
if (Objects.equals(appliedSlotMask.get(pos), mask)) return;
684
boolean changed = false;
591
685
for (int slot = 0; slot < 9; slot++) {
592
crafter.setSlotDisabled(slot, (mask & (1 << slot)) == 0);
686
boolean disabled = (mask & (1 << slot)) == 0;
687
if (crafter.isSlotDisabled(slot) != disabled) {
688
crafter.setSlotDisabled(slot, disabled);
689
changed = true;
690
}
593
691
}
594
692
appliedSlotMask.put(pos, mask);
595
try { crafter.update(true, false); } catch (Throwable ignored) {}
693
if (changed) {
694
try { crafter.update(true, false); } catch (Throwable ignored) {}
695
}
596
696
}
597
697
598
698
private static Crafter liveCrafter(Block block) {
@@ -11,7 +11,12 @@ import org.bukkit.event.EventHandler;11
import org.bukkit.event.EventPriority;11
import org.bukkit.event.EventPriority;12
import org.bukkit.event.Listener;12
import org.bukkit.event.Listener;13
import org.bukkit.event.block.CrafterCraftEvent;13
import org.bukkit.event.block.CrafterCraftEvent;14
import org.bukkit.event.inventory.InventoryClickEvent;15
import org.bukkit.event.inventory.InventoryCloseEvent;16
import org.bukkit.event.inventory.InventoryDragEvent;17
import org.bukkit.event.inventory.InventoryType;14
import org.bukkit.inventory.Inventory;18
import org.bukkit.inventory.Inventory;19
import org.bukkit.inventory.ItemCraftResult;15
import org.bukkit.inventory.ItemStack;20
import org.bukkit.inventory.ItemStack;16
import org.bukkit.plugin.Plugin;21
import org.bukkit.plugin.Plugin;17
22
@@ -356,14 +361,18 @@ public final class CrafterPipeManager implements Listener {356
if (!validItem(result)) return;361
if (!validItem(result)) return;357
362
358
boolean routed = routeOutgoing(plugin, network.outgoing, result.clone());363
boolean routed = routeOutgoing(plugin, network.outgoing, result.clone());364
if (!routed) {365
if (network.attemptingCraft) event.setCancelled(true);366
return;367
}368
369
// Paper skips ingredient consumption when the result is empty, so apply370
// the vanilla remainder ourselves, then suppress the world/front drop.371
consumeCraftGrid(block);372
event.setResult(new ItemStack(Material.AIR));359
if (network.attemptingCraft) {373
if (network.attemptingCraft) {360
if (!routed) {361
event.setCancelled(true);362
return;363
}364
network.craftSucceeded = true;374
network.craftSucceeded = true;365
} else if (!routed) {375
network.attemptingCraft = false;366
return;367
}376
}368
377
369
if (network.orchestrator != null) {378
if (network.orchestrator != null) {@@ -372,14 +381,90 @@ public final class CrafterPipeManager implements Listener {372
} else {381
} else {373
playTransferAnimation(plugin, network.outgoing);382
playTransferAnimation(plugin, network.outgoing);374
}383
}375
event.setCancelled(true);376
event.setResult(new ItemStack(Material.AIR));377
if (network.outgoing.destBlock != null) {384
if (network.outgoing.destBlock != null) {378
OptimizedTransferPlanner.invalidateBlock(plugin, network.outgoing.destBlock);385
OptimizedTransferPlanner.invalidateBlock(plugin, network.outgoing.destBlock);379
}386
}380
OptimizedTransferPlanner.invalidateBlock(plugin, block);387
OptimizedTransferPlanner.invalidateBlock(plugin, block);381
}388
}382
389
390
private static void consumeCraftGrid(Block block) {391
Inventory inventory = HopperStyleEndpoints.inventoryOf(block);392
if (inventory == null) return;393
ItemStack[] matrix = new ItemStack[9];394
for (int slot = 0; slot < 9; slot++) {395
ItemStack item = inventory.getItem(slot);396
matrix[slot] = validItem(item) ? item.clone() : null;397
}398
ItemCraftResult preview = null;399
try {400
preview = Bukkit.craftItemResult(matrix, block.getWorld());401
if (preview == null || !validItem(preview.getResult())) {402
ItemStack[] airFilled = new ItemStack[9];403
for (int slot = 0; slot < 9; slot++) {404
airFilled[slot] = matrix[slot] == null ? new ItemStack(Material.AIR) : matrix[slot];405
}406
preview = Bukkit.craftItemResult(airFilled, block.getWorld());407
}408
} catch (Throwable ignored) {}409
410
ItemStack[] remaining = preview == null ? null : preview.getResultingMatrix();411
if (remaining != null) {412
int limit = Math.min(9, inventory.getSize());413
for (int slot = 0; slot < limit; slot++) {414
ItemStack item = slot < remaining.length ? remaining[slot] : null;415
inventory.setItem(slot, validItem(item) ? item.clone() : null);416
}417
return;418
}419
420
int limit = Math.min(9, inventory.getSize());421
for (int slot = 0; slot < limit; slot++) {422
ItemStack have = inventory.getItem(slot);423
if (!validItem(have)) continue;424
ItemStack leftover = craftingRemainder(have);425
if (have.getAmount() <= 1) inventory.setItem(slot, leftover);426
else {427
ItemStack reduced = have.clone();428
reduced.setAmount(have.getAmount() - 1);429
inventory.setItem(slot, reduced);430
}431
}432
}433
434
private static ItemStack craftingRemainder(ItemStack item) {435
Material remainder = item.getType().getCraftingRemainingItem();436
if (remainder == null || remainder.isAir()) return null;437
return new ItemStack(remainder, 1);438
}439
440
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)441
public void onCrafterClick(InventoryClickEvent event) {442
scheduleSlotLockRepair(event.getInventory());443
}444
445
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)446
public void onCrafterDrag(InventoryDragEvent event) {447
scheduleSlotLockRepair(event.getInventory());448
}449
450
@EventHandler(priority = EventPriority.MONITOR)451
public void onCrafterClose(InventoryCloseEvent event) {452
scheduleSlotLockRepair(event.getInventory());453
}454
455
private static void scheduleSlotLockRepair(Inventory inventory) {456
if (plugin == null || inventory == null || inventory.getType() != InventoryType.CRAFTER) return;457
var location = inventory.getLocation();458
if (location == null || location.getWorld() == null) return;459
Block block = location.getBlock();460
Network network = networkAt(block);461
if (network == null || network.orchestrator == null) return;462
Bukkit.getScheduler().runTask(plugin, () -> {463
Network live = networkAt(block);464
if (live != null && live.orchestrator != null) applySlotLocksNow(live);465
});466
}467
383
private enum RunResult { MOVED, NO_MOVE, CRAFT_FAILED }468
private enum RunResult { MOVED, NO_MOVE, CRAFT_FAILED }384
469
385
private static RunResult tryCraft(Object owner, Network network) {470
private static RunResult tryCraft(Object owner, Network network) {@@ -388,11 +473,9 @@ public final class CrafterPipeManager implements Listener {388
473
389
Block block = world.getBlockAt(network.pos.x, network.pos.y, network.pos.z);474
Block block = world.getBlockAt(network.pos.x, network.pos.y, network.pos.z);390
if (block.getType() != Material.CRAFTER) return RunResult.NO_MOVE;475
if (block.getType() != Material.CRAFTER) return RunResult.NO_MOVE;391
if (isBusy(block)) return RunResult.NO_MOVE;476
if (isBusy(block) || network.attemptingCraft) return RunResult.NO_MOVE;392
477
393
if (!Objects.equals(appliedSlotMask.get(network.pos), network.recipeMask)) {478
applySlotLocksNow(network);394
applySlotLocksNow(network);395
}396
479
397
Inventory crafterInv = HopperStyleEndpoints.inventoryOf(block);480
Inventory crafterInv = HopperStyleEndpoints.inventoryOf(block);398
if (crafterInv == null) return RunResult.NO_MOVE;481
if (crafterInv == null) return RunResult.NO_MOVE;@@ -401,7 +484,7 @@ public final class CrafterPipeManager implements Listener {401
if (hasJunk(grid, network.recipe)) return RunResult.CRAFT_FAILED;484
if (hasJunk(grid, network.recipe)) return RunResult.CRAFT_FAILED;402
if (!gridMatchesRecipe(grid, network.recipe)) return RunResult.NO_MOVE;485
if (!gridMatchesRecipe(grid, network.recipe)) return RunResult.NO_MOVE;403
486
404
return triggerCraft(owner, network, block) ? RunResult.MOVED : RunResult.CRAFT_FAILED;487
return pulseCraft(network, block) ? RunResult.MOVED : RunResult.NO_MOVE;405
}488
}406
489
407
private static ItemStack[] readGrid(Inventory inventory) {490
private static ItemStack[] readGrid(Inventory inventory) {@@ -442,27 +525,38 @@ public final class CrafterPipeManager implements Listener {442
return true;525
return true;443
}526
}444
527
445
private static boolean triggerCraft(Object owner, Network network, Block block) {528
/**529
* Vanilla crafter crafts on its scheduled block tick while TRIGGERED is true.530
* Setting powered/triggered alone does not schedule that tick.531
*/532
private static boolean pulseCraft(Network network, Block block) {533
if (!(block.getBlockData() instanceof org.bukkit.block.data.type.Crafter data)) return false;446
network.attemptingCraft = true;534
network.attemptingCraft = true;447
network.craftSucceeded = false;535
network.craftSucceeded = false;448
try {536
try {449
if (block.getBlockData() instanceof org.bukkit.block.data.type.Crafter data) {537
if (data.isCrafting()) {450
data.setTriggered(true);538
data.setCrafting(false);451
block.setBlockData(data, false);539
block.setBlockData(data, false);452
}540
}541
data = (org.bukkit.block.data.type.Crafter) block.getBlockData();542
data.setTriggered(true);543
block.setBlockData(data, false);453
block.tick();544
block.tick();454
if (block.getBlockData() instanceof org.bukkit.block.data.type.Crafter data) {545
if (!network.craftSucceeded && block.getBlockData() instanceof org.bukkit.block.data.type.Crafter still455
data.setTriggered(false);546
&& still.isCrafting()) {456
block.setBlockData(data, false);547
still.setCrafting(false);548
block.setBlockData(still, false);549
block.tick();457
}550
}458
return network.craftSucceeded;551
return network.craftSucceeded;459
} catch (Throwable ignored) {552
} catch (Throwable ignored) {460
return false;553
return false;461
} finally {554
} finally {462
network.attemptingCraft = false;555
if (block.getBlockData() instanceof org.bukkit.block.data.type.Crafter after) {463
if (network.outgoing != null && network.outgoing.destBlock != null) {556
after.setTriggered(false);464
OptimizedTransferPlanner.invalidateBlock(owner, network.outgoing.destBlock);557
block.setBlockData(after, false);465
}558
}559
network.attemptingCraft = false;466
}560
}467
}561
}468
562
@@ -587,12 +681,18 @@ public final class CrafterPipeManager implements Listener {587
}681
}588
682
589
private static void applySlotLocks(CrafterPos pos, Crafter crafter, int mask) {683
private static void applySlotLocks(CrafterPos pos, Crafter crafter, int mask) {590
if (Objects.equals(appliedSlotMask.get(pos), mask)) return;684
boolean changed = false;591
for (int slot = 0; slot < 9; slot++) {685
for (int slot = 0; slot < 9; slot++) {592
crafter.setSlotDisabled(slot, (mask & (1 << slot)) == 0);686
boolean disabled = (mask & (1 << slot)) == 0;687
if (crafter.isSlotDisabled(slot) != disabled) {688
crafter.setSlotDisabled(slot, disabled);689
changed = true;690
}593
}691
}594
appliedSlotMask.put(pos, mask);692
appliedSlotMask.put(pos, mask);595
try { crafter.update(true, false); } catch (Throwable ignored) {}693
if (changed) {694
try { crafter.update(true, false); } catch (Throwable ignored) {}695
}596
}696
}597
697
598
private static Crafter liveCrafter(Block block) {698
private static Crafter liveCrafter(Block block) {@@ -696,7 +696,8 @@ public final class OptimizedTransferPlanner {
696
696
697
697
for (ConnectionView connection : filtered) {
698
698
if (stack == null || stack.getAmount() <= 0 || cycleBudget[slot] <= 0) break;
699
if (usedConnections.containsKey(connection.raw) || !connection.filters.contains(type)) continue;
699
if (usedConnections.containsKey(connection.raw)
700
|| !transferFilters(connection).contains(type)) continue;
700
701
TransferResult result = transferCached(connection, stack, cycleDestinations, key);
701
702
if (!result.moved) continue;
702
703
usedConnections.put(connection.raw, Boolean.TRUE);
@@ -965,9 +966,19 @@ public final class OptimizedTransferPlanner {
965
966
}
966
967
}
967
968
968
boolean allowed(ConnectionView connection, ItemStack item, boolean filtered, Set<Material> reserved) {
969
boolean allowed(ConnectionView connection, ItemStack item, boolean filteredPath, Set<Material> reserved) {
969
970
if (item == null || item.getType().isAir() || item.getAmount() <= 0) return false;
970
return filtered ? connection.filters.contains(item.getType()) : !reserved.contains(item.getType());
971
if (filteredPath) return transferFilters(connection).contains(item.getType());
972
return !reserved.contains(item.getType());
973
}
974
975
/** Crafter-bound pipes use the orchestrator recipe, not the connection's own filter list. */
976
EnumSet<Material> transferFilters(ConnectionView connection) {
977
Block destinationBlock = blockAt(connection.destination);
978
EnumSet<Material> crafterRecipe = destinationBlock == null
979
? null : CrafterPipeManager.recipeMaterials(destinationBlock);
980
if (crafterRecipe != null && !crafterRecipe.isEmpty()) return crafterRecipe;
981
return connection.filters;
971
982
}
972
983
973
984
void afterTransfer(ConnectionView connection, Inventory source, Inventory destination) {
@@ -696,7 +696,8 @@ public final class OptimizedTransferPlanner {696
696
697
for (ConnectionView connection : filtered) {697
for (ConnectionView connection : filtered) {698
if (stack == null || stack.getAmount() <= 0 || cycleBudget[slot] <= 0) break;698
if (stack == null || stack.getAmount() <= 0 || cycleBudget[slot] <= 0) break;699
if (usedConnections.containsKey(connection.raw) || !connection.filters.contains(type)) continue;699
if (usedConnections.containsKey(connection.raw)700
|| !transferFilters(connection).contains(type)) continue;700
TransferResult result = transferCached(connection, stack, cycleDestinations, key);701
TransferResult result = transferCached(connection, stack, cycleDestinations, key);701
if (!result.moved) continue;702
if (!result.moved) continue;702
usedConnections.put(connection.raw, Boolean.TRUE);703
usedConnections.put(connection.raw, Boolean.TRUE);@@ -965,9 +966,19 @@ public final class OptimizedTransferPlanner {965
}966
}966
}967
}967
968
968
boolean allowed(ConnectionView connection, ItemStack item, boolean filtered, Set<Material> reserved) {969
boolean allowed(ConnectionView connection, ItemStack item, boolean filteredPath, Set<Material> reserved) {969
if (item == null || item.getType().isAir() || item.getAmount() <= 0) return false;970
if (item == null || item.getType().isAir() || item.getAmount() <= 0) return false;970
return filtered ? connection.filters.contains(item.getType()) : !reserved.contains(item.getType());971
if (filteredPath) return transferFilters(connection).contains(item.getType());972
return !reserved.contains(item.getType());973
}974
975
/** Crafter-bound pipes use the orchestrator recipe, not the connection's own filter list. */976
EnumSet<Material> transferFilters(ConnectionView connection) {977
Block destinationBlock = blockAt(connection.destination);978
EnumSet<Material> crafterRecipe = destinationBlock == null979
? null : CrafterPipeManager.recipeMaterials(destinationBlock);980
if (crafterRecipe != null && !crafterRecipe.isEmpty()) return crafterRecipe;981
return connection.filters;971
}982
}972
983
973
void afterTransfer(ConnectionView connection, Inventory source, Inventory destination) {984
void afterTransfer(ConnectionView connection, Inventory source, Inventory destination) {