Smart but stubborn

- Fixed powered smart chutes scanning inventories for extractable items / updating their version tracker #6154 #5867 #6770
This commit is contained in:
simibubi 2024-08-06 16:42:22 +02:00
parent c69716bf7e
commit 4d04a16fbb
2 changed files with 9 additions and 17 deletions

View file

@ -224,7 +224,7 @@ public class ChuteBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
// airCurrent.findEntities(); // airCurrent.findEntities();
if (bottomPullDistance <= 0 && !getItem().isEmpty() || itemSpeed <= 0 || level == null || level.isClientSide) if (bottomPullDistance <= 0 && !getItem().isEmpty() || itemSpeed <= 0 || level == null || level.isClientSide)
return; return;
if (!canCollectItemsFromBelow()) if (!canActivate())
return; return;
Vec3 center = VecHelper.getCenterOf(worldPosition); Vec3 center = VecHelper.getCenterOf(worldPosition);
AABB searchArea = new AABB(center.add(0, -bottomPullDistance - 0.5, 0), center.add(0, -0.5, 0)).inflate(.45f); 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())) if (!up && BlockHelper.noCollisionInSpace(level, worldPosition.below()))
spawnAirFlow(0, -1, absMotion, .5f); 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);
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) { private void handleInput(IItemHandler inv, float startLocation) {
if (inv == null) if (inv == null)
return; return;
if (!canActivate())
return;
if (invVersionTracker.stillWaiting(inv)) if (invVersionTracker.stillWaiting(inv))
return; return;
Predicate<ItemStack> canAccept = this::canAcceptItem; Predicate<ItemStack> canAccept = this::canAcceptItem;
@ -361,7 +363,7 @@ public class ChuteBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
ChuteBlockEntity targetChute = getTargetChute(blockState); ChuteBlockEntity targetChute = getTargetChute(blockState);
Direction direction = AbstractChuteBlock.getChuteFacing(blockState); Direction direction = AbstractChuteBlock.getChuteFacing(blockState);
if (level == null || direction == null || !this.canOutputItems()) if (level == null || direction == null || !this.canActivate())
return false; return false;
if (!capBelow.isPresent()) if (!capBelow.isPresent())
capBelow = grabCapability(Direction.DOWN); capBelow = grabCapability(Direction.DOWN);
@ -417,7 +419,7 @@ public class ChuteBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
private boolean handleUpwardOutput(boolean simulate) { private boolean handleUpwardOutput(boolean simulate) {
BlockState stateAbove = level.getBlockState(worldPosition.above()); BlockState stateAbove = level.getBlockState(worldPosition.above());
if (level == null || !this.canOutputItems()) if (level == null || !this.canActivate())
return false; return false;
if (AbstractChuteBlock.isOpenChute(getBlockState())) { if (AbstractChuteBlock.isOpenChute(getBlockState())) {
@ -492,11 +494,7 @@ public class ChuteBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
return ExtractionCountMode.UPTO; return ExtractionCountMode.UPTO;
} }
protected boolean canCollectItemsFromBelow() { protected boolean canActivate() {
return true;
}
protected boolean canOutputItems() {
return true; return true;
} }

View file

@ -22,7 +22,7 @@ public class SmartChuteBlockEntity extends ChuteBlockEntity {
@Override @Override
protected boolean canAcceptItem(ItemStack stack) { protected boolean canAcceptItem(ItemStack stack) {
return super.canAcceptItem(stack) && canCollectItemsFromBelow() && filtering.test(stack); return super.canAcceptItem(stack) && canActivate() && filtering.test(stack);
} }
@Override @Override
@ -37,17 +37,11 @@ public class SmartChuteBlockEntity extends ChuteBlockEntity {
} }
@Override @Override
protected boolean canCollectItemsFromBelow() { protected boolean canActivate() {
BlockState blockState = getBlockState(); BlockState blockState = getBlockState();
return blockState.hasProperty(SmartChuteBlock.POWERED) && !blockState.getValue(SmartChuteBlock.POWERED); 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 @Override
public void addBehaviours(List<BlockEntityBehaviour> behaviours) { public void addBehaviours(List<BlockEntityBehaviour> behaviours) {
behaviours.add(filtering = behaviours.add(filtering =