From 4d04a16fbb47a7fb63e0ad04c29e707d60d83b59 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Tue, 6 Aug 2024 16:42:22 +0200 Subject: [PATCH] Smart but stubborn - Fixed powered smart chutes scanning inventories for extractable items / updating their version tracker #6154 #5867 #6770 --- .../logistics/chute/ChuteBlockEntity.java | 16 +++++++--------- .../logistics/chute/SmartChuteBlockEntity.java | 10 ++-------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/logistics/chute/ChuteBlockEntity.java b/src/main/java/com/simibubi/create/content/logistics/chute/ChuteBlockEntity.java index 673308384..2489910f3 100644 --- a/src/main/java/com/simibubi/create/content/logistics/chute/ChuteBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/chute/ChuteBlockEntity.java @@ -224,7 +224,7 @@ public class ChuteBlockEntity extends SmartBlockEntity implements IHaveGoggleInf // airCurrent.findEntities(); if (bottomPullDistance <= 0 && !getItem().isEmpty() || itemSpeed <= 0 || level == null || level.isClientSide) return; - if (!canCollectItemsFromBelow()) + if (!canActivate()) return; Vec3 center = VecHelper.getCenterOf(worldPosition); AABB searchArea = new AABB(center.add(0, -bottomPullDistance - 0.5, 0), center.add(0, -0.5, 0)).inflate(.45f); @@ -305,7 +305,7 @@ public class ChuteBlockEntity extends SmartBlockEntity implements IHaveGoggleInf if (!up && BlockHelper.noCollisionInSpace(level, worldPosition.below())) spawnAirFlow(0, -1, absMotion, .5f); - if (up && canCollectItemsFromBelow() && bottomPullDistance > 0) { + if (up && canActivate() && bottomPullDistance > 0) { spawnAirFlow(-bottomPullDistance, 0, absMotion, 2); spawnAirFlow(-bottomPullDistance, 0, absMotion, 2); } @@ -340,6 +340,8 @@ public class ChuteBlockEntity extends SmartBlockEntity implements IHaveGoggleInf private void handleInput(IItemHandler inv, float startLocation) { if (inv == null) return; + if (!canActivate()) + return; if (invVersionTracker.stillWaiting(inv)) return; Predicate canAccept = this::canAcceptItem; @@ -361,7 +363,7 @@ public class ChuteBlockEntity extends SmartBlockEntity implements IHaveGoggleInf ChuteBlockEntity targetChute = getTargetChute(blockState); Direction direction = AbstractChuteBlock.getChuteFacing(blockState); - if (level == null || direction == null || !this.canOutputItems()) + if (level == null || direction == null || !this.canActivate()) return false; if (!capBelow.isPresent()) capBelow = grabCapability(Direction.DOWN); @@ -417,7 +419,7 @@ public class ChuteBlockEntity extends SmartBlockEntity implements IHaveGoggleInf private boolean handleUpwardOutput(boolean simulate) { BlockState stateAbove = level.getBlockState(worldPosition.above()); - if (level == null || !this.canOutputItems()) + if (level == null || !this.canActivate()) return false; if (AbstractChuteBlock.isOpenChute(getBlockState())) { @@ -492,11 +494,7 @@ public class ChuteBlockEntity extends SmartBlockEntity implements IHaveGoggleInf return ExtractionCountMode.UPTO; } - protected boolean canCollectItemsFromBelow() { - return true; - } - - protected boolean canOutputItems() { + protected boolean canActivate() { return true; } diff --git a/src/main/java/com/simibubi/create/content/logistics/chute/SmartChuteBlockEntity.java b/src/main/java/com/simibubi/create/content/logistics/chute/SmartChuteBlockEntity.java index 14fbec7ad..1fae21e82 100644 --- a/src/main/java/com/simibubi/create/content/logistics/chute/SmartChuteBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/chute/SmartChuteBlockEntity.java @@ -22,7 +22,7 @@ public class SmartChuteBlockEntity extends ChuteBlockEntity { @Override protected boolean canAcceptItem(ItemStack stack) { - return super.canAcceptItem(stack) && canCollectItemsFromBelow() && filtering.test(stack); + return super.canAcceptItem(stack) && canActivate() && filtering.test(stack); } @Override @@ -37,17 +37,11 @@ public class SmartChuteBlockEntity extends ChuteBlockEntity { } @Override - protected boolean canCollectItemsFromBelow() { + protected boolean canActivate() { BlockState blockState = getBlockState(); return blockState.hasProperty(SmartChuteBlock.POWERED) && !blockState.getValue(SmartChuteBlock.POWERED); } - @Override - protected boolean canOutputItems() { - BlockState blockState = getBlockState(); - return blockState.hasProperty(SmartChuteBlock.POWERED) && !blockState.getValue(SmartChuteBlock.POWERED); - } - @Override public void addBehaviours(List behaviours) { behaviours.add(filtering =