Create

Create

86M Downloads

Schematicannon infinitely reloading schematic causing watchdog crash. (Potential Fix Included)

JensenJ opened this issue ยท 0 comments

commented

Describe the Bug

Hi there,
I was playing around with schematics and seeing how far away you could have the schematicannon and the actual placed schematic. The whole area was chunk loaded so that was of no concern. I noticed that when I exceeded the max defined range the TPS of the world would drastically drop and with large schematics can actually crash from a watchdog error. I ran a spark profile and it showed a large amount of the tick being used up by loading the schematic which shouldn't happen every tick. A screenshot is provided here in case the spark profile expires.
image

Reason this seems to happen:
It seems that if the schematicannon is out of range as shown here

if (!printer.getAnchor()
.closerThan(getBlockPos(), MAX_ANCHOR_DISTANCE)) {
state = State.STOPPED;
statusMsg = "targetOutsideRange";
printer.resetSchematic();
sendUpdate = true;
return;
}

the schematic is reset, which will then mean the return value of printer.IsLoaded() is false, which means the printer needs to be initialised again (and the schematic loaded with it) here:
if (!printer.isLoaded()) {
if (!blueprint.isEmpty())
initializePrinter(blueprint);
return;
}

I didn't look too much into the code further than this, but I imagine it may be as simple as just not resetting the schematic when this issue occurs, or just preventing it from loading the schematic at all if its out of range. Also a config option for the max range of a schematicannon may be nice to have.

NOTE: Although the bug originated on Fabric (shown by crash report and spark profile), the code above shows it would happen on Forge and this will have been a bug for a very long time.

Thanks,
Jensen

Reproduction Steps

  1. Get schematic of something (Issue is much more noticeable the larger the schematic)
  2. Place schematic preview into the world
  3. Place schematicannon into world atleast 256 (hardcoded max range) blocks away
  4. Ensure both schematic preview and cannon are chunkloaded (Not sure if this is essential, this is just what I did to be safe)
  5. Place schematic into cannon, do not press anything within the cannon. It should say the schematic is out of range now.
  6. Game will now have reduced TPS and maybe watchdog crash. Run a profiler to confirm.

Expected Result

Schematic to not infinitely try and reload itself if it is out of range of the cannon.

Screenshots and Videos

No response

Crash Report or Log

https://mclo.gs/tqwdVHk

Operating System

Linux (Server running Ubuntu 22.04)

Mod Version

0.5.1f

Minecraft Version

1.20.1

Forge Version

47.2.0

Other Mods

This issue happens without any other mods installed.
However, a large custom modpack was used in original crash report and spark profile. The mods are listed within the report.

Additional Context

No response