Compare commits

..
2 changed files with 13 additions and 38 deletions

No files matched your search

@@ -1,6 +1,5 @@
package codechicken.nei;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -77,49 +76,26 @@ public class ItemMobSpawner extends ItemBlock {
meta = idPig;
}
Entity e = getEntity(meta);
if (e != null) {
list.add(
(e instanceof IMob ? EnumChatFormatting.DARK_RED : EnumChatFormatting.DARK_AQUA)
+ IDtoNameMap.get(meta));
}
list.add(
(e instanceof IMob ? EnumChatFormatting.DARK_RED : EnumChatFormatting.DARK_AQUA)
+ IDtoNameMap.get(meta));
}
public static EntityLiving getEntity(int ID) {
EntityLiving e = entityHashMap.get(ID);
if (e == null) {
loadSpawners();
Class<?> clazz = (Class<?>) EntityList.IDtoClassMapping.get(ID);
World world = NEIClientUtils.mc() != null ? NEIClientUtils.mc().theWorld : null;
if (clazz != null) {
int modifiers = clazz.getModifiers();
if (Modifier.isAbstract(modifiers) || Modifier.isInterface(modifiers)) {
NEIClientConfig.logger.warn("Skipping abstract entity class: " + clazz.getName());
e = getEntity(idPig);
if (e != null) {
entityHashMap.put(ID, e);
}
return e;
}
}
Class<?> clazz = EntityList.IDtoClassMapping.get(ID);
World world = NEIClientUtils.mc().theWorld;
try {
if (clazz != null && world != null) {
e = (EntityLiving) clazz.getConstructor(new Class[] { World.class }).newInstance(world);
} else {
e = getEntity(idPig);
}
e = (EntityLiving) clazz.getConstructor(new Class[] { World.class }).newInstance(world);
} catch (Throwable t) {
if (clazz == null) {
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);
}
else NEIClientConfig.logger.error("Error creating instance of entity: " + clazz.getName(), t);
e = getEntity(idPig);
}
if (e != null) {
entityHashMap.put(ID, e);
}
entityHashMap.put(ID, e);
}
return e;
}
@@ -135,13 +111,12 @@ public class ItemMobSpawner extends ItemBlock {
public static void loadSpawners() {
if (loaded) return;
loaded = true;
for (Object entry : EntityList.classToStringMapping.entrySet()) {
Map.Entry<Class<? extends Entity>, String> mapEntry = (Map.Entry<Class<? extends Entity>, String>) entry;
final Class<? extends Entity> clazz = mapEntry.getKey();
for (Map.Entry<Class<? extends Entity>, String> entry : EntityList.classToStringMapping.entrySet()) {
final Class<? extends Entity> clazz = entry.getKey();
if (EntityLiving.class.isAssignableFrom(clazz)) {
Integer id = (Integer) EntityList.classToIDMapping.get(clazz);
if (id == null) continue;
String name = mapEntry.getValue();
String name = entry.getValue();
if (name == null) continue;
if (name.equals("EnderDragon")) continue;
if (name.equals("Pig")) idPig = id;
@@ -331,7 +331,7 @@ public class SearchField extends TextField implements ItemFilterProvider {
text = text.replaceAll("\"", "\\\\$0");
} else {
String prefixes = searchParser.getPrefixes();
text = text.replaceAll("[-<>^{}|/\\\\\"" + prefixes + "]", "\\\\$0");
text = text.replaceAll("[-<>^{}|/\\\\\"" + Pattern.quote(prefixes) + "]", "\\\\$0");
}
break;
default: