Guard against null element in writeEntityToNBT for wizards and evil wizards, fixes #491

This commit is contained in:
Electroblob77
2020-12-20 23:24:30 +00:00
parent 24a06e0bac
commit 32e92b4b04
2 changed files with 4 additions and 2 deletions
@@ -278,7 +278,8 @@ public class EntityEvilWizard extends EntityMob implements ISpellCaster, IEntity
@Override
public void writeEntityToNBT(NBTTagCompound nbt){
super.writeEntityToNBT(nbt);
nbt.setInteger("element", this.getElement().ordinal());
Element element = this.getElement();
nbt.setInteger("element", element == null ? 0 : element.ordinal());
nbt.setInteger("skin", this.textureIndex);
NBTExtras.storeTagSafely(nbt, "spells", NBTExtras.listToNBT(spells, spell -> new NBTTagInt(spell.metadata())));
nbt.setBoolean("hasStructure", this.hasStructure);