Skip to content

Commit

Permalink
fix: logistics inserters ignore their enabled/disabled state
Browse files Browse the repository at this point in the history
  • Loading branch information
klikli-dev committed Aug 18, 2024
1 parent 698f371 commit 895426e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ protected boolean isValidInsertTarget(LeafNodeBehaviour<IFluidHandler, @Nullable
this.blockEntity.getBlockState().getValue(BlockStateProperties.FACING);
}

@Override
public boolean enabled() {
return this.enabled;
}

@Override
public void enabled(boolean enabled) {
this.enabled = enabled;
}
Expand Down Expand Up @@ -117,7 +119,7 @@ public void tickServer() {
this.distributor.tick(); //moved from super.tickServer() here because otherwise the distributor keeps moving targets despite not moving items

var insertTarget = this.distributor.target();
if (insertTarget == null)
if (insertTarget == null || !insertTarget.inserter().enabled()) //TODO: this should be improved, disabled targets should be skipped by the distributor
return;

var extractTarget = this.extractTargets.getFirst(); //we only support one target
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ public LogisticsFluidInserterBehaviour(BlockEntity blockEntity) {
super(blockEntity, Capabilities.FluidHandler.BLOCK);
}

@Override
public boolean enabled() {
return this.enabled;
}

@Override
public void enabled(boolean enabled) {
this.enabled = enabled;
this.onEnabledChanged();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ protected boolean isValidInsertTarget(LeafNodeBehaviour<IItemHandler, @Nullable
this.blockEntity.getBlockState().getValue(BlockStateProperties.FACING);
}

@Override
public boolean enabled() {
return this.enabled;
}

@Override
public void enabled(boolean enabled) {
this.enabled = enabled;
}
Expand Down Expand Up @@ -114,7 +116,7 @@ public void tickServer() {
this.distributor.tick(); //moved from super.tickServer() here because otherwise the distributor keeps moving targets despite not moving items

var insertTarget = this.distributor.target();
if (insertTarget == null)
if (insertTarget == null || !insertTarget.inserter().enabled()) //TODO: this should be improved, disabled targets should be skipped by the distributor
return;

var extractTarget = this.extractTargets.getFirst(); //we only support one target
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ public LogisticsItemInserterBehaviour(BlockEntity blockEntity) {
super(blockEntity, Capabilities.ItemHandler.BLOCK);
}

@Override
public boolean enabled() {
return this.enabled;
}

@Override
public void enabled(boolean enabled) {
this.enabled = enabled;
this.onEnabledChanged();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public void filter(Filter filter){
this.filter = filter;
}

public abstract boolean enabled();

public abstract void enabled(boolean enabled);

/**
* Gets the capability type of this node.
*/
Expand Down

0 comments on commit 895426e

Please sign in to comment.