Patchouli (Fabric/Quilt)

Patchouli (Fabric/Quilt)

25M Downloads

Leaving off `name` in a BookEntry will NPE in random places, should probably be validated somewhere

quat1024 opened this issue ยท 2 comments

commented

Mod loader

Fabric

Minecraft version

1.18.1

Patchouli version

1.18.1-64-FABRIC

Modloader version

Fabric Loader 0.12.11 / fabric 0.44.0+1.18

Modpack info

Incorporeal dev instance

The latest.log file

https://paste.ee/p/lSEfv

Issue description

If you leave off name in an entry's json, the game will unceremoniously NPE in random places when operating on it.

In the linked paste.ee, I crashed the game by opening the Entry Index while there were two entries with the same sortnum with one missing a name:

return sort == 0 ? this.getName().getString().compareTo(o.getName().getString()) : sort;

If it doesn't happen there, it'll probably NPE here when trying to draw a button to the screen:

name = entry.getName();
if (entry.isPriority()) {
name = name.withStyle(ChatFormatting.ITALIC);
}
}
name = name.withStyle(entry.getBook().getFontStyle());

Steps to reproduce

  1. Write an entry json that doesn't include "name"
  2. Game explodes much later than it should

Other information

I would prefer if this failed-fast, possibly by failing to load the entry, or warning in the console while replacing the name with "unnamed" or something.

Workspace where i ran in to this: quat1024/incorporeal-3@428dcc2

commented

Related: #291

commented

Lots more validation is being done now on load