Open fzzyhmstrs opened 5 hours ago
Confirmed that the RegistrySupplier is causing the issues; when I introduce a workaround that provides the Reference
instead of the Supplier, all works as intended.
public static RegistryEntry<StatusEffect> getReference(RegistrySupplier<StatusEffect> input) {
return EFFECT.getRegistrar().getHolder(input.getId());
}
When exiting world or closing game while a player has an active modded status effect registered via Arch API, the game crashes with the following error. MC: 1.21.1 Arch: 13.0.8 Env: Intellij Fabric runClient
looking at the
writeNbt
bit of the stack, it becomes apparent that the MC registry entry codec "validates" by doing an instanceof check.writeNbt -> CODEC -> StatusEffect.ENTRY_CODEC -> getEntryCodec() -> validateReference
RegistrySupplier is not an instance of Reference, so this fails and the game crashes from getOrThrow(). Neoforged seems to get around this issue by holding the underlying
Reference
inside the DeferredHolder, and then passing that delegate into the validation instead of itself. Arch doesn't do this (or anything to avoid this hard instanceof check). I've only tested in fabric, but I would guess this problem would also be in Arch neoforge.