Repeat offender

- Crashes that occur during schematic loading no longer terminate the server
- Fixed crash when creating new belts at existing chutes/funnels
- Fixed ghost items appearing on non-powered belts when extracted from
This commit is contained in:
simibubi 2023-01-24 15:29:59 +01:00
parent 6606a07d44
commit 9ab3b77294
12 changed files with 67 additions and 10 deletions

View file

@ -4,7 +4,7 @@ org.gradle.jvmargs = -Xmx3G
org.gradle.daemon = false org.gradle.daemon = false
# mod version info # mod version info
mod_version = 0.5.0.h mod_version = 0.5.0.i
artifact_minecraft_version = 1.18.2 artifact_minecraft_version = 1.18.2
minecraft_version = 1.18.2 minecraft_version = 1.18.2

View file

@ -559,7 +559,7 @@ bf2b0310500213ff853c748c236eb5d01f61658e assets/create/blockstates/yellow_toolbo
7f39521b211441f5c3e06d60c5978cebe16cacfb assets/create/blockstates/zinc_block.json 7f39521b211441f5c3e06d60c5978cebe16cacfb assets/create/blockstates/zinc_block.json
b7181bcd8182b2f17088e5aa881f374c9c65470c assets/create/blockstates/zinc_ore.json b7181bcd8182b2f17088e5aa881f374c9c65470c assets/create/blockstates/zinc_ore.json
f85edc574ee6de0de7693ffb031266643db6724a assets/create/lang/en_ud.json f85edc574ee6de0de7693ffb031266643db6724a assets/create/lang/en_ud.json
c219c77242e645f32704201dd80e279b3759b794 assets/create/lang/en_us.json 7e9712249a13bd4760d58e041473487ada1326ba assets/create/lang/en_us.json
487a511a01b2a4531fb672f917922312db78f958 assets/create/models/block/acacia_window.json 487a511a01b2a4531fb672f917922312db78f958 assets/create/models/block/acacia_window.json
b48060cba1a382f373a05bf0039054053eccf076 assets/create/models/block/acacia_window_pane_noside.json b48060cba1a382f373a05bf0039054053eccf076 assets/create/models/block/acacia_window_pane_noside.json
3066db1bf03cffa1a9c7fbacf47ae586632f4eb3 assets/create/models/block/acacia_window_pane_noside_alt.json 3066db1bf03cffa1a9c7fbacf47ae586632f4eb3 assets/create/models/block/acacia_window_pane_noside_alt.json

View file

@ -1119,6 +1119,7 @@
"create.schematicAndQuill.saved": "Saved as %1$s", "create.schematicAndQuill.saved": "Saved as %1$s",
"create.schematic.invalid": "[!] Invalid Item - Use the Schematic Table instead", "create.schematic.invalid": "[!] Invalid Item - Use the Schematic Table instead",
"create.schematic.error": "Schematic failed to Load - Check Game Logs",
"create.schematic.position": "Position", "create.schematic.position": "Position",
"create.schematic.rotation": "Rotation", "create.schematic.rotation": "Rotation",
"create.schematic.rotation.none": "None", "create.schematic.rotation.none": "None",
@ -1212,6 +1213,8 @@
"create.schematicannon.status.schematicInvalid": "Schematic Invalid", "create.schematicannon.status.schematicInvalid": "Schematic Invalid",
"create.schematicannon.status.schematicNotPlaced": "Schematic not Positioned", "create.schematicannon.status.schematicNotPlaced": "Schematic not Positioned",
"create.schematicannon.status.schematicExpired": "Schematic File Expired", "create.schematicannon.status.schematicExpired": "Schematic File Expired",
"create.schematicannon.status.schematicErrored": "Incompatible Blocks",
"create.schematicannon.status.schematicErroredCheckLogs": "Check Server Logs",
"create.materialChecklist": "Material Checklist", "create.materialChecklist": "Material Checklist",
"create.materialChecklist.blocksNotLoaded": "* Disclaimer *\n\nMaterial List may be inaccurate due to relevant chunks not being loaded.", "create.materialChecklist.blocksNotLoaded": "* Disclaimer *\n\nMaterial List may be inaccurate due to relevant chunks not being loaded.",

View file

