From 3ed3fe5a09020496407c7b678d8ab45cf0736a25 Mon Sep 17 00:00:00 2001 From: EdrowsLuo <793971297@qq.com> Date: Tue, 21 Feb 2023 14:59:46 +0800 Subject: [PATCH] Fix crash when SchematicannonTileEntity try to parse state using empty string --- .../schematics/block/SchematicannonTileEntity.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java index d291b9cd7..f07b83f94 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java @@ -155,7 +155,8 @@ public class SchematicannonTileEntity extends SmartTileEntity implements MenuPro schematicProgress = compound.getFloat("Progress"); bookPrintingProgress = compound.getFloat("PaperProgress"); fuelLevel = compound.getFloat("Fuel"); - state = State.valueOf(compound.getString("State")); + String stateString = compound.getString("State"); + state = stateString.isEmpty() ? State.STOPPED : State.valueOf(compound.getString("State")); blocksPlaced = compound.getInt("AmountPlaced"); blocksToPlace = compound.getInt("AmountToPlace"); @@ -458,7 +459,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements MenuPro sendUpdate = true; return; } - + if (printer.isWorldEmpty()) { state = State.STOPPED; statusMsg = "schematicExpired"; @@ -675,10 +676,10 @@ public class SchematicannonTileEntity extends SmartTileEntity implements MenuPro ItemStack paper = inventory.extractItem(BookInput, 1, true); boolean outputFull = inventory.getStackInSlot(BookOutput) .getCount() == inventory.getSlotLimit(BookOutput); - + if (printer.isErrored()) return; - + if (!printer.isLoaded()) { if (!blueprint.isEmpty()) initializePrinter(blueprint); @@ -817,7 +818,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements MenuPro blocksToPlace += printer.markAllBlockRequirements(checklist, level, this::shouldPlace); printer.markAllEntityRequirements(checklist); } - + checklist.gathered.clear(); findInventories(); for (LazyOptional cap : attachedInventories) {