Skip to content

Commit

Permalink
fix the large miner crashing when cycling layers
Browse files Browse the repository at this point in the history
fixes #972
  • Loading branch information
screret committed Mar 19, 2024
1 parent 96965ef commit ac4e1ba
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@
import com.gregtechceu.gtceu.api.machine.feature.IFancyUIMachine;
import com.gregtechceu.gtceu.api.machine.trait.NotifiableItemStackHandler;
import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic;
import com.gregtechceu.gtceu.api.recipe.GTRecipeType;
import com.gregtechceu.gtceu.api.recipe.ui.GTRecipeTypeUI;
import com.gregtechceu.gtceu.common.data.GTMachines;
import com.gregtechceu.gtceu.common.machine.trait.miner.MinerLogic;
import com.gregtechceu.gtceu.data.lang.LangHandler;
import com.lowdragmc.lowdraglib.gui.widget.ComponentPanelWidget;
import com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup;
import com.lowdragmc.lowdraglib.gui.widget.SlotWidget;
import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup;
import com.lowdragmc.lowdraglib.misc.FluidTransferList;
import com.lowdragmc.lowdraglib.misc.ItemStackTransfer;
import com.lowdragmc.lowdraglib.side.item.ItemTransferHelper;
import com.lowdragmc.lowdraglib.syncdata.ISubscription;
Expand Down Expand Up @@ -323,7 +320,7 @@ else if (playerIn.isCrouching())
else
getRecipeLogic().setCurrentRadius(Math.max(1, currentRadius - 1));

getRecipeLogic().resetArea();
getRecipeLogic().resetArea(true);

int workingArea = IMiner.getWorkingArea(getRecipeLogic().getCurrentRadius());
playerIn.sendSystemMessage(Component.translatable("gtceu.universal.tooltip.working_area", workingArea, workingArea));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public InteractionResult onScrewdriverClick(Player playerIn, InteractionHand han
int workingArea = IMiner.getWorkingArea(getRecipeLogic().getCurrentRadius());
playerIn.sendSystemMessage(Component.translatable("gtceu.universal.tooltip.working_area", workingArea, workingArea));
}
getRecipeLogic().resetArea();
getRecipeLogic().resetArea(true);
} else {
playerIn.sendSystemMessage(Component.translatable("gtceu.multiblock.large_miner.errorradius"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void setChunkMode(boolean isChunkMode) {
if (!isWorking()) {
this.isChunkMode = isChunkMode;
if (!getMachine().isRemote()) {
resetArea();
resetArea(true);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public MinerLogic(@Nonnull IRecipeLogicMachine machine, int fortune, int speed,
@Override
public void resetRecipeLogic() {
super.resetRecipeLogic();
resetArea();
resetArea(false);
this.cachedItemTransfer = null;
this.pipeLength = 0;
}
Expand Down Expand Up @@ -445,12 +445,14 @@ public void checkBlocksToMine() {
/**
* Recalculates the mining area, refills the block list and restarts the miner, if it was done
*/
public void resetArea() {
public void resetArea(boolean checkToMine) {
initPos(getMiningPos(), currentRadius);
if (this.isDone) this.setWorkingEnabled(false);
this.isDone = false;
blocksToMine.clear();
checkBlocksToMine();
if (checkToMine) {
blocksToMine.clear();
checkBlocksToMine();
}
}

/**
Expand Down

0 comments on commit ac4e1ba

Please sign in to comment.