@ -67,7 +67,7 @@ public class Create {
public static final String ID = "create"; public static final String ID = "create";
public static final String NAME = "Create"; public static final String NAME = "Create";
public static final String VERSION = "0.5h"; public static final String VERSION = "0.5i";
public static final Logger LOGGER = LogUtils.getLogger(); public static final Logger LOGGER = LogUtils.getLogger();

View file

@ -169,6 +169,8 @@ public class BeltTileEntity extends KineticTileEntity {
protected void initializeItemHandler() { protected void initializeItemHandler() {
if (level.isClientSide || itemHandler.isPresent()) if (level.isClientSide || itemHandler.isPresent())
return; return;
if (beltLength == 0 || controller == null)
return;
if (!level.isLoaded(controller)) if (!level.isLoaded(controller))
return; return;
BlockEntity te = level.getBlockEntity(controller); BlockEntity te = level.getBlockEntity(controller);

View file

@ -52,6 +52,8 @@ public class ItemHandlerBeltSegment implements IItemHandler {
amount = Math.min(amount, transported.stack.getCount()); amount = Math.min(amount, transported.stack.getCount());
ItemStack extracted = simulate ? transported.stack.copy().split(amount) : transported.stack.split(amount); ItemStack extracted = simulate ? transported.stack.copy().split(amount) : transported.stack.split(amount);
if (!simulate) { if (!simulate) {
if (transported.stack.isEmpty())
this.beltInventory.toRemove.add(transported);
this.beltInventory.belt.setChanged(); this.beltInventory.belt.setChanged();
this.beltInventory.belt.sendData(); this.beltInventory.belt.sendData();
} }

View file

@ -5,6 +5,7 @@ import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.Create;
import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementChecks; import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementChecks;
import com.simibubi.create.content.contraptions.components.structureMovement.StructureTransform; import com.simibubi.create.content.contraptions.components.structureMovement.StructureTransform;
import com.simibubi.create.content.schematics.item.SchematicItem; import com.simibubi.create.content.schematics.item.SchematicItem;
@ -37,6 +38,7 @@ public class SchematicPrinter {
} }
private boolean schematicLoaded; private boolean schematicLoaded;
private boolean isErrored;
private SchematicWorld blockReader; private SchematicWorld blockReader;
private BlockPos schematicAnchor; private BlockPos schematicAnchor;
@ -93,7 +95,16 @@ public class SchematicPrinter {
schematicAnchor = NbtUtils.readBlockPos(blueprint.getTag() schematicAnchor = NbtUtils.readBlockPos(blueprint.getTag()
.getCompound("Anchor")); .getCompound("Anchor"));
blockReader = new SchematicWorld(schematicAnchor, originalWorld); blockReader = new SchematicWorld(schematicAnchor, originalWorld);
activeTemplate.placeInWorld(blockReader, schematicAnchor, schematicAnchor, settings, blockReader.getRandom(), Block.UPDATE_CLIENTS);
try {
activeTemplate.placeInWorld(blockReader, schematicAnchor, schematicAnchor, settings,
blockReader.getRandom(), Block.UPDATE_CLIENTS);
} catch (Exception e) {
Create.LOGGER.error("Failed to load Schematic for Printing", e);
schematicLoaded = true;
isErrored = true;
return;
}
BlockPos extraBounds = StructureTemplate.calculateRelativePosition(settings, new BlockPos(activeTemplate.getSize()) BlockPos extraBounds = StructureTemplate.calculateRelativePosition(settings, new BlockPos(activeTemplate.getSize())
.offset(-1, -1, -1)); .offset(-1, -1, -1));
@ -115,6 +126,7 @@ public class SchematicPrinter {
public void resetSchematic() { public void resetSchematic() {
schematicLoaded = false; schematicLoaded = false;
schematicAnchor = null; schematicAnchor = null;
isErrored = false;
currentPos = null; currentPos = null;
blockReader = null; blockReader = null;
printingEntityIndex = -1; printingEntityIndex = -1;
@ -126,8 +138,12 @@ public class SchematicPrinter {
return schematicLoaded; return schematicLoaded;
} }
public boolean isErrored() {
return isErrored;
}
public BlockPos getCurrentTarget() { public BlockPos getCurrentTarget() {
if (!isLoaded()) if (!isLoaded() || isErrored())
return null; return null;
return schematicAnchor.offset(currentPos); return schematicAnchor.offset(currentPos);
} }

View file

@ -310,6 +310,10 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
} }
font.drawShadow(ms, msg, x + 103 - stringWidth / 2, y + 53, 0xCCDDFF); font.drawShadow(ms, msg, x + 103 - stringWidth / 2, y + 53, 0xCCDDFF);
if ("schematicErrored".equals(te.statusMsg))
font.drawShadow(ms, Lang.translateDirect("schematicannon.status.schematicErroredCheckLogs"),
x + 103 - stringWidth / 2, y + 65, 0xCCDDFF);
} }
protected void renderBlueprintHighlight(PoseStack matrixStack, int x, int y) { protected void renderBlueprintHighlight(PoseStack matrixStack, int x, int y) {

View file

@ -304,7 +304,8 @@ public class SchematicannonTileEntity extends SmartTileEntity implements MenuPro
ItemStack blueprint = inventory.getStackInSlot(0); ItemStack blueprint = inventory.getStackInSlot(0);
blockSkipped = false; blockSkipped = false;
if (blueprint.isEmpty() && !statusMsg.equals("idle")) { if (blueprint.isEmpty() && !statusMsg.equals("idle") && inventory.getStackInSlot(1)
.isEmpty()) {
state = State.STOPPED; state = State.STOPPED;
statusMsg = "idle"; statusMsg = "idle";
sendUpdate = true; sendUpdate = true;
@ -448,12 +449,23 @@ public class SchematicannonTileEntity extends SmartTileEntity implements MenuPro
// Load blocks into reader // Load blocks into reader
printer.loadSchematic(blueprint, level, true); printer.loadSchematic(blueprint, level, true);
if (printer.isErrored()) {
state = State.STOPPED;
statusMsg = "schematicErrored";
inventory.setStackInSlot(0, ItemStack.EMPTY);
inventory.setStackInSlot(1, new ItemStack(AllItems.EMPTY_SCHEMATIC.get()));
printer.resetSchematic();
sendUpdate = true;
return;
}
if (printer.isWorldEmpty()) { if (printer.isWorldEmpty()) {
state = State.STOPPED; state = State.STOPPED;
statusMsg = "schematicExpired"; statusMsg = "schematicExpired";
inventory.setStackInSlot(0, ItemStack.EMPTY); inventory.setStackInSlot(0, ItemStack.EMPTY);
inventory.setStackInSlot(1, new ItemStack(AllItems.EMPTY_SCHEMATIC.get())); inventory.setStackInSlot(1, new ItemStack(AllItems.EMPTY_SCHEMATIC.get()));
printer.resetSchematic(); printer.resetSchematic();
sendUpdate = true;
return; return;
} }
@ -462,6 +474,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements MenuPro
state = State.STOPPED; state = State.STOPPED;
statusMsg = "targetOutsideRange"; statusMsg = "targetOutsideRange";
printer.resetSchematic(); printer.resetSchematic();
sendUpdate = true;
return; return;
} }
@ -663,6 +676,9 @@ public class SchematicannonTileEntity extends SmartTileEntity implements MenuPro
boolean outputFull = inventory.getStackInSlot(BookOutput) boolean outputFull = inventory.getStackInSlot(BookOutput)
.getCount() == inventory.getSlotLimit(BookOutput); .getCount() == inventory.getSlotLimit(BookOutput);
if (printer.isErrored())
return;
if (!printer.isLoaded()) { if (!printer.isLoaded()) {
if (!blueprint.isEmpty()) if (!blueprint.isEmpty())
initializePrinter(blueprint); initializePrinter(blueprint);
@ -796,11 +812,12 @@ public class SchematicannonTileEntity extends SmartTileEntity implements MenuPro
checklist.damageRequired.clear(); checklist.damageRequired.clear();
checklist.blocksNotLoaded = false; checklist.blocksNotLoaded = false;
if (printer.isLoaded()) { if (printer.isLoaded() && !printer.isErrored()) {
blocksToPlace = blocksPlaced; blocksToPlace = blocksPlaced;
blocksToPlace += printer.markAllBlockRequirements(checklist, level, this::shouldPlace); blocksToPlace += printer.markAllBlockRequirements(checklist, level, this::shouldPlace);
printer.markAllEntityRequirements(checklist); printer.markAllEntityRequirements(checklist);
} }
checklist.gathered.clear(); checklist.gathered.clear();
findInventories(); findInventories();
for (LazyOptional<IItemHandler> cap : attachedInventories) { for (LazyOptional<IItemHandler> cap : attachedInventories) {

View file

@ -8,6 +8,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.AllKeys; import com.simibubi.create.AllKeys;
import com.simibubi.create.Create;
import com.simibubi.create.content.contraptions.components.structureMovement.StructureTransform; import com.simibubi.create.content.contraptions.components.structureMovement.StructureTransform;
import com.simibubi.create.content.schematics.SchematicWorld; import com.simibubi.create.content.schematics.SchematicWorld;
import com.simibubi.create.content.schematics.client.tools.Tools; import com.simibubi.create.content.schematics.client.tools.Tools;
@ -18,6 +19,7 @@ import com.simibubi.create.content.schematics.packet.SchematicSyncPacket;
import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.outliner.AABBOutline; import com.simibubi.create.foundation.utility.outliner.AABBOutline;
@ -157,7 +159,15 @@ public class SchematicHandler {
BlockPos pos; BlockPos pos;
pos = BlockPos.ZERO; pos = BlockPos.ZERO;
schematic.placeInWorld(w, pos, pos, placementSettings, w.getRandom(), Block.UPDATE_CLIENTS);
try {
schematic.placeInWorld(w, pos, pos, placementSettings, w.getRandom(), Block.UPDATE_CLIENTS);
} catch (Exception e) {
Minecraft.getInstance().player.displayClientMessage(Lang.translate("schematic.error")
.component(), false);
Create.LOGGER.error("Failed to load Schematic for Previewing", e);
return;
}
placementSettings.setMirror(Mirror.FRONT_BACK); placementSettings.setMirror(Mirror.FRONT_BACK);
pos = BlockPos.ZERO.east(size.getX() - 1); pos = BlockPos.ZERO.east(size.getX() - 1);

View file

@ -39,7 +39,7 @@ public class SchematicPlacePacket extends SimplePacketBase {
Level world = player.getLevel(); Level world = player.getLevel();
SchematicPrinter printer = new SchematicPrinter(); SchematicPrinter printer = new SchematicPrinter();
printer.loadSchematic(stack, world, !player.canUseGameMasterBlocks()); printer.loadSchematic(stack, world, !player.canUseGameMasterBlocks());
if (!printer.isLoaded()) if (!printer.isLoaded() || printer.isErrored())
return; return;
boolean includeAir = AllConfigs.SERVER.schematics.creativePrintIncludesAir.get(); boolean includeAir = AllConfigs.SERVER.schematics.creativePrintIncludesAir.get();

View file

@ -271,6 +271,7 @@
"create.schematicAndQuill.saved": "Saved as %1$s", "create.schematicAndQuill.saved": "Saved as %1$s",
"create.schematic.invalid": "[!] Invalid Item - Use the Schematic Table instead", "create.schematic.invalid": "[!] Invalid Item - Use the Schematic Table instead",
"create.schematic.error": "Schematic failed to Load - Check Game Logs",
"create.schematic.position": "Position", "create.schematic.position": "Position",
"create.schematic.rotation": "Rotation", "create.schematic.rotation": "Rotation",
"create.schematic.rotation.none": "None", "create.schematic.rotation.none": "None",
@ -369,6 +370,8 @@
"create.schematicannon.status.schematicInvalid": "Schematic Invalid", "create.schematicannon.status.schematicInvalid": "Schematic Invalid",
"create.schematicannon.status.schematicNotPlaced": "Schematic not Positioned", "create.schematicannon.status.schematicNotPlaced": "Schematic not Positioned",
"create.schematicannon.status.schematicExpired": "Schematic File Expired", "create.schematicannon.status.schematicExpired": "Schematic File Expired",
"create.schematicannon.status.schematicErrored": "Incompatible Blocks",
"create.schematicannon.status.schematicErroredCheckLogs": "Check Server Logs",
"create.materialChecklist": "Material Checklist", "create.materialChecklist": "Material Checklist",
"create.materialChecklist.blocksNotLoaded": "* Disclaimer *\n\nMaterial List may be inaccurate due to relevant chunks not being loaded.", "create.materialChecklist.blocksNotLoaded": "* Disclaimer *\n\nMaterial List may be inaccurate due to relevant chunks not being loaded.",