From ac4e1ba4d897f0b42aec78068b9b0d07e009efe2 Mon Sep 17 00:00:00 2001 From: screret <68943070+screret@users.noreply.github.com> Date: Tue, 19 Mar 2024 13:50:45 +0200 Subject: [PATCH] fix the large miner crashing when cycling layers fixes #972 --- .../gtceu/common/machine/electric/MinerMachine.java | 5 +---- .../machine/multiblock/electric/LargeMinerMachine.java | 2 +- .../common/machine/trait/miner/LargeMinerLogic.java | 2 +- .../gtceu/common/machine/trait/miner/MinerLogic.java | 10 ++++++---- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/electric/MinerMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/electric/MinerMachine.java index 215f182c28..51cd3feb60 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/electric/MinerMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/electric/MinerMachine.java @@ -15,8 +15,6 @@ 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; @@ -24,7 +22,6 @@ 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; @@ -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)); diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/LargeMinerMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/LargeMinerMachine.java index 669b0a2035..a8d95495ab 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/LargeMinerMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/LargeMinerMachine.java @@ -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")); } diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/trait/miner/LargeMinerLogic.java b/src/main/java/com/gregtechceu/gtceu/common/machine/trait/miner/LargeMinerLogic.java index a5679ab733..8e7362706a 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/trait/miner/LargeMinerLogic.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/trait/miner/LargeMinerLogic.java @@ -86,7 +86,7 @@ public void setChunkMode(boolean isChunkMode) { if (!isWorking()) { this.isChunkMode = isChunkMode; if (!getMachine().isRemote()) { - resetArea(); + resetArea(true); } } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/trait/miner/MinerLogic.java b/src/main/java/com/gregtechceu/gtceu/common/machine/trait/miner/MinerLogic.java index cf6a137267..9fdca615d0 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/trait/miner/MinerLogic.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/trait/miner/MinerLogic.java @@ -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; } @@ -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(); + } } /**