Minecraft Comes Alive (MCA)

Minecraft Comes Alive (MCA)

13M Downloads

Crash on villager death by non-entity source

maxanier opened this issue ยท 1 comments

commented

Describe the bug
The game crashes if a child of a player (or a married villager) is killed by a non player/mob caused damage source (fall damage, fire, magic, ...).

In EntityVillagerMCA#onDeath source.getImmediateSource().getName() is called. However, getImmediateSource can be null (for non entity caused sources) and is even annotated nullable.
Therefore the game crashes here:

player.sendMessage(new TextComponentString(Constants.Color.RED + MCA.getLocalizer().localize("notify.childdied", get(VILLAGER_NAME), cause.getImmediateSource().getName())));

or here:
player.sendMessage(new TextComponentString(Constants.Color.RED + MCA.getLocalizer().localize("notify.spousedied", get(VILLAGER_NAME), cause.getImmediateSource().getName())));

Steps to Reproduce
Please include steps we can take to reproduce the bug:

  1. Marry villager or create child
  2. Kill them by fall damage, or fire.

Minecraft Information (please complete all questions entirely):

  • Minecraft Version: 1.12.2
  • Forge Version: 14.23.5.2847
  • MCA Version: 6.0.1

Additional context
Original issue was reported on the MC Forum for my mod Vampirism:
But Vampirism is only involved by calling entity.attackEntityFrom(DamageSource.MAGIC, 1000); which should be absolutely fine.
TeamLapen/Vampirism#531
Crashlog: https://pastebin.com/SnPxvvdZ

commented

can confirm, i have run into this crash as well