Skip to content

Commit

Permalink
Fix that kinetic stress output will never not stop (#1110)
Browse files Browse the repository at this point in the history
* Fix that kinetic stress output will never not stop

* Add onPaused callback which is called when the WorkableMultiblockMachine set workingEnabled to false

* Format code
  • Loading branch information
iamSmallY authored Apr 20, 2024
1 parent 2e0f890 commit 2e5930d
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.gregtechceu.gtceu.api.gui.fancy.TooltipsPanel;
import com.gregtechceu.gtceu.api.machine.feature.IFancyUIMachine;
import com.gregtechceu.gtceu.api.machine.feature.IMachineFeature;
import com.gregtechceu.gtceu.api.machine.multiblock.WorkableMultiblockMachine;
import com.gregtechceu.gtceu.api.machine.trait.IRecipeHandlerTrait;
import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic;
import com.gregtechceu.gtceu.api.recipe.GTRecipe;
Expand Down Expand Up @@ -91,6 +92,13 @@ default boolean onWaiting(IWorkableMultiController controller) {
return true;
}

/**
* Called in {@link WorkableMultiblockMachine#setWorkingEnabled(boolean)}
*/
default boolean onPaused(IWorkableMultiController controller) {
return true;
}

/**
* Called in {@link RecipeLogic#onRecipeFinish()} before outputs are produced
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,16 @@ public void onWaiting() {
IWorkableMultiController.super.onWaiting();
}

@Override
public void setWorkingEnabled(boolean isWorkingAllowed) {
if (!isWorkingAllowed) {
for (IMultiPart part : getParts()) {
part.onPaused(this);
}
}
IWorkableMultiController.super.setWorkingEnabled(isWorkingAllowed);
}

@NotNull
public GTRecipeType getRecipeType() {
return recipeTypes[activeRecipeType];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.gregtechceu.gtceu.api.capability.recipe.IO;
import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity;
import com.gregtechceu.gtceu.api.machine.feature.multiblock.IMultiController;
import com.gregtechceu.gtceu.api.machine.feature.multiblock.IWorkableMultiController;
import com.gregtechceu.gtceu.api.machine.multiblock.part.TieredIOPartMachine;
import com.gregtechceu.gtceu.common.machine.kinetic.IKineticMachine;
import com.gregtechceu.gtceu.common.machine.trait.NotifiableStressTrait;
Expand Down Expand Up @@ -62,6 +64,32 @@ public void onRotated(Direction oldFacing, Direction newFacing) {
}
}

@Override
public boolean onWaiting(IWorkableMultiController controller) {
getKineticHolder().stopWorking();
return super.onWaiting(controller);
}

@Override
public boolean onPaused(IWorkableMultiController controller) {
getKineticHolder().stopWorking();
return super.onPaused(controller);
}

@Override
public void removedFromController(IMultiController controller) {
super.removedFromController(controller);
getKineticHolder().stopWorking();
}

@Override
public void setWorkingEnabled(boolean workingEnabled) {
if (!workingEnabled) {
getKineticHolder().stopWorking();
}
super.setWorkingEnabled(workingEnabled);
}

//////////////////////////////////////
//********* GUI *********//
//////////////////////////////////////
Expand Down

0 comments on commit 2e5930d

Please sign in to comment.