From 4900005e9af9d15442e267657c80df06fcf5e3a5 Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Mon, 25 Sep 2023 10:31:53 +0200 Subject: [PATCH] Fix crash when reanimating mobs without spawn egg, Closes #1005 --- .../spiritreanimator/ReanimateTickAction.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/cyclops/evilcraft/blockentity/tickaction/spiritreanimator/ReanimateTickAction.java b/src/main/java/org/cyclops/evilcraft/blockentity/tickaction/spiritreanimator/ReanimateTickAction.java index ba65e52518..259bb65cff 100644 --- a/src/main/java/org/cyclops/evilcraft/blockentity/tickaction/spiritreanimator/ReanimateTickAction.java +++ b/src/main/java/org/cyclops/evilcraft/blockentity/tickaction/spiritreanimator/ReanimateTickAction.java @@ -3,6 +3,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.EntityType; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.SpawnEggItem; import net.minecraftforge.common.ForgeSpawnEggItem; import net.minecraftforge.fluids.capability.IFluidHandler; import org.apache.commons.lang3.mutable.MutableDouble; @@ -26,10 +27,6 @@ public boolean canTick(BlockEntitySpiritReanimator tile, ItemStack itemStack, in return tile.getTank().getFluidAmount() >= getRequiredMb(tile, tick) && tile.canWork(); } - protected ItemStack getSpawnEgg(EntityType entityType) { - return new ItemStack(ForgeSpawnEggItem.fromEntityType(entityType)); - } - @Override public void onTick(BlockEntitySpiritReanimator tile, ItemStack itemStack, int slot, int tick) { // Drain the tank a bit. @@ -38,7 +35,10 @@ public void onTick(BlockEntitySpiritReanimator tile, ItemStack itemStack, int sl ItemStack spawnEgg = ItemStack.EMPTY; EntityType entityType = tile.getEntityType(); if(entityType != null) { - spawnEgg = getSpawnEgg(entityType); + SpawnEggItem spawnEggItem = ForgeSpawnEggItem.fromEntityType(entityType); + if (spawnEggItem != null) { + spawnEgg = new ItemStack(spawnEggItem); + } } if(!spawnEgg.isEmpty() && addToProduceSlot(tile, spawnEgg)) { tile.getInventory().removeItem(BlockEntitySpiritReanimator.SLOT_EGG, 1);