From f4b8409dfcec72ab61c48e019982b83db83fa484 Mon Sep 17 00:00:00 2001 From: Chicken-Bomes Date: Sun, 10 Aug 2014 12:02:35 +1000 Subject: [PATCH] Catch and remove bad mob spawners --- src/codechicken/nei/ItemMobSpawner.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/codechicken/nei/ItemMobSpawner.java b/src/codechicken/nei/ItemMobSpawner.java index 0181af97..410eb61b 100644 --- a/src/codechicken/nei/ItemMobSpawner.java +++ b/src/codechicken/nei/ItemMobSpawner.java @@ -5,6 +5,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.monster.IMob; +import net.minecraft.entity.passive.EntityPig; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; @@ -16,8 +17,10 @@ import net.minecraft.world.World; import net.minecraftforge.client.MinecraftForgeClient; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Map.Entry; public class ItemMobSpawner extends ItemBlock { @@ -84,7 +87,10 @@ public class ItemMobSpawner extends ItemBlock try { e = (EntityLiving) clazz.getConstructor(new Class[]{World.class}).newInstance(world); } catch (Throwable t) { - NEIClientConfig.logger.error("Error creating instance of entity: " + clazz.getName(), t); + if(clazz == null) + NEIClientConfig.logger.error("Null class for entity ("+ID+", "+IDtoNameMap.get(ID)); + else + NEIClientConfig.logger.error("Error creating instance of entity: " + clazz.getName(), t); e = getEntity(idPig); } entityHashMap.put(ID, e); @@ -122,6 +128,12 @@ public class ItemMobSpawner extends ItemBlock } catch (Throwable ignored) { } } + + for(Iterator> it = IDtoNameMap.entrySet().iterator(); it.hasNext();) { + Entry e = it.next(); + if(getEntity(e.getKey()).getClass() == EntityPig.class && !e.getValue().equals("Pig")) + it.remove(); + } } @Override