Skip to content

Commit

Permalink
Smart but stubborn
Browse files Browse the repository at this point in the history
- Fixed powered smart chutes scanning inventories for extractable items / updating their version tracker #6154 #5867 #6770
  • Loading branch information
simibubi committed Aug 6, 2024
1 parent c69716b commit 4d04a16
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ private void findEntities(float itemSpeed) {
// 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);
Expand Down Expand Up @@ -305,7 +305,7 @@ private void spawnParticles(float itemMotion) {
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);
}
Expand Down Expand Up @@ -340,6 +340,8 @@ private void handleInputFromBelow() {
private void handleInput(IItemHandler inv, float startLocation) {
if (inv == null)
return;
if (!canActivate())
return;
if (invVersionTracker.stillWaiting(inv))
return;
Predicate<ItemStack> canAccept = this::canAcceptItem;
Expand All @@ -361,7 +363,7 @@ private boolean handleDownwardOutput(boolean simulate) {
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);
Expand Down Expand Up @@ -417,7 +419,7 @@ private boolean handleDownwardOutput(boolean simulate) {
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())) {
Expand Down Expand Up @@ -492,11 +494,7 @@ protected ExtractionCountMode getExtractionMode() {
return ExtractionCountMode.UPTO;
}

protected boolean canCollectItemsFromBelow() {
return true;
}

protected boolean canOutputItems() {
protected boolean canActivate() {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public SmartChuteBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState s

@Override
protected boolean canAcceptItem(ItemStack stack) {
return super.canAcceptItem(stack) && canCollectItemsFromBelow() && filtering.test(stack);
return super.canAcceptItem(stack) && canActivate() && filtering.test(stack);
}

@Override
Expand All @@ -37,17 +37,11 @@ protected ExtractionCountMode getExtractionMode() {
}

@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<BlockEntityBehaviour> behaviours) {
behaviours.add(filtering =
Expand Down

0 comments on commit 4d04a16

Please sign in to comment.