mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-15 01:34:42 +00:00
Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a543ae2be | ||
|
|
af3da58f93 | ||
|
|
74e0212ed9 | ||
|
|
0d3f7f3acc | ||
|
|
4f5776af5c | ||
|
|
8a13af1969 | ||
|
|
d6d50a968d | ||
|
|
43459d4b41 | ||
|
|
9b84ea7804 | ||
|
|
de42a43b2c | ||
|
|
b89734f3e6 |
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -76,26 +77,49 @@ public class ItemMobSpawner extends ItemBlock {
|
||||
meta = idPig;
|
||||
}
|
||||
Entity e = getEntity(meta);
|
||||
list.add(
|
||||
(e instanceof IMob ? EnumChatFormatting.DARK_RED : EnumChatFormatting.DARK_AQUA)
|
||||
+ IDtoNameMap.get(meta));
|
||||
if (e != null) {
|
||||
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 = EntityList.IDtoClassMapping.get(ID);
|
||||
World world = NEIClientUtils.mc().theWorld;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
e = (EntityLiving) clazz.getConstructor(new Class[] { World.class }).newInstance(world);
|
||||
if (clazz != null && world != null) {
|
||||
e = (EntityLiving) clazz.getConstructor(new Class[] { World.class }).newInstance(world);
|
||||
} else {
|
||||
e = getEntity(idPig);
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
entityHashMap.put(ID, e);
|
||||
if (e != null) {
|
||||
entityHashMap.put(ID, e);
|
||||
}
|
||||
}
|
||||
return e;
|
||||
}
|
||||
@@ -111,12 +135,13 @@ public class ItemMobSpawner extends ItemBlock {
|
||||
public static void loadSpawners() {
|
||||
if (loaded) return;
|
||||
loaded = true;
|
||||
for (Map.Entry<Class<? extends Entity>, String> entry : EntityList.classToStringMapping.entrySet()) {
|
||||
final Class<? extends Entity> clazz = entry.getKey();
|
||||
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();
|
||||
if (EntityLiving.class.isAssignableFrom(clazz)) {
|
||||
Integer id = (Integer) EntityList.classToIDMapping.get(clazz);
|
||||
if (id == null) continue;
|
||||
String name = entry.getValue();
|
||||
String name = mapEntry.getValue();
|
||||
if (name == null) continue;
|
||||
if (name.equals("EnderDragon")) continue;
|
||||
if (name.equals("Pig")) idPig = id;
|
||||
|
||||
@@ -104,7 +104,7 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
public static Button delete;
|
||||
public static ButtonCycled gamemode;
|
||||
public static Button rain;
|
||||
public static Button magnet;
|
||||
public static ButtonCycled magnet;
|
||||
public static Button[] timeButtons = new Button[4];
|
||||
public static Button heal;
|
||||
|
||||
@@ -600,7 +600,7 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
return getStateTip("rain", state);
|
||||
}
|
||||
};
|
||||
magnet = new Button() {
|
||||
magnet = new ButtonCycled(2) {
|
||||
|
||||
@Override
|
||||
public boolean onButtonPress(boolean rightclick) {
|
||||
|
||||
@@ -31,7 +31,8 @@ public class LayoutStyleMinecraft extends LayoutStyle {
|
||||
LayoutManager.gamemode.icons[0] = new Image(132, 12, 12, 12);
|
||||
LayoutManager.gamemode.icons[1] = new Image(156, 12, 12, 12);
|
||||
LayoutManager.gamemode.icons[2] = new Image(168, 12, 12, 12);
|
||||
LayoutManager.magnet.icon = new Image(180, 24, 12, 12);
|
||||
LayoutManager.magnet.icons[0] = new Image(180, 24, 12, 12);
|
||||
LayoutManager.magnet.icons[1] = new Image(180, 36, 12, 12);
|
||||
LayoutManager.timeButtons[0].icon = new Image(132, 24, 12, 12);
|
||||
LayoutManager.timeButtons[1].icon = new Image(120, 24, 12, 12);
|
||||
LayoutManager.timeButtons[2].icon = new Image(144, 24, 12, 12);
|
||||
@@ -86,6 +87,7 @@ public class LayoutStyleMinecraft extends LayoutStyle {
|
||||
LayoutManager.options.index = NEIClientConfig.getCheatMode();
|
||||
|
||||
LayoutManager.magnet.state = 0x4 | (NEIClientConfig.getMagnetMode() ? 1 : 0);
|
||||
LayoutManager.magnet.index = (LayoutManager.magnet.state & 0x1) != 0 ? 1 : 0;
|
||||
|
||||
if (NEIClientConfig.canPerformAction("delete")) {
|
||||
layoutButton(LayoutManager.delete);
|
||||
|
||||
@@ -315,6 +315,9 @@ public class SearchField extends TextField implements ItemFilterProvider {
|
||||
public static String getEscapedSearchText(String text) {
|
||||
text = EnumChatFormatting.getTextWithoutFormattingCodes(text);
|
||||
|
||||
boolean addQuotes = text.contains(" ")
|
||||
&& NEIClientConfig.getBooleanSetting("inventory.search.quoteDropItemName");
|
||||
|
||||
switch (NEIClientConfig.getIntSetting("inventory.search.patternMode")) {
|
||||
case 1:
|
||||
text = text.replaceAll("[\\?|\\*]", "\\\\$0");
|
||||
@@ -323,14 +326,19 @@ public class SearchField extends TextField implements ItemFilterProvider {
|
||||
text = text.replaceAll("[{}()\\[\\].+*?^$\\\\|]", "\\\\$0");
|
||||
break;
|
||||
case 3:
|
||||
text = text.replaceAll("\"", "\\\\$0");
|
||||
text = "\"" + text + "\"";
|
||||
return text;
|
||||
// In extended+ quotes require only quotes to be escaped
|
||||
if (addQuotes) {
|
||||
text = text.replaceAll("\"", "\\\\$0");
|
||||
} else {
|
||||
String prefixes = searchParser.getPrefixes();
|
||||
text = text.replaceAll("[-<>^{}|/\\\\\"" + prefixes + "]", "\\\\$0");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (text.contains(" ") && NEIClientConfig.getBooleanSetting("inventory.search.quoteDropItemName")) {
|
||||
if (addQuotes) {
|
||||
text = "\"" + text + "\"";
|
||||
}
|
||||
|
||||
|
||||
@@ -468,7 +468,7 @@ public class SearchTokenParser {
|
||||
return tokens;
|
||||
}
|
||||
|
||||
private String getPrefixes() {
|
||||
public String getPrefixes() {
|
||||
if (this.prefixes == null) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 32 KiB |
Reference in new issue
Block a user