More Axolotl Variants API

More Axolotl Variants API

13M Downloads

ItemModelShaperMixin may produce NullPointerException

Gekocaretaker opened this issue ยท 0 comments

commented

I was playing on 1.21.1 Fabric, although I assume it also effects 1.21 with how similar the two versions are.

In the mavapi$getBucketModel method, the line that calls copyTag() on the CustomData returns null in certain instances. I found the bug happens in the advancement screen, and either causes the game to crash completely or just freeze.

I decided to make a quick fix, replacing the CompoundTag nbt = ... and Axolotl.Variant variant = ... lines with this:

CustomData stackData = stack.get(DataComponents.BUCKET_ENTITY_DATA);
Axolotl.Variant variant;
if (stackData != null) {
	CompoundTag nbt = stackData.copyTag();
	variant = AxolotlRegistry.loadVariant(nbt.getInt(Axolotl.VARIANT_TAG), nbt);
} else {
	variant = Axolotl.Variant.LUCY;
}

Which makes it have a fallback, just in case the stack does not have the bucket entity data tag like in the advancement screen.