Easy Villagers

Easy Villagers

13M Downloads

NPE logspam

GizmoTheMoonPig opened this issue ยท 0 comments

commented

Having Trader blocks filled with villagers that dont have work sounds (unemployed, nitwit, or even some modded ones) will spam logs with NullPointerExceptions because the work sound is null. Vanilla explicitly says this sound event can be null so it should really be checked before you try to play it.

https://gist.github.com/GizmoTheMoonPig/b0fda9b418b01fceb22b6bfeaec766d3

all you need to do is change this line to check if the villager sound actually exists, perhaps like so:

SoundEvent workSound = villagerEntity.getVillagerData().getProfession().workSound();
if (workSound != null) {
  VillagerBlockBase.playVillagerSound(level, getBlockPos(), workSound);
}

Hope this helps!