NPE when returning a SleepFailureReason with null message
alkyaly opened this issue ยท 2 comments
This is not a Fabric API bug per se, it can happen in vanilla with a special dimension datapack, but with the introduction of EntitySleepEvents.ALLOW_SLEEPING
this can occur several times.
It can be replicated with:
EntitySleepEvents.ALLOW_SLEEPING.register((player, pos) -> PlayerEntity.SleepFailureReason.OTHER_PROBLEM);
then clicking a bed block at night in the Overworld.
Log (Warn: Mojang Official Mappings): https://gist.github.com/alkyaly/5c6207833bb8315340d158643349b7ca
BedBlock#onUse never null checks for a SFR text, passing null to PlayerEntity#sendMessage.
This could be easily solved with a injection inside the onUse lambda:
(Warn: Mojang Official Mappings): https://github.com/alkyaly/Somnia-Fabric/blob/1.17-Fabric/src/main/java/io/github/alkyaly/somnia/mixin/BedBlockMixin.java#L29-L35
Having the mixin in Fabric API would avoid duplicated code within mods that depend on that event.
Vanilla issue for this is MC-235035.
Vanilla issue for this is MC-235035.
Thanks, I added that to the fix comment in #1681.