Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: newly unpowered smart chutes don't ignore vault version tracker #6770

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public class ChuteBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
ChuteItemHandler itemHandler;
LazyOptional<IItemHandler> lazyHandler;
boolean canPickUpItems;
boolean previouslyPowered;

float bottomPullDistance;
float beltBelowOffset;
Expand All @@ -83,7 +84,7 @@ public class ChuteBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
int entitySearchCooldown;

VersionedInventoryTrackerBehaviour invVersionTracker;

LazyOptional<IItemHandler> capAbove;
LazyOptional<IItemHandler> capBelow;

Expand Down Expand Up @@ -340,8 +341,9 @@ private void handleInputFromBelow() {
private void handleInput(IItemHandler inv, float startLocation) {
if (inv == null)
return;
if (invVersionTracker.stillWaiting(inv))
if (!previouslyPowered && invVersionTracker.stillWaiting(inv))
return;
setPreviouslyPowered(false);
Predicate<ItemStack> canAccept = this::canAcceptItem;
int count = getExtractionAmount();
ExtractionCountMode mode = getExtractionMode();
Expand Down Expand Up @@ -761,6 +763,15 @@ public ItemStack getItem() {
return item;
}

/**
* Sets whether the chute was previously powered, so that we get a tick of skipping invVersionTracker.stillWaiting
* (Only relevant for the smart chute, but the logic that needs it is in here)
* @param previouslyPowered
*/
public void setPreviouslyPowered(boolean previouslyPowered) {
this.previouslyPowered = previouslyPowered;
}

// @Override
// @Nullable
// public AirCurrent getAirCurrent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ public void neighborChanged(BlockState state, Level worldIn, BlockPos pos, Block
@Override
public void tick(BlockState state, ServerLevel worldIn, BlockPos pos, Random r) {
boolean previouslyPowered = state.getValue(POWERED);
if (previouslyPowered != worldIn.hasNeighborSignal(pos))
if (previouslyPowered != worldIn.hasNeighborSignal(pos)) {
worldIn.setBlock(pos, state.cycle(POWERED), 2);
if (previouslyPowered) {
withBlockEntityDo(worldIn, pos, (c) -> c.setPreviouslyPowered(true));
}
}
}

@Override
Expand All @@ -54,7 +58,7 @@ public BlockState getStateForPlacement(BlockPlaceContext p_196258_1_) {
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
return true;
}

@Override
public BlockEntityType<? extends ChuteBlockEntity> getBlockEntityType() {
return AllBlockEntityTypes.SMART_CHUTE.get();
Expand Down