mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-16 18:54:45 +00:00
Compare commits
36
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b32f25c2ce | ||
|
|
4be7a30578 | ||
|
|
7ac3e32635 | ||
|
|
088d37a11a | ||
|
|
6a787dd5b7 | ||
|
|
c305649b95 | ||
|
|
b5d2815eab | ||
|
|
6049d0e9c3 | ||
|
|
9288fc4575 | ||
|
|
ec749ecc8e | ||
|
|
7471a82bca | ||
|
|
3f3c1791cb | ||
|
|
a0e16835c2 | ||
|
|
e9ce5cf72b | ||
|
|
fac011b67e | ||
|
|
f9c8ac504e | ||
|
|
f97711a33a | ||
|
|
b2934c4910 | ||
|
|
759ea69c9f | ||
|
|
36a2cafdac | ||
|
|
6100012f5b | ||
|
|
2e5781beb5 | ||
|
|
43918f3bb1 | ||
|
|
a41299dfca | ||
|
|
ee060b9253 | ||
|
|
82a2273995 | ||
|
|
06fadcc362 | ||
|
|
b328fd3db1 | ||
|
|
9563ebfe5a | ||
|
|
d9143c584e | ||
|
|
65652e5896 | ||
|
|
bd5e991a84 | ||
|
|
165afa2910 | ||
|
|
2507634196 | ||
|
|
e0171adc65 | ||
|
|
72ad8aa2e7 |
No files matched your search
@@ -0,0 +1,62 @@
|
||||
name: Report Bug
|
||||
description: "Report a bug."
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: "A bug/crash report with sufficient information and logs to reproduce and track down."
|
||||
- type: input
|
||||
id: discord
|
||||
attributes:
|
||||
label: Your GTNH Discord Username
|
||||
description: Leave empty if you don't have one, but this will make it harder to contact you if we need additional info.
|
||||
placeholder: "Example: Fake#1234"
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
label: Mod Version
|
||||
description: "What version of the Mod are you using?"
|
||||
placeholder: "Example: 1.0.0"
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: report
|
||||
attributes:
|
||||
label: Bug Report
|
||||
description: "Relevant information, as well as relevant logs attached such as `logs/fml-client-latest.log."
|
||||
placeholder: "Example: https://mclo.gs/ OR submit the file to github by dragging it to this textbox."
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: java
|
||||
attributes:
|
||||
label: Java Version
|
||||
description: What Java version are you using? It's worth mentioning that if you play on Java9+ you should try update to latest minor release (e.g. prefer Java 17.0.6 over 17.0.2) of that version.
|
||||
options:
|
||||
- Java 8
|
||||
- Java 9
|
||||
- Java 11
|
||||
- Java 17
|
||||
- Java 19
|
||||
- Java 20
|
||||
- Java 21
|
||||
- Other (Please Specify)
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: modlist
|
||||
attributes:
|
||||
label: Mod List or GTNH Pack Version
|
||||
description: "List of mods, ideally a minimal reproducible set (can be retrieved from latest.log). If using GTNH please indicate pack version and any changed mods, not the entire modlist."
|
||||
placeholder: "List of mods or GTNH Pack version goes here"
|
||||
validations:
|
||||
required: true
|
||||
- type: checkboxes
|
||||
id: final
|
||||
attributes:
|
||||
label: Final Checklist
|
||||
description: Certify that you read things
|
||||
options:
|
||||
- label: "I have searched the issues and haven't found a similar issue."
|
||||
required: true
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
name: Feature Request
|
||||
description: "Request a feature."
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: "Please use this form to request features. We ask you check if it was already requested though"
|
||||
- type: input
|
||||
id: discord
|
||||
attributes:
|
||||
label: Your GTNH Discord Username
|
||||
description: Leave empty if you don't have one, but this will make it harder to contact you if we need additional info.
|
||||
placeholder: "Example: Wumpus#1234"
|
||||
- type: textarea
|
||||
id: request
|
||||
attributes:
|
||||
label: Feature Request
|
||||
description: "Relevant information, as well as relevant images"
|
||||
placeholder: "Example: https://mclo.gs/ OR submit the file to github by dragging it to this textbox."
|
||||
validations:
|
||||
required: true
|
||||
- type: checkboxes
|
||||
id: final
|
||||
attributes:
|
||||
label: Final Checklist
|
||||
description: Certify that you read things
|
||||
options:
|
||||
- label: "I have searched the issues and haven't found a similar issue."
|
||||
required: true
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// Add your dependencies here
|
||||
|
||||
dependencies {
|
||||
api('com.github.GTNewHorizons:CodeChickenCore:1.3.6:dev')
|
||||
api('com.github.GTNewHorizons:CodeChickenCore:1.4.0:dev')
|
||||
shadowImplementation('org.apache.commons:commons-csv:1.10.0')
|
||||
}
|
||||
+2
-2
@@ -41,11 +41,11 @@ developmentEnvironmentUserName = Developer
|
||||
|
||||
# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
|
||||
# See https://github.com/bsideup/jabel for details on how this works.
|
||||
enableModernJavaSyntax = false
|
||||
enableModernJavaSyntax = true
|
||||
|
||||
# Enables injecting missing generics into the decompiled source code for a better coding experience.
|
||||
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
|
||||
enableGenericInjection = false
|
||||
enableGenericInjection = true
|
||||
|
||||
# Generate a class with a String field for the mod version named as defined below.
|
||||
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.26'
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.30'
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.getMousePosition;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.guihook.IContainerInputHandler;
|
||||
|
||||
public class AutoFocusWidget implements IContainerInputHandler {
|
||||
|
||||
/**
|
||||
* Implement this interface on a GuiContainer to enable the autofocus search in NEI (if the autofocus option is
|
||||
* enabled) without needing to add the classname to the config file .
|
||||
*/
|
||||
public interface INEIAutoFocusSearchEnable {
|
||||
}
|
||||
|
||||
public static AutoFocusWidget instance = new AutoFocusWidget();
|
||||
|
||||
public static List<String> enableAutoFocusPrefixes = new ArrayList<>();
|
||||
|
||||
protected boolean autofocus = false;
|
||||
protected Point mouse;
|
||||
|
||||
public AutoFocusWidget() {
|
||||
GuiContainerManager.addInputHandler(this);
|
||||
}
|
||||
|
||||
public void load(GuiContainer gui) {
|
||||
this.autofocus = LayoutManager.searchField.isVisible() && NEIClientConfig.searchWidgetAutofocus() != 0
|
||||
&& isAllowedGuiAutoSearchFocus(gui);
|
||||
this.mouse = getMousePosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyTyped(GuiContainer gui, char keyChar, int keyCode) {
|
||||
|
||||
if (this.autofocus) {
|
||||
this.autofocus = false;
|
||||
|
||||
if (!this.mouse.equals(getMousePosition())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (NEIClientConfig.searchWidgetAutofocus() == 2
|
||||
&& GameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindInventory)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (keyCode == Keyboard.KEY_RETURN || keyCode == Keyboard.KEY_NUMPADENTER
|
||||
|| keyCode == Keyboard.KEY_ESCAPE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
LayoutManager.searchField.setFocus(true);
|
||||
LayoutManager.searchField.handleKeyPress(keyCode, keyChar);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(GuiContainer gui, int mousex, int mousey, int button) {
|
||||
this.autofocus = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) {
|
||||
this.autofocus = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyTyped(GuiContainer gui, char keyChar, int keyID) {}
|
||||
|
||||
@Override
|
||||
public void onMouseClicked(GuiContainer gui, int mousex, int mousey, int button) {
|
||||
this.autofocus = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseDragged(GuiContainer gui, int mousex, int mousey, int button, long heldTime) {
|
||||
this.autofocus = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) {
|
||||
this.autofocus = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseUp(GuiContainer gui, int mousex, int mousey, int button) {
|
||||
this.autofocus = false;
|
||||
}
|
||||
|
||||
protected boolean isAllowedGuiAutoSearchFocus(GuiContainer gui) {
|
||||
if (gui instanceof INEIAutoFocusSearchEnable) {
|
||||
return true;
|
||||
}
|
||||
String guiClassName = gui.getClass().getName();
|
||||
for (String prefix : enableAutoFocusPrefixes) {
|
||||
if (guiClassName.startsWith(prefix)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,6 +19,7 @@ public class BookmarkCraftingChain {
|
||||
|
||||
public HashMap<ItemStack, ItemStack> inputs = new HashMap<>();
|
||||
public HashMap<ItemStack, ItemStack> outputs = new HashMap<>();
|
||||
public HashMap<ItemStack, ItemStack> remainder = new HashMap<>();
|
||||
public HashMap<ItemStack, ItemStack> intermediate = new HashMap<>();
|
||||
|
||||
protected static class CraftingChainItem {
|
||||
@@ -206,6 +207,7 @@ public class BookmarkCraftingChain {
|
||||
|
||||
this.inputs.clear();
|
||||
this.outputs.clear();
|
||||
this.remainder.clear();
|
||||
this.intermediate.clear();
|
||||
this.calculatedItems.clear();
|
||||
this.multiplier.clear();
|
||||
@@ -245,18 +247,20 @@ public class BookmarkCraftingChain {
|
||||
}
|
||||
|
||||
} else { // output
|
||||
long iCount = calculateCount(request, request.inputs.get(item.stackIndex))
|
||||
- iShift.getOrDefault(item.stackIndex, 0L);
|
||||
long iCalcCount = calculateCount(request, request.inputs.get(item.stackIndex));
|
||||
long iCount = iCalcCount - iShift.getOrDefault(item.stackIndex, 0L);
|
||||
this.multiplier.put(item.stack, item.factor > 0 ? (int) (count / item.factor) : 0);
|
||||
|
||||
if (iCount < count) {
|
||||
this.outputs.put(item.stack, item.getItemStack(count - iCount));
|
||||
iShift.put(item.stackIndex, iShift.getOrDefault(item.stackIndex, 0L) + iCount);
|
||||
} else if (iCount >= count) {
|
||||
if (iCount >= count) {
|
||||
this.intermediate.put(item.stack, item.getItemStack(0));
|
||||
iShift.put(item.stackIndex, iShift.getOrDefault(item.stackIndex, 0L) + count);
|
||||
} else if (iCalcCount > 0) {
|
||||
this.remainder.put(item.stack, item.getItemStack(count - iCount));
|
||||
iShift.put(item.stackIndex, iShift.getOrDefault(item.stackIndex, 0L) + iCount);
|
||||
} else {
|
||||
this.outputs.put(item.stack, item.getItemStack(count - iCount));
|
||||
iShift.put(item.stackIndex, iShift.getOrDefault(item.stackIndex, 0L) + iCount);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,19 +1,19 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
@@ -30,18 +30,18 @@ import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
|
||||
import org.apache.commons.csv.CSVFormat;
|
||||
import org.apache.commons.csv.CSVParser;
|
||||
import org.apache.commons.csv.CSVRecord;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import codechicken.core.ClassDiscoverer;
|
||||
import codechicken.core.ClientUtils;
|
||||
import codechicken.core.GuiModListScroll;
|
||||
import codechicken.lib.packet.PacketCustom;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.IConfigureNEI;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.recipe.GuiRecipeTab;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import cpw.mods.fml.client.CustomModLoadingErrorDisplayException;
|
||||
@@ -54,15 +54,8 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ClientHandler {
|
||||
|
||||
private static String[] defaultHandlerOrdering = {
|
||||
"# Each line in this file should either be a comment (starts with '#') or an ordering.",
|
||||
"# Ordering lines are <handler ID>,<ordering number>.",
|
||||
"# Handlers will be sorted in order of number ascending, so smaller numbers first.",
|
||||
"# Any handlers that are missing from this file will be assigned to 0.", "# Negative numbers are fine.",
|
||||
"# If you delete this file, it will be regenerated with all registered handler IDs.", };
|
||||
private static ClientHandler instance;
|
||||
|
||||
private ArrayList<EntityItem> SMPmagneticItems = new ArrayList<>();
|
||||
private final ArrayList<EntityItem> SMPmagneticItems = new ArrayList<>();
|
||||
private World lastworld;
|
||||
private GuiScreen lastGui;
|
||||
|
||||
@@ -147,6 +140,7 @@ public class ClientHandler {
|
||||
|
||||
public static void preInit() {
|
||||
loadSerialHandlers();
|
||||
loadHiddenItems();
|
||||
loadHeightHackHandlers();
|
||||
loadHiddenHandlers();
|
||||
loadEnableAutoFocus();
|
||||
@@ -154,100 +148,69 @@ public class ClientHandler {
|
||||
StackInfo.loadGuidFilters();
|
||||
}
|
||||
|
||||
public static void loadSerialHandlers() {
|
||||
File file = NEIClientConfig.serialHandlersFile;
|
||||
public static void loadSettingsFile(String resource, Consumer<Stream<String>> callback) {
|
||||
loadSettingsFile(resource, (file, writer) -> {
|
||||
String folder = resource.substring(resource.lastIndexOf(".") + 1);
|
||||
URL defaultResource = ClientHandler.class.getResource("/assets/nei/" + folder + "/" + resource);
|
||||
|
||||
if (defaultResource != null) {
|
||||
try {
|
||||
IOUtils.copy(defaultResource.openStream(), writer);
|
||||
} catch (IOException e) {}
|
||||
}
|
||||
}, callback);
|
||||
}
|
||||
|
||||
public static void loadSettingsFile(String resource, BiConsumer<File, FileWriter> createDefault,
|
||||
Consumer<Stream<String>> callback) {
|
||||
File file = new File(NEIClientConfig.configDir, resource);
|
||||
|
||||
if (!file.exists()) {
|
||||
try (FileWriter writer = new FileWriter(file)) {
|
||||
NEIClientConfig.logger.info("Creating default serial handlers list {}", file);
|
||||
URL defaultSerialHandlersResource = ClientHandler.class
|
||||
.getResource("/assets/nei/cfg/serialhandlers.cfg");
|
||||
if (defaultSerialHandlersResource != null) {
|
||||
IOUtils.copy(defaultSerialHandlersResource.openStream(), writer);
|
||||
}
|
||||
NEIClientConfig.logger.info("Creating default '{}' {}", resource, file);
|
||||
createDefault.accept(file, writer);
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Failed to save default serial handlers list to file {}", file, e);
|
||||
NEIClientConfig.logger.error("Failed to save default '{}' to file {}", resource, file, e);
|
||||
}
|
||||
}
|
||||
|
||||
try (FileReader reader = new FileReader(file)) {
|
||||
NEIClientConfig.logger.info("Loading serial handlers from file {}", file);
|
||||
NEIClientConfig.serialHandlers = IOUtils.readLines(reader).stream().filter((line) -> !line.startsWith("#"))
|
||||
.collect(Collectors.toCollection(HashSet::new));
|
||||
NEIClientConfig.logger.info("Loading '{}' file {}", resource, file);
|
||||
callback.accept(
|
||||
IOUtils.readLines(reader).stream().filter(line -> !line.startsWith("#") && !line.trim().isEmpty()));
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Failed to load serial handlers from file {}", file, e);
|
||||
NEIClientConfig.logger.error("Failed to load '{}' file {}", resource, file, e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadSerialHandlers() {
|
||||
loadSettingsFile(
|
||||
"serialhandlers.cfg",
|
||||
lines -> NEIClientConfig.serialHandlers = lines.collect(Collectors.toCollection(HashSet::new)));
|
||||
}
|
||||
|
||||
public static void loadHeightHackHandlers() {
|
||||
File file = NEIClientConfig.heightHackHandlersFile;
|
||||
if (!file.exists()) {
|
||||
try (FileWriter writer = new FileWriter(file)) {
|
||||
NEIClientConfig.logger.info("Creating default height hack handlers list {}", file);
|
||||
URL defaultHeightHackHandlersResource = ClientHandler.class
|
||||
.getResource("/assets/nei/cfg/heighthackhandlers.cfg");
|
||||
if (defaultHeightHackHandlersResource != null) {
|
||||
IOUtils.copy(defaultHeightHackHandlersResource.openStream(), writer);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Failed to save default height hack handlers list to file {}", file, e);
|
||||
}
|
||||
}
|
||||
|
||||
try (FileReader reader = new FileReader(file)) {
|
||||
NEIClientConfig.logger.info("Loading height hack handlers from file {}", file);
|
||||
NEIClientConfig.heightHackHandlerRegex = IOUtils.readLines(reader).stream()
|
||||
.filter((line) -> !line.startsWith("#")).map(Pattern::compile)
|
||||
.collect(Collectors.toCollection(HashSet::new));
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Failed to load height hack handlers from file {}", file, e);
|
||||
}
|
||||
loadSettingsFile(
|
||||
"heighthackhandlers.cfg",
|
||||
lines -> NEIClientConfig.heightHackHandlerRegex = lines.map(Pattern::compile)
|
||||
.collect(Collectors.toCollection(HashSet::new)));
|
||||
}
|
||||
|
||||
public static void loadHiddenHandlers() {
|
||||
File file = NEIClientConfig.hiddenHandlersFile;
|
||||
if (!file.exists()) {
|
||||
try (FileWriter writer = new FileWriter(file)) {
|
||||
NEIClientConfig.logger.info("Creating default hidden handlers list {}", file);
|
||||
URL defaultHeightHackHandlersResource = ClientHandler.class
|
||||
.getResource("/assets/nei/cfg/hiddenhandlers.cfg");
|
||||
if (defaultHeightHackHandlersResource != null) {
|
||||
IOUtils.copy(defaultHeightHackHandlersResource.openStream(), writer);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Failed to save default hidden handlers list to file {}", file, e);
|
||||
}
|
||||
}
|
||||
|
||||
try (FileReader reader = new FileReader(file)) {
|
||||
NEIClientConfig.logger.info("Loading hidden handlers from file {}", file);
|
||||
NEIClientConfig.hiddenHandlers = IOUtils.readLines(reader).stream().filter((line) -> !line.startsWith("#"))
|
||||
.collect(Collectors.toCollection(HashSet::new));
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Failed to load hidden handlers from file {}", file, e);
|
||||
}
|
||||
loadSettingsFile(
|
||||
"hiddenhandlers.cfg",
|
||||
lines -> NEIClientConfig.hiddenHandlers = lines.collect(Collectors.toCollection(HashSet::new)));
|
||||
}
|
||||
|
||||
public static void loadEnableAutoFocus() {
|
||||
File file = NEIClientConfig.enableAutoFocusFile;
|
||||
if (!file.exists()) {
|
||||
try (FileWriter writer = new FileWriter(file)) {
|
||||
NEIClientConfig.logger.info("Creating default enable auto focus list {}", file);
|
||||
URL defaultEnableAutoFocusResource = ClientHandler.class
|
||||
.getResource("/assets/nei/cfg/enableautofocus.cfg");
|
||||
if (defaultEnableAutoFocusResource != null) {
|
||||
IOUtils.copy(defaultEnableAutoFocusResource.openStream(), writer);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Failed to save default enable auto focus list to file {}", file, e);
|
||||
}
|
||||
}
|
||||
loadSettingsFile(
|
||||
"enableautofocus.cfg",
|
||||
lines -> AutoFocusWidget.enableAutoFocusPrefixes = lines
|
||||
.collect(Collectors.toCollection(ArrayList::new)));
|
||||
}
|
||||
|
||||
try (FileReader reader = new FileReader(file)) {
|
||||
NEIClientConfig.logger.info("Loading enable auto focus from file {}", file);
|
||||
NEIClientConfig.enableAutoFocusPrefixes = IOUtils.readLines(reader).stream()
|
||||
.filter((line) -> !line.startsWith("#")).collect(Collectors.toCollection(ArrayList::new));
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Failed to load enable auto focus from file {}", file, e);
|
||||
}
|
||||
public static void loadHiddenItems() {
|
||||
loadSettingsFile("hiddenitems.cfg", lines -> lines.forEach(API::hideItem));
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
@@ -264,54 +227,38 @@ public class ClientHandler {
|
||||
}
|
||||
|
||||
public static void postInit() {
|
||||
loadHandlerOrdering();
|
||||
GuiContainerManager.registerReloadResourceListener();
|
||||
}
|
||||
|
||||
public static void loadHandlerOrdering() {
|
||||
File file = NEIClientConfig.handlerOrderingFile;
|
||||
if (!file.exists()) {
|
||||
try (FileWriter writer = new FileWriter(file)) {
|
||||
NEIClientConfig.logger.info("Creating default handler ordering CSV {}", file);
|
||||
|
||||
List<String> toWrite = Lists.newArrayList(defaultHandlerOrdering);
|
||||
GuiRecipeTab.handlerMap.keySet().stream().sorted()
|
||||
.forEach(handlerId -> toWrite.add(String.format("%s,0", handlerId)));
|
||||
final String COMMA_DELIMITER = ",";
|
||||
final String[] defaultHandlerOrdering = {
|
||||
"# Each line in this file should either be a comment (starts with '#') or an ordering.",
|
||||
"# Ordering lines are <handler ID>,<ordering number>.",
|
||||
"# Handlers will be sorted in order of number ascending, so smaller numbers first.",
|
||||
"# Any handlers that are missing from this file will be assigned to 0.", "# Negative numbers are fine.",
|
||||
"# If you delete this file, it will be regenerated with all registered handler IDs.", };
|
||||
|
||||
loadSettingsFile("handlerordering.csv", (file, writer) -> {
|
||||
List<String> toWrite = Lists.newArrayList(defaultHandlerOrdering);
|
||||
GuiRecipeTab.handlerMap.keySet().stream().sorted()
|
||||
.forEach(handlerId -> toWrite.add(String.format("%s" + COMMA_DELIMITER + "0", handlerId)));
|
||||
try {
|
||||
IOUtils.writeLines(toWrite, "\n", writer);
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Failed to save default handler ordering to file {}", file, e);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {}
|
||||
}, lines -> lines.map(line -> line.split(COMMA_DELIMITER)).filter(parts -> parts.length == 2).forEach(parts -> {
|
||||
String handlerId = parts[0];
|
||||
int ordering = Integer.parseInt(parts[1]);
|
||||
NEIClientConfig.handlerOrdering.put(handlerId, ordering);
|
||||
}));
|
||||
}
|
||||
|
||||
URL url;
|
||||
try {
|
||||
url = file.toURI().toURL();
|
||||
} catch (MalformedURLException e) {
|
||||
NEIClientConfig.logger.info("Invalid URL for handler ordering CSV.");
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
public static void loadPluginsList() {
|
||||
final ClassDiscoverer classDiscoverer = new ClassDiscoverer(
|
||||
test -> test.startsWith("NEI") && test.endsWith("Config.class"),
|
||||
IConfigureNEI.class);
|
||||
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()))) {
|
||||
NEIClientConfig.logger.info("Loading handler ordering from file {}", file);
|
||||
CSVParser csvParser = CSVFormat.EXCEL.withCommentMarker('#').parse(reader);
|
||||
for (CSVRecord record : csvParser) {
|
||||
final String handlerId = record.get(0);
|
||||
|
||||
int ordering;
|
||||
try {
|
||||
ordering = Integer.parseInt(record.get(1));
|
||||
} catch (NumberFormatException e) {
|
||||
NEIClientConfig.logger.error("Error parsing CSV record {}: {}", record, e);
|
||||
continue;
|
||||
}
|
||||
|
||||
NEIClientConfig.handlerOrdering.put(handlerId, ordering);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
NEIClientConfig.logger.info("Error parsing CSV");
|
||||
e.printStackTrace();
|
||||
}
|
||||
NEIClientConfig.pluginsList.addAll(classDiscoverer.findClasses());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -408,9 +355,10 @@ public class ClientHandler {
|
||||
}
|
||||
};
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
CustomModLoadingErrorDisplayException e = new CustomModLoadingErrorDisplayException() {
|
||||
|
||||
private static final long serialVersionUID = -5593387489666663375L;
|
||||
|
||||
@Override
|
||||
public void initGui(GuiErrorScreen errorScreen, FontRenderer fontRenderer) {
|
||||
Minecraft.getMinecraft().displayGuiScreen(errorGui);
|
||||
|
||||
@@ -1,230 +1,48 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraft.nbt.NBTBase.NBTPrimitive;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import codechicken.nei.ItemList.AllMultiItemFilter;
|
||||
import codechicken.nei.ItemList.AnyMultiItemFilter;
|
||||
import codechicken.nei.ItemList.EverythingItemFilter;
|
||||
import codechicken.nei.ItemList.NegatedItemFilter;
|
||||
import codechicken.nei.ItemList.NothingItemFilter;
|
||||
import codechicken.nei.PresetsList.Preset;
|
||||
import codechicken.nei.PresetsList.PresetMode;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import codechicken.nei.util.ItemStackFilterParser;
|
||||
|
||||
public class CollapsibleItems {
|
||||
|
||||
protected static interface ISearchParserProvider {
|
||||
|
||||
public ItemFilter getFilter(String searchText);
|
||||
|
||||
default Predicate<String> getMatcher(String searchText) {
|
||||
|
||||
if (searchText.length() >= 3 && searchText.startsWith("r/") && searchText.endsWith("/")) {
|
||||
|
||||
try {
|
||||
Pattern pattern = Pattern.compile(
|
||||
searchText.substring(2, searchText.length() - 1),
|
||||
Pattern.MULTILINE | Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE);
|
||||
return value -> pattern.matcher(value).find();
|
||||
} catch (PatternSyntaxException ignored) {}
|
||||
|
||||
} else if (!searchText.isEmpty()) {
|
||||
return value -> value.toLowerCase().contains(searchText);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected static class GroupTokenParser {
|
||||
|
||||
protected final HashMap<Character, ISearchParserProvider> searchProviders = new HashMap<>();
|
||||
|
||||
public void addProvider(char prefix, ISearchParserProvider provider) {
|
||||
this.searchProviders.put(prefix, provider);
|
||||
}
|
||||
|
||||
public ItemFilter getFilter(String filterText) {
|
||||
final String[] parts = filterText.toLowerCase().trim().split("\\|");
|
||||
final List<ItemFilter> searchTokens = Arrays.stream(parts).map(s -> parseSearchText(s))
|
||||
.filter(s -> s != null && !s.filters.isEmpty()).collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
if (searchTokens.isEmpty()) {
|
||||
return new EverythingItemFilter();
|
||||
} else if (searchTokens.size() == 1) {
|
||||
return searchTokens.get(0);
|
||||
} else {
|
||||
return new AnyMultiItemFilter(searchTokens);
|
||||
}
|
||||
}
|
||||
|
||||
private AllMultiItemFilter parseSearchText(String filterText) {
|
||||
|
||||
if (filterText.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final String[] tokens = filterText.split("\\s+");
|
||||
final AllMultiItemFilter searchTokens = new AllMultiItemFilter();
|
||||
|
||||
for (String token : tokens) {
|
||||
token = token.trim();
|
||||
boolean ignore = token.startsWith("!");
|
||||
|
||||
if (ignore) {
|
||||
token = token.substring(1);
|
||||
}
|
||||
|
||||
if (token.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ISearchParserProvider provider = this.searchProviders.get(token.charAt(0));
|
||||
|
||||
if (provider != null) {
|
||||
token = token.substring(1);
|
||||
} else {
|
||||
provider = this.searchProviders.get('\0');
|
||||
}
|
||||
|
||||
ItemFilter filter = parseToken(ignore ? "!" + token : token, provider);
|
||||
|
||||
if (filter != null) {
|
||||
searchTokens.filters.add(filter);
|
||||
}
|
||||
}
|
||||
|
||||
return searchTokens;
|
||||
}
|
||||
|
||||
private ItemFilter parseToken(String token, ISearchParserProvider provider) {
|
||||
final String[] parts = token.split(",");
|
||||
final AnyMultiItemFilter includeFilter = new AnyMultiItemFilter();
|
||||
final AnyMultiItemFilter expludeFilter = new AnyMultiItemFilter();
|
||||
final AllMultiItemFilter groupFilter = new AllMultiItemFilter();
|
||||
|
||||
for (String part : parts) {
|
||||
boolean ignore = part.startsWith("!");
|
||||
|
||||
if (ignore) {
|
||||
part = part.substring(1);
|
||||
}
|
||||
|
||||
ItemFilter filter = provider.getFilter(part);
|
||||
|
||||
if (filter == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ignore) {
|
||||
expludeFilter.filters.add(filter);
|
||||
} else {
|
||||
includeFilter.filters.add(filter);
|
||||
}
|
||||
}
|
||||
|
||||
if (!includeFilter.filters.isEmpty()) {
|
||||
groupFilter.filters.add(includeFilter);
|
||||
}
|
||||
|
||||
if (!expludeFilter.filters.isEmpty()) {
|
||||
groupFilter.filters.add(new NegatedItemFilter(expludeFilter));
|
||||
}
|
||||
|
||||
return groupFilter.filters.isEmpty() ? null : groupFilter;
|
||||
}
|
||||
}
|
||||
|
||||
protected static class IdentifierFilter implements ISearchParserProvider {
|
||||
|
||||
@Override
|
||||
public ItemFilter getFilter(String searchText) {
|
||||
|
||||
if (Pattern.matches("^\\d+(-\\d+)*$", searchText)) {
|
||||
final Predicate<Integer> filter = generateDamageFilter(searchText);
|
||||
return (stack) -> filter.test(stack.getItemDamage());
|
||||
}
|
||||
|
||||
Predicate<String> matcher = getMatcher(searchText);
|
||||
|
||||
if (matcher != null) {
|
||||
return stack -> matcher.test(getStringIdentifier(stack));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String getStringIdentifier(ItemStack stack) {
|
||||
String name = GameData.getItemRegistry().getNameForObject(stack.getItem());
|
||||
return name == null || name.isEmpty() ? "Unknown:Unknown" : name;
|
||||
}
|
||||
|
||||
protected Predicate<Integer> generateDamageFilter(String searchText) {
|
||||
String[] range = searchText.split("-");
|
||||
|
||||
if (range.length == 1) {
|
||||
final int damage = Integer.parseInt(range[0]);
|
||||
return (dmg) -> dmg == damage;
|
||||
} else {
|
||||
final int damageStart = Integer.parseInt(range[0]);
|
||||
final int damageEnd = Integer.parseInt(range[1]);
|
||||
return (dmg) -> dmg >= damageStart && dmg <= damageEnd;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static class OreDictionaryFilter implements ISearchParserProvider {
|
||||
|
||||
@Override
|
||||
public ItemFilter getFilter(String searchText) {
|
||||
Predicate<String> matcher = getMatcher(searchText);
|
||||
|
||||
if (matcher != null) {
|
||||
return stack -> matches(stack, matcher);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected boolean matches(ItemStack stack, Predicate<String> matcher) {
|
||||
return IntStream.of(OreDictionary.getOreIDs(stack))
|
||||
.anyMatch(id -> matcher.test(OreDictionary.getOreName(id)));
|
||||
}
|
||||
}
|
||||
|
||||
protected static class GroupItem {
|
||||
|
||||
protected static int lastGroupIndex = 0;
|
||||
|
||||
public final int groupIndex;
|
||||
public final ItemFilter filter;
|
||||
public String guid;
|
||||
public ItemFilter filter;
|
||||
public boolean expanded = false;
|
||||
public String displayName = "";
|
||||
|
||||
public GroupItem(ItemFilter filter) {
|
||||
this.groupIndex = lastGroupIndex++;
|
||||
public void setFilter(String filter) {
|
||||
this.filter = ItemStackFilterParser.parse(filter.trim());
|
||||
this.guid = this.filter != null ? UUID.nameUUIDFromBytes(filter.getBytes()).toString() : "";
|
||||
}
|
||||
|
||||
public void setFilter(ItemFilter filter, String guid) {
|
||||
this.filter = filter;
|
||||
this.guid = guid;
|
||||
}
|
||||
|
||||
public boolean matches(ItemStack stack) {
|
||||
@@ -232,88 +50,112 @@ public class CollapsibleItems {
|
||||
}
|
||||
}
|
||||
|
||||
protected static final GroupTokenParser groupParser = new GroupTokenParser();
|
||||
protected final Map<Integer, GroupItem> groups = new ConcurrentHashMap<>();
|
||||
protected final Map<ItemStack, Integer> cache = new ConcurrentHashMap<>();
|
||||
private static final String STATE_KEY = "collapsibleitems";
|
||||
|
||||
static {
|
||||
groupParser.addProvider('\0', new IdentifierFilter());
|
||||
groupParser.addProvider('$', new OreDictionaryFilter());
|
||||
}
|
||||
protected static File statesFile;
|
||||
protected static final List<GroupItem> groups = new ArrayList<>();
|
||||
protected static final Map<ItemStack, Integer> cache = new ConcurrentHashMap<>();
|
||||
|
||||
public void reload() {
|
||||
GroupItem.lastGroupIndex = 0;
|
||||
this.groups.clear();
|
||||
this.cache.clear();
|
||||
private CollapsibleItems() {}
|
||||
|
||||
public static void load() {
|
||||
CollapsibleItems.groups.clear();
|
||||
CollapsibleItems.cache.clear();
|
||||
|
||||
for (int i = PresetsList.presets.size() - 1; i >= 0; i--) {
|
||||
Preset preset = PresetsList.presets.get(i);
|
||||
if (preset.enabled && preset.mode == PresetMode.GROUP) {
|
||||
addGroup(preset);
|
||||
GroupItem group = new GroupItem();
|
||||
group.setFilter(preset, UUID.nameUUIDFromBytes(preset.items.toString().getBytes()).toString());
|
||||
group.displayName = preset.name;
|
||||
addGroup(group);
|
||||
}
|
||||
}
|
||||
|
||||
loadCollapsibleItems();
|
||||
|
||||
if (ItemList.loadFinished) {
|
||||
LayoutManager.markItemsDirty();
|
||||
if (NEIClientConfig.enableCollapsibleItems()) {
|
||||
ClientHandler.loadSettingsFile(
|
||||
"collapsibleitems.cfg",
|
||||
lines -> parseFile(lines.collect(Collectors.toCollection(ArrayList::new))));
|
||||
}
|
||||
|
||||
loadStates();
|
||||
}
|
||||
|
||||
protected void loadCollapsibleItems() {
|
||||
File file = NEIClientConfig.collapsibleItemsFile;
|
||||
if (!file.exists()) {
|
||||
try (FileWriter writer = new FileWriter(file)) {
|
||||
NEIClientConfig.logger.info("Creating default collapsible items list {}", file);
|
||||
URL defaultCollapsibleItemsResource = ClientHandler.class
|
||||
.getResource("/assets/nei/cfg/collapsibleitems.cfg");
|
||||
if (defaultCollapsibleItemsResource != null) {
|
||||
IOUtils.copy(defaultCollapsibleItemsResource.openStream(), writer);
|
||||
private static void parseFile(List<String> itemStrings) {
|
||||
final JsonParser parser = new JsonParser();
|
||||
GroupItem group = new GroupItem();
|
||||
|
||||
for (String itemStr : itemStrings) {
|
||||
try {
|
||||
|
||||
if (itemStr.startsWith("; ")) {
|
||||
JsonObject settings = parser.parse(itemStr.substring(2)).getAsJsonObject();
|
||||
|
||||
if (settings.get("displayName") != null) {
|
||||
group.displayName = settings.get("displayName").getAsString();
|
||||
}
|
||||
|
||||
if (settings.get("unlocalizedName") != null) {
|
||||
String unlocalizedName = settings.get("unlocalizedName").getAsString();
|
||||
String displayName = StatCollector.translateToLocal(unlocalizedName);
|
||||
|
||||
if (!displayName.equals(unlocalizedName)) {
|
||||
group.displayName = displayName;
|
||||
}
|
||||
}
|
||||
|
||||
if (settings.get("expanded") != null) {
|
||||
group.expanded = settings.get("expanded").getAsBoolean();
|
||||
}
|
||||
|
||||
} else {
|
||||
group.setFilter(itemStr);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Failed to save default collapsible items list to file {}", file, e);
|
||||
|
||||
if (group != null && group.filter != null) {
|
||||
addGroup(group);
|
||||
group = new GroupItem();
|
||||
}
|
||||
|
||||
} catch (IllegalArgumentException | JsonSyntaxException | IllegalStateException e) {
|
||||
NEIClientConfig.logger.error("Failed to load collapsible items from json string:\n{}", itemStr);
|
||||
}
|
||||
}
|
||||
|
||||
try (FileReader reader = new FileReader(file)) {
|
||||
NEIClientConfig.logger.info("Loading collapsible items from file {}", file);
|
||||
IOUtils.readLines(reader).stream().filter((line) -> !line.startsWith("#") && !line.trim().isEmpty())
|
||||
.forEach(this::addGroup);
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Failed to load collapsible items from file {}", file, e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void addGroup(String filterText) {
|
||||
addGroup(CollapsibleItems.groupParser.getFilter(filterText.trim()));
|
||||
private static void addGroup(GroupItem group) {
|
||||
if (group == null || group.filter == null
|
||||
|| group.filter instanceof EverythingItemFilter
|
||||
|| group.filter instanceof NothingItemFilter)
|
||||
return;
|
||||
CollapsibleItems.groups.add(group);
|
||||
}
|
||||
|
||||
protected void addGroup(ItemFilter filter) {
|
||||
if (filter == null || filter instanceof EverythingItemFilter || filter instanceof NothingItemFilter) return;
|
||||
GroupItem group = new GroupItem(filter);
|
||||
this.groups.put(group.groupIndex, group);
|
||||
public static boolean isEmpty() {
|
||||
return CollapsibleItems.groups.isEmpty();
|
||||
}
|
||||
|
||||
public ItemFilter getItemFilter() {
|
||||
public static ItemFilter getItemFilter() {
|
||||
AnyMultiItemFilter filter = new AnyMultiItemFilter();
|
||||
|
||||
for (GroupItem group : this.groups.values()) {
|
||||
for (GroupItem group : CollapsibleItems.groups) {
|
||||
filter.filters.add(group.filter);
|
||||
}
|
||||
|
||||
return filter;
|
||||
}
|
||||
|
||||
public void updateCache(final List<ItemStack> items) {
|
||||
this.cache.clear();
|
||||
public static void updateCache(final List<ItemStack> items) {
|
||||
CollapsibleItems.cache.clear();
|
||||
|
||||
try {
|
||||
|
||||
ItemList.forkJoinPool.submit(() -> items.parallelStream().forEach(stack -> {
|
||||
GroupItem group = this.groups.values().stream().filter(g -> g.matches(stack)).findFirst().orElse(null);
|
||||
GroupItem group = CollapsibleItems.groups.stream().filter(g -> g.matches(stack)).findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (group != null) {
|
||||
this.cache.put(stack, group.groupIndex);
|
||||
CollapsibleItems.cache.put(stack, CollapsibleItems.groups.indexOf(group));
|
||||
}
|
||||
})).get();
|
||||
|
||||
@@ -323,42 +165,89 @@ public class CollapsibleItems {
|
||||
|
||||
}
|
||||
|
||||
public int getGroupIndex(ItemStack stack) {
|
||||
public static int getGroupIndex(ItemStack stack) {
|
||||
|
||||
if (stack == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return this.cache.getOrDefault(stack, -1);
|
||||
return CollapsibleItems.cache.getOrDefault(stack, -1);
|
||||
}
|
||||
|
||||
public boolean isExpanded(int groupIndex) {
|
||||
public static String getDisplayName(int groupIndex) {
|
||||
|
||||
if (this.groups.containsKey(groupIndex)) {
|
||||
return this.groups.get(groupIndex).expanded;
|
||||
if (groupIndex < CollapsibleItems.groups.size()) {
|
||||
return CollapsibleItems.groups.get(groupIndex).displayName;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isExpanded(int groupIndex) {
|
||||
|
||||
if (groupIndex < CollapsibleItems.groups.size()) {
|
||||
return CollapsibleItems.groups.get(groupIndex).expanded;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setExpanded(int groupIndex, boolean expanded) {
|
||||
public static void setExpanded(int groupIndex, boolean expanded) {
|
||||
|
||||
if (this.groups.containsKey(groupIndex)) {
|
||||
this.groups.get(groupIndex).expanded = expanded;
|
||||
if (groupIndex < CollapsibleItems.groups.size()) {
|
||||
CollapsibleItems.groups.get(groupIndex).expanded = expanded;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void toggleGroups(Boolean expanded) {
|
||||
public static void toggleGroups(Boolean expanded) {
|
||||
|
||||
if (expanded == null) {
|
||||
expanded = !this.groups.values().stream().filter(g -> g.expanded).findAny().isPresent();
|
||||
expanded = CollapsibleItems.groups.stream().noneMatch(g -> g.expanded);
|
||||
}
|
||||
|
||||
for (GroupItem group : this.groups.values()) {
|
||||
for (GroupItem group : CollapsibleItems.groups) {
|
||||
group.expanded = expanded;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void saveStates() {
|
||||
NBTTagCompound list = new NBTTagCompound();
|
||||
|
||||
for (GroupItem group : CollapsibleItems.groups) {
|
||||
list.setBoolean(group.guid, group.expanded);
|
||||
}
|
||||
|
||||
if (NEIClientConfig.world != null) {
|
||||
NEIClientConfig.world.nbt.setTag(STATE_KEY, list);
|
||||
}
|
||||
}
|
||||
|
||||
private static void loadStates() {
|
||||
|
||||
try {
|
||||
|
||||
if (NEIClientConfig.world.nbt.hasKey(STATE_KEY)) {
|
||||
NBTTagCompound states = NEIClientConfig.world.nbt.getCompoundTag(STATE_KEY);
|
||||
@SuppressWarnings("unchecked")
|
||||
final Map<String, NBTPrimitive> list = (Map<String, NBTPrimitive>) states.tagMap;
|
||||
final Map<String, GroupItem> mapping = new HashMap<>();
|
||||
|
||||
for (GroupItem group : CollapsibleItems.groups) {
|
||||
mapping.put(group.guid, group);
|
||||
}
|
||||
|
||||
for (Map.Entry<String, NBTPrimitive> nbtEntry : list.entrySet()) {
|
||||
if (mapping.containsKey(nbtEntry.getKey())) {
|
||||
mapping.get(nbtEntry.getKey()).expanded = nbtEntry.getValue().func_150290_f() == 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
NEIClientConfig.logger.error("Error loading collapsible items states", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -116,7 +116,6 @@ public class ContainerPotionCreator extends ContainerExtended {
|
||||
if (!player.worldObj.isRemote) InventoryUtils.dropOnClose(player, potionInv);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void handleServerPacket(PacketCustom packet) {
|
||||
ItemStack potion = potionInv.getStackInSlot(0);
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.render.CCRenderState;
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.api.INEIAutoFocusSearchEnable;
|
||||
import codechicken.nei.AutoFocusWidget.INEIAutoFocusSearchEnable;
|
||||
import codechicken.nei.api.INEIGuiHandler;
|
||||
import codechicken.nei.api.TaggedInventoryArea;
|
||||
|
||||
@@ -60,13 +60,13 @@ public class GuiExtendedCreativeInv extends GuiContainer implements INEIGuiHandl
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleMouseClick(Slot p_146984_1_, int p_146984_2_, int p_146984_3_, int p_146984_4_) {
|
||||
protected void handleMouseClick(Slot slotIn, int slotId, int clickedButton, int clickType) {
|
||||
|
||||
// Hack for armor slots, because they are outside the container
|
||||
if (p_146984_1_ != null && p_146984_4_ == 4 && p_146984_1_.xDisplayPosition < 0) {
|
||||
p_146984_4_ = 0;
|
||||
if (slotIn != null && clickType == 4 && slotIn.xDisplayPosition < 0) {
|
||||
clickType = 0;
|
||||
}
|
||||
|
||||
super.handleMouseClick(p_146984_1_, p_146984_2_, p_146984_3_, p_146984_4_);
|
||||
super.handleMouseClick(slotIn, slotId, clickedButton, clickType);
|
||||
}
|
||||
}
|
||||
@@ -15,14 +15,13 @@ public class GuiNEIButton extends GuiButton {
|
||||
super(i, j, k, l, i1, s);
|
||||
}
|
||||
|
||||
public void drawButton(Minecraft minecraft, int i, int j) {
|
||||
public void drawButton(Minecraft minecraft, int x, int y) {
|
||||
if (!visible) return;
|
||||
|
||||
FontRenderer fontrenderer = minecraft.fontRenderer;
|
||||
minecraft.renderEngine.bindTexture(guiTex);
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
boolean flag = i >= xPosition && j >= yPosition && i < xPosition + width && j < yPosition + height;
|
||||
int k = getHoverState(flag);
|
||||
boolean mouseOver = x >= xPosition && y >= yPosition && x < xPosition + width && y < yPosition + height;
|
||||
int k = getHoverState(mouseOver);
|
||||
drawTexturedModalRect(xPosition, yPosition, 0, 46 + k * 20, width / 2, height / 2); // top left
|
||||
drawTexturedModalRect(xPosition + width / 2, yPosition, 200 - width / 2, 46 + k * 20, width / 2, height / 2); // top
|
||||
// right
|
||||
@@ -40,25 +39,27 @@ public class GuiNEIButton extends GuiButton {
|
||||
46 + k * 20 + 20 - height / 2,
|
||||
width / 2,
|
||||
height / 2); // bottom right
|
||||
mouseDragged(minecraft, i, j);
|
||||
mouseDragged(minecraft, x, y);
|
||||
|
||||
if (!enabled) drawCenteredString(
|
||||
fontrenderer,
|
||||
displayString,
|
||||
xPosition + width / 2,
|
||||
yPosition + (height - 8) / 2,
|
||||
0xffa0a0a0);
|
||||
else if (flag) drawCenteredString(
|
||||
fontrenderer,
|
||||
displayString,
|
||||
xPosition + width / 2,
|
||||
yPosition + (height - 8) / 2,
|
||||
0xffffa0);
|
||||
else drawCenteredString(
|
||||
fontrenderer,
|
||||
displayString,
|
||||
xPosition + width / 2,
|
||||
yPosition + (height - 8) / 2,
|
||||
0xe0e0e0);
|
||||
drawContent(minecraft, x, y, mouseOver);
|
||||
}
|
||||
|
||||
protected int getTextColour(boolean mouseOver) {
|
||||
int color = 0xe0e0e0;
|
||||
|
||||
if (!enabled) {
|
||||
color = 0xffa0a0a0;
|
||||
} else if (mouseOver) {
|
||||
color = 0xffffa0;
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
protected void drawContent(Minecraft minecraft, int y, int x, boolean mouseOver) {
|
||||
FontRenderer fontrenderer = minecraft.fontRenderer;
|
||||
int color = getTextColour(mouseOver);
|
||||
|
||||
drawCenteredString(fontrenderer, displayString, xPosition + width / 2, yPosition + (height - 8) / 2, color);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import static codechicken.nei.NEIClientUtils.translate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.guihook.IContainerInputHandler;
|
||||
import codechicken.nei.guihook.IContainerTooltipHandler;
|
||||
|
||||
public class HeldItemHandler implements IContainerInputHandler, IContainerTooltipHandler {
|
||||
|
||||
protected HeldItemHandler() {
|
||||
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
HeldItemHandler instance = new HeldItemHandler();
|
||||
GuiContainerManager.addInputHandler(instance);
|
||||
GuiContainerManager.addTooltipHandler(instance);
|
||||
}
|
||||
|
||||
protected boolean contains(int mousex, int mousey) {
|
||||
return NEIClientUtils.getHeldItem() != null
|
||||
&& (ItemPanels.bookmarkPanel.contains(mousex, mousey) || ItemPanels.itemPanel.contains(mousex, mousey)
|
||||
|| ItemPanels.itemPanel.historyPanel.contains(mousex, mousey));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(GuiContainer gui, int mousex, int mousey, int button) {
|
||||
|
||||
if (contains(mousex, mousey)) {
|
||||
|
||||
if (NEIClientConfig.canPerformAction("delete") && NEIClientConfig.canPerformAction("item")) {
|
||||
if (button == 1) {
|
||||
NEIClientUtils.decreaseSlotStack(-999);
|
||||
} else {
|
||||
NEIClientUtils.deleteHeldItem();
|
||||
}
|
||||
} else {
|
||||
NEIClientUtils.dropHeldItem();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyTyped(GuiContainer gui, char keyChar, int keyCode) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyID) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyTyped(GuiContainer gui, char keyChar, int keyID) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseClicked(GuiContainer gui, int mousex, int mousey, int button) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseDragged(GuiContainer gui, int mousex, int mousey, int button, long heldTime) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseUp(GuiContainer gui, int mousex, int mousey, int button) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleItemDisplayName(GuiContainer gui, ItemStack itemstack, List<String> currenttip) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleItemTooltip(GuiContainer gui, ItemStack itemstack, int mousex, int mousey,
|
||||
List<String> currenttip) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleTooltip(GuiContainer gui, int mousex, int mousey, List<String> currenttip) {
|
||||
|
||||
if (contains(mousex, mousey)) {
|
||||
currenttip.clear();
|
||||
|
||||
if (NEIClientConfig.canPerformAction("delete") && NEIClientConfig.canPerformAction("item")) {
|
||||
currenttip.add(EnumChatFormatting.RED + translate("itempanel.deleteItem"));
|
||||
}
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -69,10 +69,10 @@ public class ItemHistoryPanel extends Widget {
|
||||
|
||||
private void drawSplittingArea(int x, int y, int width, int height, int color) {
|
||||
|
||||
float alpha = (float) (color >> 24 & 255) / 255.0F;
|
||||
float red = (float) (color >> 16 & 255) / 255.0F;
|
||||
float green = (float) (color >> 8 & 255) / 255.0F;
|
||||
float blue = (float) (color & 255) / 255.0F;
|
||||
float alpha = (color >> 24 & 255) / 255.0F;
|
||||
float red = (color >> 16 & 255) / 255.0F;
|
||||
float green = (color >> 8 & 255) / 255.0F;
|
||||
float blue = (color & 255) / 255.0F;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
@@ -120,28 +120,8 @@ public class ItemHistoryPanel extends Widget {
|
||||
|
||||
@Override
|
||||
public boolean handleClick(int mousex, int mousey, int button) {
|
||||
|
||||
if (handleClickExt(mousex, mousey, button)) return true;
|
||||
|
||||
if (NEIClientUtils.getHeldItem() != null) {
|
||||
|
||||
if (!grid.contains(mousex, mousey)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (NEIClientConfig.canPerformAction("delete") && NEIClientConfig.canPerformAction("item")) {
|
||||
if (button == 1) {
|
||||
NEIClientUtils.decreaseSlotStack(-999);
|
||||
} else {
|
||||
NEIClientUtils.deleteHeldItem();
|
||||
}
|
||||
} else {
|
||||
NEIClientUtils.dropHeldItem();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ItemPanelSlot hoverSlot = getSlotMouseOver(mousex, mousey);
|
||||
if (hoverSlot != null) {
|
||||
|
||||
@@ -168,7 +148,8 @@ public class ItemHistoryPanel extends Widget {
|
||||
if (hoverSlot != null && hoverSlot.slotIndex == mouseDownSlot && ItemPanels.itemPanel.draggedStack == null) {
|
||||
ItemStack item = hoverSlot.item.copy();
|
||||
|
||||
if (NEIController.manager.window instanceof GuiRecipe || !NEIClientConfig.canCheatItem(item)) {
|
||||
if (NEIController.manager.window instanceof GuiRecipe || NEIClientUtils.shiftKey()
|
||||
|| !NEIClientConfig.canCheatItem(item)) {
|
||||
|
||||
if (button == 0) {
|
||||
GuiCraftingRecipe.openRecipeGui("item", item);
|
||||
|
||||
@@ -6,15 +6,16 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.concurrent.ForkJoinWorkerThread;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
@@ -40,7 +41,6 @@ public class ItemList {
|
||||
*/
|
||||
public static final List<ItemFilterProvider> itemFilterers = new LinkedList<>();
|
||||
public static final List<ItemsLoadedCallback> loadCallbacks = new LinkedList<>();
|
||||
public static final CollapsibleItems collapsibleItems = new CollapsibleItems();
|
||||
|
||||
private static final HashSet<Item> erroredItems = new HashSet<>();
|
||||
private static final HashSet<String> stackTraces = new HashSet<>();
|
||||
@@ -90,7 +90,20 @@ public class ItemList {
|
||||
|
||||
@Override
|
||||
public boolean matches(ItemStack item) {
|
||||
return pattern.matcher(item.getDisplayName()).find();
|
||||
String displayName = EnumChatFormatting.getTextWithoutFormattingCodes(item.getDisplayName());
|
||||
|
||||
if (displayName != null && !displayName.isEmpty() && pattern.matcher(displayName).find()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item.hasDisplayName()) {
|
||||
displayName = EnumChatFormatting
|
||||
.getTextWithoutFormattingCodes(item.getItem().getItemStackDisplayName(item));
|
||||
|
||||
return displayName != null && !displayName.isEmpty() && pattern.matcher(displayName).find();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +116,7 @@ public class ItemList {
|
||||
}
|
||||
|
||||
public AllMultiItemFilter(ItemFilter... filters) {
|
||||
this(Arrays.asList(filters));
|
||||
this(new LinkedList<>(Arrays.asList(filters)));
|
||||
}
|
||||
|
||||
public AllMultiItemFilter() {
|
||||
@@ -115,7 +128,8 @@ public class ItemList {
|
||||
for (ItemFilter filter : filters) try {
|
||||
if (filter != null && !filter.matches(item)) return false;
|
||||
} catch (Exception e) {
|
||||
NEIClientConfig.logger.error("Exception filtering " + item + " with " + filter, e);
|
||||
NEIClientConfig.logger
|
||||
.error("Exception filtering " + item + " with " + filter + " (" + e.getMessage() + ")", e);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -137,9 +151,10 @@ public class ItemList {
|
||||
@Override
|
||||
public boolean matches(ItemStack item) {
|
||||
for (ItemFilter filter : filters) try {
|
||||
if (filter.matches(item)) return true;
|
||||
if (filter != null && filter.matches(item)) return true;
|
||||
} catch (Exception e) {
|
||||
NEIClientConfig.logger.error("Exception filtering " + item + " with " + filter, e);
|
||||
NEIClientConfig.logger
|
||||
.error("Exception filtering " + item + " with " + filter + " (" + e.getMessage() + ")", e);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -154,9 +169,10 @@ public class ItemList {
|
||||
public static boolean itemMatchesAll(ItemStack item, List<ItemFilter> filters) {
|
||||
for (ItemFilter filter : filters) {
|
||||
try {
|
||||
if (!filter.matches(item)) return false;
|
||||
if (filter != null && !filter.matches(item)) return false;
|
||||
} catch (Exception e) {
|
||||
NEIClientConfig.logger.error("Exception filtering " + item + " with " + filter, e);
|
||||
NEIClientConfig.logger
|
||||
.error("Exception filtering " + item + " with " + filter + " (" + e.getMessage() + ")", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,15 +227,7 @@ public class ItemList {
|
||||
|
||||
private String getTooltip(ItemStack stack) {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
final List<String> namelist = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
|
||||
final StringJoiner sb = new StringJoiner("\n");
|
||||
|
||||
for (String name : namelist) {
|
||||
sb.add(name);
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
return String.join("\n", stack.getTooltip(Minecraft.getMinecraft().thePlayer, false));
|
||||
} catch (Throwable ignored) {}
|
||||
|
||||
return "";
|
||||
@@ -230,12 +238,12 @@ public class ItemList {
|
||||
|
||||
ItemSorter.sort(items);
|
||||
|
||||
if (NEIClientConfig.enableCollapsibleItems()) {
|
||||
if (!CollapsibleItems.isEmpty()) {
|
||||
HashMap<Integer, Integer> groups = new HashMap<>();
|
||||
int orderIndex = 0;
|
||||
|
||||
for (ItemStack stack : items) {
|
||||
final int groupIndex = ItemList.collapsibleItems.getGroupIndex(stack);
|
||||
final int groupIndex = CollapsibleItems.getGroupIndex(stack);
|
||||
|
||||
if (groupIndex == -1) {
|
||||
ItemList.ordering.put(stack, orderIndex++);
|
||||
@@ -260,8 +268,8 @@ public class ItemList {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void execute() {
|
||||
// System.out.println("Executing NEI Item Loading");
|
||||
ThreadOperationTimer timer = getTimer(NEIClientConfig.getItemLoadingTimeout());
|
||||
LayoutManager.itemsLoaded = true;
|
||||
loadFinished = false;
|
||||
|
||||
List<ItemStack> items = new LinkedList<>();
|
||||
@@ -280,14 +288,21 @@ public class ItemList {
|
||||
permutations.clear();
|
||||
permutations.addAll(ItemInfo.itemOverrides.get(item));
|
||||
|
||||
if (permutations.isEmpty()) item.getSubItems(item, null, permutations);
|
||||
if (permutations.isEmpty()) {
|
||||
item.getSubItems(item, null, permutations);
|
||||
}
|
||||
|
||||
if (permutations.isEmpty()) damageSearch(item, permutations);
|
||||
if (permutations.isEmpty()) {
|
||||
damageSearch(item, permutations);
|
||||
}
|
||||
|
||||
permutations.addAll(ItemInfo.itemVariants.get(item));
|
||||
|
||||
timer.reset();
|
||||
|
||||
permutations = permutations.stream().filter(stack -> !ItemInfo.isHidden(stack))
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
items.addAll(permutations);
|
||||
itemMap.putAll(item, permutations);
|
||||
} catch (Throwable t) {
|
||||
@@ -302,7 +317,7 @@ public class ItemList {
|
||||
for (ItemsLoadedCallback callback : loadCallbacks) callback.itemsLoaded();
|
||||
|
||||
if (interrupted()) return;
|
||||
ItemList.collapsibleItems.updateCache(items);
|
||||
CollapsibleItems.updateCache(items);
|
||||
updateOrdering(items);
|
||||
|
||||
loadFinished = true;
|
||||
@@ -310,15 +325,25 @@ public class ItemList {
|
||||
}
|
||||
};
|
||||
|
||||
public static ForkJoinPool getPool(int poolSize) {
|
||||
public static ForkJoinPool forkJoinPool;
|
||||
|
||||
static {
|
||||
final ForkJoinPool.ForkJoinWorkerThreadFactory factory = new ForkJoinPool.ForkJoinWorkerThreadFactory() {
|
||||
|
||||
private int workerId;
|
||||
|
||||
@Override
|
||||
public ForkJoinWorkerThread newThread(ForkJoinPool pool) {
|
||||
final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool);
|
||||
worker.setName("NEI-worker-thread-" + workerId++);
|
||||
return worker;
|
||||
}
|
||||
};
|
||||
int poolSize = Runtime.getRuntime().availableProcessors() * 2 / 3;
|
||||
if (poolSize < 1) poolSize = 1;
|
||||
|
||||
return new ForkJoinPool(poolSize);
|
||||
forkJoinPool = new ForkJoinPool(poolSize, factory, null, false);
|
||||
}
|
||||
|
||||
public static final int numProcessors = Runtime.getRuntime().availableProcessors();
|
||||
public static ForkJoinPool forkJoinPool = getPool(numProcessors * 2 / 3);
|
||||
|
||||
public static final RestartableTask updateFilter = new RestartableTask("NEI Item Filtering") {
|
||||
|
||||
private int compare(ItemStack o1, ItemStack o2) {
|
||||
|
||||
@@ -66,7 +66,7 @@ public class ItemMobSpawner extends ItemBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack itemstack, EntityPlayer par2EntityPlayer, List list, boolean par4) {
|
||||
public void addInformation(ItemStack itemstack, EntityPlayer par2EntityPlayer, List<String> list, boolean par4) {
|
||||
setDefaultTag(itemstack);
|
||||
int meta = itemstack.getItemDamage();
|
||||
if (meta == 0) {
|
||||
@@ -106,9 +106,10 @@ public class ItemMobSpawner extends ItemBlock {
|
||||
public static void loadSpawners(World world) {
|
||||
if (loaded) return;
|
||||
loaded = true;
|
||||
HashMap<Class<Entity>, String> classToStringMapping = (HashMap<Class<Entity>, String>) EntityList.classToStringMapping;
|
||||
HashMap<Class<Entity>, Integer> classToIDMapping = (HashMap<Class<Entity>, Integer>) EntityList.classToIDMapping;
|
||||
for (Class<Entity> eclass : classToStringMapping.keySet()) {
|
||||
Map<Class<? extends Entity>, String> classToStringMapping = EntityList.classToStringMapping;
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<Class<? extends Entity>, Integer> classToIDMapping = (Map<Class<? extends Entity>, Integer>) EntityList.classToIDMapping;
|
||||
for (Class<? extends Entity> eclass : classToStringMapping.keySet()) {
|
||||
if (!EntityLiving.class.isAssignableFrom(eclass)) continue;
|
||||
try {
|
||||
EntityLiving entityliving = (EntityLiving) eclass.getConstructor(new Class[] { World.class })
|
||||
@@ -131,7 +132,7 @@ public class ItemMobSpawner extends ItemBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(Item item, CreativeTabs tab, List list) {
|
||||
public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> list) {
|
||||
if (!NEIClientConfig.hasSMPCounterPart()) list.add(new ItemStack(item));
|
||||
else for (int i : IDtoNameMap.keySet()) list.add(new ItemStack(item, 1, i));
|
||||
}
|
||||
|
||||
@@ -17,11 +17,11 @@ import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.guihook.IContainerTooltipHandler;
|
||||
|
||||
public class ItemPanel extends PanelWidget implements IContainerTooltipHandler {
|
||||
public class ItemPanel extends PanelWidget {
|
||||
|
||||
/**
|
||||
* Backwards compat :-/
|
||||
@@ -66,6 +66,7 @@ public class ItemPanel extends PanelWidget implements IContainerTooltipHandler {
|
||||
protected static class MaskMetadata {
|
||||
|
||||
public int groupIndex = -1;
|
||||
public String displayName = "";
|
||||
public boolean extended = false;
|
||||
|
||||
public Color bgColor = null;
|
||||
@@ -97,7 +98,7 @@ public class ItemPanel extends PanelWidget implements IContainerTooltipHandler {
|
||||
this.groupItems.clear();
|
||||
this.forceExpand = false;
|
||||
|
||||
if (NEIClientConfig.enableCollapsibleItems() && !this.newItems.isEmpty()) {
|
||||
if (!CollapsibleItems.isEmpty() && !this.newItems.isEmpty()) {
|
||||
final Set<Integer> groups = new HashSet<>();
|
||||
boolean outsideGroup = false;
|
||||
|
||||
@@ -105,14 +106,14 @@ public class ItemPanel extends PanelWidget implements IContainerTooltipHandler {
|
||||
this.rawItems = new ArrayList<>(this.newItems);
|
||||
|
||||
for (ItemStack stack : this.newItems) {
|
||||
final int groupIndex = ItemList.collapsibleItems.getGroupIndex(stack);
|
||||
final int groupIndex = CollapsibleItems.getGroupIndex(stack);
|
||||
|
||||
if (groupIndex == -1) {
|
||||
this.realItems.add(stack);
|
||||
outsideGroup = true;
|
||||
} else {
|
||||
|
||||
if (!groups.contains(groupIndex) || ItemList.collapsibleItems.isExpanded(groupIndex)) {
|
||||
if (!groups.contains(groupIndex) || CollapsibleItems.isExpanded(groupIndex)) {
|
||||
this.realItems.add(stack);
|
||||
groups.add(groupIndex);
|
||||
}
|
||||
@@ -174,7 +175,7 @@ public class ItemPanel extends PanelWidget implements IContainerTooltipHandler {
|
||||
}
|
||||
|
||||
int idx = mask.get(slotIndex);
|
||||
maskGroup.put(idx, ItemList.collapsibleItems.getGroupIndex(getItem(idx)));
|
||||
maskGroup.put(idx, CollapsibleItems.getGroupIndex(getItem(idx)));
|
||||
}
|
||||
|
||||
for (int slotIndex = 0; slotIndex < mask.size(); slotIndex++) {
|
||||
@@ -196,7 +197,8 @@ public class ItemPanel extends PanelWidget implements IContainerTooltipHandler {
|
||||
MaskMetadata metadata = new MaskMetadata();
|
||||
|
||||
metadata.groupIndex = groupIndex;
|
||||
metadata.extended = this.forceExpand || ItemList.collapsibleItems.isExpanded(groupIndex);
|
||||
metadata.displayName = CollapsibleItems.getDisplayName(groupIndex);
|
||||
metadata.extended = this.forceExpand || CollapsibleItems.isExpanded(groupIndex);
|
||||
metadata.bgColor = metadata.extended ? expandedColor : collapsedColor;
|
||||
metadata.color = darkerColor(metadata.bgColor);
|
||||
metadata.left = column == 0 || idx == 0
|
||||
@@ -317,7 +319,6 @@ public class ItemPanel extends PanelWidget implements IContainerTooltipHandler {
|
||||
|
||||
public ItemPanel() {
|
||||
grid = new ItemPanelGrid();
|
||||
GuiContainerManager.addTooltipHandler(this);
|
||||
}
|
||||
|
||||
public static void updateItemList(ArrayList<ItemStack> newItems) {
|
||||
@@ -338,7 +339,7 @@ public class ItemPanel extends PanelWidget implements IContainerTooltipHandler {
|
||||
|
||||
@Override
|
||||
public boolean onButtonPress(boolean rightclick) {
|
||||
ItemList.collapsibleItems.toggleGroups(rightclick ? false : null);
|
||||
CollapsibleItems.toggleGroups(rightclick ? false : null);
|
||||
ItemList.updateFilter.restart();
|
||||
return true;
|
||||
}
|
||||
@@ -481,7 +482,7 @@ public class ItemPanel extends PanelWidget implements IContainerTooltipHandler {
|
||||
LayoutManager.addWidget(quantity);
|
||||
}
|
||||
|
||||
if (NEIClientConfig.enableCollapsibleItems()) {
|
||||
if (!CollapsibleItems.isEmpty()) {
|
||||
LayoutManager.addWidget(toggleGroups);
|
||||
}
|
||||
|
||||
@@ -513,16 +514,6 @@ public class ItemPanel extends PanelWidget implements IContainerTooltipHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleTooltip(GuiContainer gui, int mousex, int mousey, List<String> currenttip) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleItemDisplayName(GuiContainer gui, ItemStack itemstack, List<String> currenttip) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleItemTooltip(GuiContainer gui, ItemStack itemstack, int mousex, int mousey,
|
||||
List<String> currenttip) {
|
||||
@@ -537,6 +528,12 @@ public class ItemPanel extends PanelWidget implements IContainerTooltipHandler {
|
||||
if (metadata != null) {
|
||||
final List<ItemStack> items = panelGrid.groupItems.get(metadata.groupIndex);
|
||||
|
||||
if (NEIClientConfig.getBooleanSetting("inventory.collapsibleItems.customName") && !metadata.extended
|
||||
&& !"".equals(metadata.displayName)) {
|
||||
currenttip.clear();
|
||||
currenttip.add(metadata.displayName + GuiDraw.TOOLTIP_LINESPACE);
|
||||
}
|
||||
|
||||
if (items != null && items.size() > 1) {
|
||||
String message = metadata.extended ? "itempanel.collapsed.hint.collapse"
|
||||
: "itempanel.collapsed.hint.expand";
|
||||
@@ -549,7 +546,7 @@ public class ItemPanel extends PanelWidget implements IContainerTooltipHandler {
|
||||
}
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
return super.handleItemTooltip(gui, itemstack, mousex, mousey, currenttip);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -563,7 +560,7 @@ public class ItemPanel extends PanelWidget implements IContainerTooltipHandler {
|
||||
final MaskMetadata metadata = panelGrid.maskMetadata.get(hoverSlot.slotIndex);
|
||||
|
||||
if (metadata != null) {
|
||||
ItemList.collapsibleItems.setExpanded(metadata.groupIndex, !metadata.extended);
|
||||
CollapsibleItems.setExpanded(metadata.groupIndex, !metadata.extended);
|
||||
panelGrid.setItems(panelGrid.rawItems);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ public class ItemQuantityField extends TextField {
|
||||
|
||||
if (!focused() && intValue() == 0) {
|
||||
field.setText(translate("itempanel.quantity.default"));
|
||||
field.setCursorPositionZero();
|
||||
field.setEnabled(false);
|
||||
super.draw(mousex, mousey);
|
||||
field.setEnabled(true);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -29,7 +27,7 @@ public class ItemStackSet extends ItemStackMap<ItemStack> implements ItemFilter
|
||||
put(item, item);
|
||||
}
|
||||
|
||||
public ItemStackSet addAll(List<ItemStack> items) {
|
||||
public ItemStackSet addAll(Iterable<ItemStack> items) {
|
||||
for (ItemStack item : items) add(item);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,250 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.guihook.IContainerInputHandler;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
|
||||
public class ItemZoom extends Widget implements IContainerInputHandler {
|
||||
|
||||
public static final int MIN_ZOOM = 0;
|
||||
public static final int MAX_ZOOM = 1000;
|
||||
|
||||
private static final int MIN_SCALE = 2;
|
||||
private static final int SLOT_SIZE = 16;
|
||||
|
||||
private Boolean previousKeyboardRepeatEnabled = null;
|
||||
|
||||
private ItemStack stack = null;
|
||||
private String displayName = "";
|
||||
private int availableAreaWidth = 0;
|
||||
private float xPosition = 0;
|
||||
private float yPosition = 0;
|
||||
private float scale = 1;
|
||||
|
||||
public ItemZoom() {
|
||||
GuiContainerManager.addInputHandler(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int mx, int my) {
|
||||
|
||||
if (this.stack != null
|
||||
&& (NEIClientConfig.getBooleanSetting("inventory.itemzoom.enabled")
|
||||
|| NEIClientConfig.isKeyHashDown("gui.itemzoom_hold"))
|
||||
&& GuiContainerManager.shouldShowTooltip(NEIClientUtils.getGuiContainer())) {
|
||||
final float inverseScaleFactor = 1.0f / this.scale;
|
||||
final float screenScale = getScreenScale();
|
||||
final float size = SLOT_SIZE * this.scale;
|
||||
int shiftText = 10;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled(screenScale, screenScale, 1);
|
||||
GL11.glScaled(this.scale, this.scale, 2);
|
||||
GL11.glTranslated(this.xPosition * inverseScaleFactor, this.yPosition * inverseScaleFactor, 0);
|
||||
|
||||
GuiContainerManager.drawItem(0, 0, this.stack, false, "");
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||
GuiContainerManager.enable2DRender();
|
||||
|
||||
if (NEIClientConfig.getBooleanSetting("inventory.itemzoom.showName")) {
|
||||
String dispalyName = NEIClientUtils
|
||||
.cropText(GuiDraw.fontRenderer, this.displayName, this.availableAreaWidth);
|
||||
GuiDraw.drawStringC(
|
||||
dispalyName,
|
||||
(int) ((this.xPosition + size / 2) * screenScale),
|
||||
(int) ((this.yPosition + size) * screenScale) + shiftText,
|
||||
NEIClientConfig.getSetting("inventory.itemzoom.nameColor").getHexValue());
|
||||
shiftText += GuiDraw.fontRenderer.FONT_HEIGHT;
|
||||
}
|
||||
|
||||
if (NEIClientConfig.getBooleanSetting("inventory.itemzoom.enabled")
|
||||
&& NEIClientConfig.getBooleanSetting("inventory.itemzoom.helpText")) {
|
||||
String keyName = NEIClientConfig.getKeyName("gui.itemzoom_toggle");
|
||||
|
||||
if (keyName != null) {
|
||||
String helpText = NEIClientUtils.translate("itemzoom.toggle", keyName);
|
||||
List<String> lines = GuiDraw.fontRenderer
|
||||
.listFormattedStringToWidth(helpText, this.availableAreaWidth);
|
||||
|
||||
for (String line : lines) {
|
||||
GuiDraw.drawStringC(
|
||||
line,
|
||||
(int) ((this.xPosition + size / 2) * screenScale),
|
||||
(int) ((this.yPosition + size) * screenScale) + 10 + shiftText,
|
||||
0x66555555);
|
||||
shiftText += GuiDraw.fontRenderer.FONT_HEIGHT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
}
|
||||
|
||||
public void resize(GuiContainer gui) {
|
||||
final ItemStack stack = getStackMouseOver(gui);
|
||||
|
||||
if (stack != null && (!NEIClientConfig.getBooleanSetting("inventory.itemzoom.onlySolid")
|
||||
|| Block.getBlockFromItem(stack.getItem()).getMaterial().isSolid())) {
|
||||
final float screenScale = 1.0f / getScreenScale();
|
||||
final float availableAreaWidth = (gui.width - gui.xSize) / 2 * screenScale;
|
||||
final float availableAreaHeight = gui.height * screenScale;
|
||||
final Point mouse = GuiDraw.getMousePosition();
|
||||
|
||||
this.scale = Math.round(getZoomAmount(gui) * getPointSize(gui) / SLOT_SIZE);
|
||||
this.yPosition = (availableAreaHeight - this.scale * SLOT_SIZE) / 2;
|
||||
this.xPosition = (availableAreaWidth - this.scale * SLOT_SIZE) / 2;
|
||||
this.availableAreaWidth = (int) (availableAreaWidth / screenScale);
|
||||
|
||||
if (availableAreaWidth / screenScale >= mouse.x) {
|
||||
this.xPosition += gui.width * screenScale - availableAreaWidth;
|
||||
}
|
||||
|
||||
try {
|
||||
this.displayName = stack.getDisplayName();
|
||||
} catch (Throwable ignored) {
|
||||
this.displayName = "Unnamed";
|
||||
}
|
||||
|
||||
this.stack = StackInfo.loadFromNBT(StackInfo.itemStackToNBT(stack), 0);
|
||||
} else {
|
||||
this.stack = null;
|
||||
this.displayName = "";
|
||||
}
|
||||
}
|
||||
|
||||
private float getPointSize(GuiContainer gui) {
|
||||
final float screenScale = 1.0f / getScreenScale();
|
||||
final float availableAreaWidth = (gui.width - (gui.xSize + gui.width) / 2) * screenScale;
|
||||
return availableAreaWidth / MAX_ZOOM;
|
||||
}
|
||||
|
||||
private float getScreenScale() {
|
||||
return Minecraft.getMinecraft().currentScreen.width * 1f / Minecraft.getMinecraft().displayWidth;
|
||||
}
|
||||
|
||||
private int getZoomAmount(GuiContainer gui) {
|
||||
return Math.max(
|
||||
Math.round(SLOT_SIZE * MIN_SCALE / getPointSize(gui)),
|
||||
NEIClientConfig.getIntSetting("inventory.itemzoom.zoom"));
|
||||
}
|
||||
|
||||
private void increaseZoom(GuiContainer gui) {
|
||||
final float pointSize = getPointSize(gui);
|
||||
final float scale = Math.round(getZoomAmount(gui) * pointSize / SLOT_SIZE);
|
||||
|
||||
NEIClientConfig.setIntSetting(
|
||||
"inventory.itemzoom.zoom",
|
||||
Math.min(MAX_ZOOM, Math.round((scale + 1) / (pointSize / SLOT_SIZE))));
|
||||
}
|
||||
|
||||
private void decreaseZoom(GuiContainer gui) {
|
||||
final float pointSize = getPointSize(gui);
|
||||
final float scale = Math.round(getZoomAmount(gui) * pointSize / SLOT_SIZE);
|
||||
|
||||
NEIClientConfig.setIntSetting(
|
||||
"inventory.itemzoom.zoom",
|
||||
Math.max(MIN_ZOOM, Math.round(Math.max(MIN_SCALE, scale - 1) / (pointSize / SLOT_SIZE))));
|
||||
}
|
||||
|
||||
private ItemStack getStackMouseOver(GuiContainer gui) {
|
||||
|
||||
if (NEIClientConfig.getBooleanSetting("inventory.itemzoom.neiOnly")) {
|
||||
final Point mouse = GuiDraw.getMousePosition();
|
||||
ItemStack stack = ItemPanels.itemPanel.getStackMouseOver(mouse.x, mouse.y);
|
||||
|
||||
if (stack == null) {
|
||||
stack = ItemPanels.bookmarkPanel.getStackMouseOver(mouse.x, mouse.y);
|
||||
}
|
||||
|
||||
if (stack == null) {
|
||||
stack = ItemPanels.itemPanel.historyPanel.getStackMouseOver(mouse.x, mouse.y);
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
return GuiContainerManager.getStackMouseOver(gui);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyTyped(GuiContainer gui, char keyChar, int keyCode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(GuiContainer gui, int mousex, int mousey, int button) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyTyped(GuiContainer gui, char keyChar, int keyID) {}
|
||||
|
||||
@Override
|
||||
public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyID) {
|
||||
|
||||
if (NEIClientConfig.isKeyHashDown("gui.itemzoom_toggle")) {
|
||||
NEIClientConfig.getSetting("inventory.itemzoom.enabled")
|
||||
.setBooleanValue(!NEIClientConfig.getBooleanSetting("inventory.itemzoom.enabled"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.stack != null && NEIClientConfig.isKeyHashDown("gui.itemzoom_hold")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.stack != null && NEIClientConfig.isKeyHashDown("gui.itemzoom_zoom_in")) {
|
||||
increaseZoom(gui);
|
||||
previousKeyboardRepeatEnabled = Keyboard.areRepeatEventsEnabled();
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.stack != null && NEIClientConfig.isKeyHashDown("gui.itemzoom_zoom_out")) {
|
||||
decreaseZoom(gui);
|
||||
previousKeyboardRepeatEnabled = Keyboard.areRepeatEventsEnabled();
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (previousKeyboardRepeatEnabled != null) {
|
||||
Keyboard.enableRepeatEvents(previousKeyboardRepeatEnabled);
|
||||
previousKeyboardRepeatEnabled = null;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseClicked(GuiContainer gui, int mousex, int mousey, int button) {}
|
||||
|
||||
@Override
|
||||
public void onMouseUp(GuiContainer gui, int mousex, int mousey, int button) {}
|
||||
|
||||
@Override
|
||||
public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) {}
|
||||
|
||||
@Override
|
||||
public void onMouseDragged(GuiContainer gui, int mousex, int mousey, int button, long heldTime) {}
|
||||
|
||||
}
|
||||
@@ -260,7 +260,7 @@ public class ItemsGrid {
|
||||
}
|
||||
}
|
||||
|
||||
private void afterDrawItems(int mousex, int mousey, @Nullable ItemPanelSlot focused) {
|
||||
protected void afterDrawItems(int mousex, int mousey, @Nullable ItemPanelSlot focused) {
|
||||
final List<Integer> mask = getMask();
|
||||
|
||||
for (int i = 0; i < mask.size(); i++) {
|
||||
@@ -367,8 +367,6 @@ public class ItemsGrid {
|
||||
afterDrawItems(mousex, mousey, focused);
|
||||
}
|
||||
|
||||
public void postDrawTooltips(int mousex, int mousey, List<String> tooltip) {}
|
||||
|
||||
public void setVisible() {
|
||||
if (getItems().isEmpty() && getMessageOnEmpty() != null) {
|
||||
LayoutManager.addWidget(messageLabel);
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.fontRenderer;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw.ITooltipLineHandler;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import codechicken.nei.util.ReadableNumberConverter;
|
||||
|
||||
public class ItemsTooltipLineHandler implements ITooltipLineHandler {
|
||||
|
||||
protected static int MAX_COLUMNS = 11;
|
||||
protected static int MARGIN_TOP = 2;
|
||||
|
||||
protected String label;
|
||||
protected EnumChatFormatting labelColor = EnumChatFormatting.GRAY;
|
||||
protected List<ItemStack> items;
|
||||
protected Dimension size = new Dimension();
|
||||
protected boolean saveStackSize = false;
|
||||
protected int columns = 0;
|
||||
protected int count = 0;
|
||||
protected int rows = 0;
|
||||
protected int length = 0;
|
||||
|
||||
public ItemsTooltipLineHandler(String label, List<ItemStack> items, boolean saveStackSize) {
|
||||
this(label, items, true, 5);
|
||||
}
|
||||
|
||||
public ItemsTooltipLineHandler(String label, List<ItemStack> items, boolean saveStackSize, int maxRows) {
|
||||
this.label = label;
|
||||
this.items = groupingItemStacks(items);
|
||||
this.saveStackSize = saveStackSize;
|
||||
this.length = this.items.size();
|
||||
|
||||
if (this.length > 0) {
|
||||
this.columns = Math.min(MAX_COLUMNS, this.length);
|
||||
this.rows = Math.min(maxRows, (int) Math.ceil((float) this.length / this.columns));
|
||||
|
||||
this.size.width = Math
|
||||
.max(this.columns * ItemsGrid.SLOT_SIZE, fontRenderer.getStringWidth(this.label) + 15);
|
||||
this.size.height = this.rows * ItemsGrid.SLOT_SIZE + fontRenderer.FONT_HEIGHT + 2 + MARGIN_TOP;
|
||||
|
||||
this.count = Math.min(
|
||||
this.length,
|
||||
Math.min(
|
||||
this.columns * this.rows,
|
||||
this.length > MAX_COLUMNS * maxRows ? (MAX_COLUMNS * maxRows - 1) : Integer.MAX_VALUE));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.items.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
public void setLabelColor(EnumChatFormatting color) {
|
||||
this.labelColor = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int x, int y) {
|
||||
if (this.length == 0) return;
|
||||
|
||||
y += MARGIN_TOP;
|
||||
|
||||
fontRenderer.drawStringWithShadow(this.labelColor + this.label + ":", x, y, 0);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
GL11.glScaled(1, 1, 3);
|
||||
GL11.glTranslatef(x, y + fontRenderer.FONT_HEIGHT + 2, 0);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
|
||||
for (int i = 0; i < this.count; i++) {
|
||||
ItemStack drawStack = this.items.get(i);
|
||||
int col = i % this.columns;
|
||||
int row = i / this.columns;
|
||||
|
||||
String stackSize = !this.saveStackSize || drawStack.stackSize == 0 ? ""
|
||||
: ReadableNumberConverter.INSTANCE.toWideReadableForm(drawStack.stackSize);
|
||||
|
||||
GuiContainerManager
|
||||
.drawItem(col * ItemsGrid.SLOT_SIZE, row * ItemsGrid.SLOT_SIZE, drawStack, true, stackSize);
|
||||
}
|
||||
|
||||
if (this.count < this.items.size()) {
|
||||
fontRenderer.drawStringWithShadow(
|
||||
"+" + (this.items.size() - this.count),
|
||||
(this.columns - 1) * ItemsGrid.SLOT_SIZE,
|
||||
(this.rows - 1) * ItemsGrid.SLOT_SIZE + (ItemsGrid.SLOT_SIZE - fontRenderer.FONT_HEIGHT) / 2 - 1,
|
||||
0xee555555);
|
||||
}
|
||||
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private List<ItemStack> groupingItemStacks(List<ItemStack> items) {
|
||||
final Map<String, Integer> count = new HashMap<>();
|
||||
final Map<String, NBTTagCompound> unique = new LinkedHashMap<>();
|
||||
final List<ItemStack> result = new ArrayList<>();
|
||||
|
||||
for (ItemStack stack : items) {
|
||||
final NBTTagCompound nbTag = StackInfo.itemStackToNBT(stack, true);
|
||||
final String GUID = StackInfo.getItemStackGUID(stack);
|
||||
|
||||
if (!unique.containsKey(GUID)) {
|
||||
count.put(GUID, nbTag.getInteger("Count"));
|
||||
unique.put(GUID, nbTag);
|
||||
} else {
|
||||
count.put(GUID, count.get(GUID) + nbTag.getInteger("Count"));
|
||||
}
|
||||
}
|
||||
|
||||
for (String GUID : unique.keySet()) {
|
||||
ItemStack stack = StackInfo.loadFromNBT(unique.get(GUID), count.get(GUID));
|
||||
|
||||
if (unique.get(GUID).hasKey("gtFluidName")) {
|
||||
stack.stackSize = 0;
|
||||
}
|
||||
|
||||
result.add(stack);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import static codechicken.nei.NEIClientConfig.invCreativeMode;
|
||||
import static codechicken.nei.NEIClientConfig.isBookmarkPanelHidden;
|
||||
import static codechicken.nei.NEIClientConfig.isEnabled;
|
||||
import static codechicken.nei.NEIClientConfig.isHidden;
|
||||
import static codechicken.nei.NEIClientConfig.isLoaded;
|
||||
import static codechicken.nei.NEIClientConfig.showIDs;
|
||||
import static codechicken.nei.NEIClientConfig.toggleBooleanSetting;
|
||||
import static codechicken.nei.NEIClientUtils.cycleGamemode;
|
||||
@@ -32,7 +33,9 @@ import static codechicken.nei.NEIClientUtils.toggleRaining;
|
||||
import static codechicken.nei.NEIClientUtils.translate;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -40,7 +43,6 @@ import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainerCreative;
|
||||
import net.minecraft.client.renderer.InventoryEffectRenderer;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -53,7 +55,6 @@ import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.KeyManager.IKeyStateTracker;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.GuiInfo;
|
||||
import codechicken.nei.api.INEIAutoFocusSearchEnable;
|
||||
import codechicken.nei.api.IRecipeOverlayRenderer;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.api.LayoutStyle;
|
||||
@@ -84,13 +85,13 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
*/
|
||||
private static TreeSet<Widget> controlWidgets = new TreeSet<>(new WidgetZOrder(true));
|
||||
|
||||
private static List<IContainerTooltipHandler> tooltipWidgets = new LinkedList<>();
|
||||
|
||||
public static ItemPanel itemPanel;
|
||||
public static BookmarkPanel bookmarkPanel;
|
||||
public static SubsetWidget dropDown;
|
||||
public static SearchField searchField;
|
||||
public static boolean searchInitFocusedCancellable = false;
|
||||
protected static int mousePriorX;
|
||||
protected static int mousePriorY;
|
||||
public static ItemZoom itemZoom;
|
||||
|
||||
public static ButtonCycled options;
|
||||
public static ButtonCycled bookmarksButton;
|
||||
@@ -167,38 +168,10 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
return getSideWidth(gui);
|
||||
}
|
||||
|
||||
protected boolean isAllowedGuiAutoSearchFocus(GuiContainer gui) {
|
||||
if (gui instanceof INEIAutoFocusSearchEnable) {
|
||||
return true;
|
||||
}
|
||||
String guiClassName = gui.getClass().getName();
|
||||
for (String prefix : NEIClientConfig.enableAutoFocusPrefixes) {
|
||||
if (guiClassName.startsWith(prefix)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// Maybe make this an option to make it easier to figure out what GPU class to add to the configuration?
|
||||
// NEIClientConfig.logger.info("Checking for autofocus on " + guiClassName + " had no match");
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void searchFocusInitCancelCheck() {
|
||||
if (searchInitFocusedCancellable) {
|
||||
if (searchField.isVisible() && NEIClientConfig.searchWidgetAutofocus()
|
||||
&& getInputFocused() == searchField) {
|
||||
searchField.setFocus(false);
|
||||
setInputFocused(null);
|
||||
}
|
||||
searchInitFocusedCancellable = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseClicked(GuiContainer gui, int mousex, int mousey, int button) {
|
||||
if (isHidden()) return;
|
||||
|
||||
searchFocusInitCancelCheck();
|
||||
|
||||
for (Widget widget : controlWidgets) widget.onGuiClick(mousex, mousey);
|
||||
}
|
||||
|
||||
@@ -208,8 +181,6 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
|
||||
if (!isEnabled()) return options.contains(mousex, mousey) && options.handleClick(mousex, mousey, button);
|
||||
|
||||
searchFocusInitCancelCheck();
|
||||
|
||||
for (Widget widget : controlWidgets) {
|
||||
widget.onGuiClick(mousex, mousey);
|
||||
if (widget.contains(mousex, mousey) ? widget.handleClick(mousex, mousey, button)
|
||||
@@ -230,14 +201,6 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
|
||||
public boolean keyTyped(GuiContainer gui, char keyChar, int keyID) {
|
||||
if (isEnabled() && !isHidden()) {
|
||||
if (searchInitFocusedCancellable) {
|
||||
searchInitFocusedCancellable = false;
|
||||
if (NEIClientConfig.isFirstInvCloseClosesInSearch()
|
||||
&& GameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindInventory)) {
|
||||
searchField.setFocus(false);
|
||||
setInputFocused(null);
|
||||
}
|
||||
}
|
||||
if (inputFocused != null) return inputFocused.handleKeyPress(keyID, keyChar);
|
||||
|
||||
for (Widget widget : controlWidgets) if (widget.handleKeyPress(keyID, keyChar)) return true;
|
||||
@@ -258,7 +221,7 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
}
|
||||
|
||||
if (NEIClientConfig.isKeyHashDown("gui.hide_bookmarks")) {
|
||||
toggleBooleanSetting("inventory.bookmarksEnabled");
|
||||
toggleBooleanSetting("inventory.bookmarks.enabled");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -276,7 +239,6 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
|
||||
public void onMouseUp(GuiContainer gui, int mx, int my, int button) {
|
||||
if (!isHidden() && isEnabled()) {
|
||||
searchFocusInitCancelCheck();
|
||||
for (Widget widget : controlWidgets) widget.mouseUp(mx, my, button);
|
||||
}
|
||||
}
|
||||
@@ -284,7 +246,6 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
@Override
|
||||
public void onMouseDragged(GuiContainer gui, int mx, int my, int button, long heldTime) {
|
||||
if (!isHidden() && isEnabled()) {
|
||||
searchFocusInitCancelCheck();
|
||||
for (Widget widget : controlWidgets) widget.mouseDragged(mx, my, button, heldTime);
|
||||
}
|
||||
}
|
||||
@@ -303,14 +264,6 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
public void renderObjects(GuiContainer gui, int mousex, int mousey) {
|
||||
if (!isHidden()) {
|
||||
layout(gui);
|
||||
if (mousePriorX == -1) {
|
||||
mousePriorX = mousex;
|
||||
mousePriorY = mousey;
|
||||
} else if (mousePriorX != mousex || mousePriorY != mousey) {
|
||||
searchFocusInitCancelCheck();
|
||||
mousePriorX = mousex;
|
||||
mousePriorY = mousey;
|
||||
}
|
||||
if (isEnabled()) {
|
||||
getLayoutStyle().drawBackground(GuiContainerManager.getManager(gui));
|
||||
for (Widget widget : drawWidgets) widget.draw(mousex, mousey);
|
||||
@@ -342,6 +295,8 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
public List<String> handleTooltip(GuiContainer gui, int mousex, int mousey, List<String> currenttip) {
|
||||
if (!isHidden() && isEnabled() && GuiContainerManager.shouldShowTooltip(gui)) {
|
||||
for (Widget widget : drawWidgets) currenttip = widget.handleTooltip(mousex, mousey, currenttip);
|
||||
for (IContainerTooltipHandler tip : tooltipWidgets)
|
||||
currenttip = tip.handleTooltip(gui, mousex, mousey, currenttip);
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
@@ -359,15 +314,37 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
currenttip.set(0, mainname);
|
||||
}
|
||||
|
||||
if (!isHidden() && isEnabled() && GuiContainerManager.shouldShowTooltip(gui)) {
|
||||
for (IContainerTooltipHandler tip : tooltipWidgets)
|
||||
currenttip = tip.handleItemDisplayName(gui, stack, currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleItemTooltip(GuiContainer gui, ItemStack itemstack, int mousex, int mousey,
|
||||
List<String> currenttip) {
|
||||
|
||||
if (!isHidden() && isEnabled() && GuiContainerManager.shouldShowTooltip(gui)) {
|
||||
for (IContainerTooltipHandler tip : tooltipWidgets)
|
||||
currenttip = tip.handleItemTooltip(gui, itemstack, mousex, mousey, currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> handleHotkeys(GuiContainer gui, int mousex, int mousey, Map<String, String> hotkeys) {
|
||||
|
||||
if (!isHidden() && isEnabled() && GuiContainerManager.shouldShowTooltip(gui)) {
|
||||
for (IContainerTooltipHandler tip : tooltipWidgets)
|
||||
hotkeys = tip.handleHotkeys(gui, mousex, mousey, hotkeys);
|
||||
}
|
||||
|
||||
return hotkeys;
|
||||
}
|
||||
|
||||
public static void layout(GuiContainer gui) {
|
||||
VisiblityData visiblity = new VisiblityData();
|
||||
|
||||
@@ -403,6 +380,8 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
bookmarkPanel = ItemPanels.bookmarkPanel;
|
||||
bookmarkPanel.init();
|
||||
|
||||
itemZoom = new ItemZoom();
|
||||
|
||||
dropDown = new SubsetWidget();
|
||||
searchField = new SearchField("search");
|
||||
API.addItemFilter(searchField);
|
||||
@@ -427,7 +406,8 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
@Override
|
||||
public boolean onButtonPress(boolean rightclick) {
|
||||
if (!rightclick) {
|
||||
if (Keyboard.getEventKeyState() && getIsAccessibleControlEventKey()) {
|
||||
if (Keyboard.getEventKeyState() && getIsAccessibleControlEventKey()
|
||||
&& NEIClientConfig.canChangeCheatMode()) {
|
||||
NEIClientConfig.cycleSetting("inventory.cheatmode", 3);
|
||||
} else {
|
||||
if (Keyboard.getEventKeyState() && (Keyboard.getEventKey() == Keyboard.KEY_LSHIFT
|
||||
@@ -451,7 +431,10 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
else if (cheatMode == 2) modeColor = EnumChatFormatting.RED.toString();
|
||||
String controlKeyLocalization = translate(Minecraft.isRunningOnMac ? "key.ctrl.mac" : "key.ctrl");
|
||||
tooltip.add(modeColor + translate("inventory.options.tip.cheatmode." + cheatMode));
|
||||
tooltip.add(modeColor + translate("inventory.options.tip.cheatmode.disable", controlKeyLocalization));
|
||||
if (NEIClientConfig.canChangeCheatMode()) {
|
||||
tooltip.add(
|
||||
modeColor + translate("inventory.options.tip.cheatmode.disable", controlKeyLocalization));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -470,7 +453,7 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
|
||||
@Override
|
||||
public boolean onButtonPress(boolean rightclick) {
|
||||
NEIClientConfig.toggleBooleanSetting("inventory.bookmarksEnabled");
|
||||
NEIClientConfig.toggleBooleanSetting("inventory.bookmarks.enabled");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -660,23 +643,14 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
if (isEnabled()) {
|
||||
setInputFocused(null);
|
||||
|
||||
if (!itemsLoaded) {
|
||||
if (!itemsLoaded && isLoaded()) {
|
||||
ItemList.loadItems.restart();
|
||||
itemsLoaded = true;
|
||||
}
|
||||
overlayRenderer = null;
|
||||
|
||||
overlayRenderer = null;
|
||||
getLayoutStyle().init();
|
||||
layout(gui);
|
||||
mousePriorX = -1;
|
||||
mousePriorY = -1;
|
||||
|
||||
if (searchField.isVisible() && NEIClientConfig.searchWidgetAutofocus()
|
||||
&& isAllowedGuiAutoSearchFocus(gui)) {
|
||||
searchField.setFocus(true);
|
||||
setInputFocused(searchField);
|
||||
searchInitFocusedCancellable = true;
|
||||
}
|
||||
AutoFocusWidget.instance.load(gui);
|
||||
}
|
||||
|
||||
NEIController.load(gui);
|
||||
@@ -703,6 +677,7 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
public static void updateWidgetVisiblities(GuiContainer gui, VisiblityData visiblity) {
|
||||
drawWidgets = new TreeSet<>(new WidgetZOrder(false));
|
||||
controlWidgets = new TreeSet<>(new WidgetZOrder(true));
|
||||
tooltipWidgets.clear();
|
||||
|
||||
if (!visiblity.showNEI) return;
|
||||
|
||||
@@ -735,6 +710,8 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
if (canPerformAction("delete")) addWidget(delete);
|
||||
}
|
||||
|
||||
addWidget(itemZoom);
|
||||
|
||||
if (visiblity.showSubsetDropdown) {
|
||||
// Bookmarks or Subset/dropdown
|
||||
addWidget(dropDown);
|
||||
@@ -754,6 +731,10 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
public static void addWidget(Widget widget) {
|
||||
drawWidgets.add(widget);
|
||||
controlWidgets.add(widget);
|
||||
|
||||
if (widget instanceof IContainerTooltipHandler) {
|
||||
tooltipWidgets.add((IContainerTooltipHandler) widget);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -768,7 +749,6 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
@Override
|
||||
public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) {
|
||||
if (isHidden() || !isEnabled()) return false;
|
||||
searchFocusInitCancelCheck();
|
||||
|
||||
for (Widget widget : drawWidgets) if (widget.onMouseWheel(scrolled, mousex, mousey)) return true;
|
||||
|
||||
@@ -876,13 +856,11 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
public static void drawItemPresenceOverlay(int slotX, int slotY, boolean isPresent, boolean slotHighlight) {
|
||||
|
||||
if (slotHighlight) {
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glTranslatef(0, 0, -150);
|
||||
drawRect(slotX, slotY, 16, 16, isPresent ? 0x8000AA00 : 0x80AA0000);
|
||||
GL11.glTranslatef(0, 0, 150);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glPopAttrib();
|
||||
} else {
|
||||
Image icon = itemPresenceOverlays[isPresent ? 1 : 0];
|
||||
drawIcon(slotX + 16 - icon.width, slotY + 16 - icon.height, icon);
|
||||
|
||||
@@ -9,6 +9,7 @@ import static codechicken.nei.LayoutManager.gamemode;
|
||||
import static codechicken.nei.LayoutManager.heal;
|
||||
import static codechicken.nei.LayoutManager.itemPanel;
|
||||
import static codechicken.nei.LayoutManager.itemPresenceOverlays;
|
||||
import static codechicken.nei.LayoutManager.itemZoom;
|
||||
import static codechicken.nei.LayoutManager.magnet;
|
||||
import static codechicken.nei.LayoutManager.options;
|
||||
import static codechicken.nei.LayoutManager.rain;
|
||||
@@ -104,6 +105,7 @@ public class LayoutStyleMinecraft extends LayoutStyle {
|
||||
|
||||
itemPanel.resize(gui);
|
||||
bookmarkPanel.resize(gui);
|
||||
itemZoom.resize(gui);
|
||||
|
||||
options.x = isEnabled() ? 0 : 6;
|
||||
options.y = isEnabled() ? gui.height - 22 : gui.height - 28;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -25,9 +25,11 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParseException;
|
||||
|
||||
import codechicken.core.CCUpdateChecker;
|
||||
import codechicken.core.ClassDiscoverer;
|
||||
import codechicken.core.ClientUtils;
|
||||
import codechicken.core.CommonUtils;
|
||||
import codechicken.lib.config.ConfigFile;
|
||||
@@ -76,12 +78,6 @@ public class NEIClientConfig {
|
||||
public static ConfigSet world;
|
||||
public static final File handlerFile = new File(configDir, "handlers.csv");
|
||||
public static final File catalystFile = new File(configDir, "catalysts.csv");
|
||||
public static final File serialHandlersFile = new File(configDir, "serialhandlers.cfg");
|
||||
public static final File heightHackHandlersFile = new File(configDir, "heighthackhandlers.cfg");
|
||||
public static final File handlerOrderingFile = new File(configDir, "handlerordering.csv");
|
||||
public static final File hiddenHandlersFile = new File(configDir, "hiddenhandlers.csv");
|
||||
public static final File enableAutoFocusFile = new File(configDir, "enableautofocus.cfg");
|
||||
public static final File collapsibleItemsFile = new File(configDir, "collapsibleitems.cfg");
|
||||
|
||||
@Deprecated
|
||||
public static File bookmarkFile;
|
||||
@@ -101,8 +97,7 @@ public class NEIClientConfig {
|
||||
// Any handler not in the map will be assigned to 0, and negative numbers are fine.
|
||||
public static HashMap<String, Integer> handlerOrdering = new HashMap<>();
|
||||
|
||||
// List of prefixes of classes that should enable the autofocus search widget on open.
|
||||
public static ArrayList<String> enableAutoFocusPrefixes = new ArrayList<>();
|
||||
public static final Set<Class<?>> pluginsList = new HashSet<>();
|
||||
|
||||
// Function that extracts the handler ID from a handler, with special logic for
|
||||
// TemplateRecipeHandler: prefer using the overlay ID if it exists.
|
||||
@@ -162,7 +157,7 @@ public class NEIClientConfig {
|
||||
return getLockedMode() == -1 || getLockedMode() == index && NEIInfo.isValidMode(index);
|
||||
}
|
||||
});
|
||||
checkCheatMode();
|
||||
canChangeCheatMode();
|
||||
|
||||
tag.getTag("inventory.utilities").setDefaultValue("delete, magnet");
|
||||
API.addOption(new OptionUtilities("inventory.utilities"));
|
||||
@@ -171,76 +166,75 @@ public class NEIClientConfig {
|
||||
API.addOption(new OptionGamemodes("inventory.gamemodes"));
|
||||
|
||||
ItemSorter.initConfig(tag);
|
||||
setInventorySearchDefaults(tag);
|
||||
|
||||
tag.getTag("inventory.search.widgetPosition").setComment("Widget Position").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.search.widgetPosition", true));
|
||||
tag.getTag("inventory.bookmarks.enabled").setComment("Enable/Disable Bookmark Panel").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.bookmarks.enabled", true));
|
||||
|
||||
tag.getTag("inventory.search.widgetAutofocus")
|
||||
.setComment(
|
||||
"Focus Search Widget on Open, blurs/unfocuses on mouse move unless typing has started first")
|
||||
tag.getTag("inventory.bookmarks.worldSpecific").setComment("Global or world specific bookmarks")
|
||||
.getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.search.widgetAutofocus", true));
|
||||
API.addOption(new OptionToggleButton("inventory.bookmarks.worldSpecific", true) {
|
||||
|
||||
tag.getTag("inventory.search.patternMode").setComment("Search Mode").getIntValue(1);
|
||||
API.addOption(new OptionCycled("inventory.search.patternMode", 3, true));
|
||||
@Override
|
||||
public boolean onClick(int button) {
|
||||
super.onClick(button);
|
||||
ItemPanels.bookmarkPanel.load();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
tag.getTag("inventory.search.quoteDropItemName").setComment("Quote Drop Item Name").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.search.quoteDropItemName", true));
|
||||
tag.getTag("inventory.bookmarks.animation").setComment("REI Style Animation in Bookmarks")
|
||||
.getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.bookmarks.animation", true));
|
||||
|
||||
tag.getTag("inventory.search.modNameSearchMode").setComment("Search mode for Mod Names (prefix: @)")
|
||||
tag.getTag("inventory.bookmarks.recipeTooltipsMode").setComment("Show recipe tooltips in Bookmarks")
|
||||
.getIntValue(1);
|
||||
API.addOption(new OptionCycled("inventory.search.modNameSearchMode", 3, true) {
|
||||
API.addOption(new OptionCycled("inventory.bookmarks.recipeTooltipsMode", 4, true));
|
||||
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return translateN(name + "." + value(), EnumChatFormatting.LIGHT_PURPLE + "@");
|
||||
}
|
||||
tag.getTag("inventory.bookmarks.showRecipeMarker").setComment("Show Recipe Marker").getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.bookmarks.showRecipeMarker", true));
|
||||
|
||||
});
|
||||
tag.getTag("inventory.bookmarks.craftingChainDir").getIntValue(1);
|
||||
API.addOption(new OptionCycled("inventory.bookmarks.craftingChainDir", 2, true));
|
||||
|
||||
tag.getTag("inventory.search.tooltipSearchMode").setComment("Search mode for Tooltips (prefix: #)")
|
||||
.getIntValue(0);
|
||||
API.addOption(new OptionCycled("inventory.search.tooltipSearchMode", 3, true) {
|
||||
tag.getTag("inventory.bookmarks.ignorePotionOverlap").setComment("Ignore overlap with potion effect HUD")
|
||||
.getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.bookmarks.ignorePotionOverlap", true));
|
||||
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return translateN(name + "." + value(), EnumChatFormatting.YELLOW + "#");
|
||||
}
|
||||
tag.getTag("inventory.guirecipe.jeiStyleTabs").setComment("Enable/disable JEI Style Tabs")
|
||||
.getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButtonBoubs("inventory.guirecipe.jeiStyleTabs", true));
|
||||
|
||||
});
|
||||
tag.getTag("inventory.guirecipe.jeiStyleRecipeCatalyst").setComment("Enable/disable JEI Style Recipe Catalysts")
|
||||
.getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.guirecipe.jeiStyleRecipeCatalyst", true));
|
||||
|
||||
tag.getTag("inventory.search.identifierSearchMode").setComment("Search mode for identifier (prefix: &)")
|
||||
.getIntValue(0);
|
||||
API.addOption(new OptionCycled("inventory.search.identifierSearchMode", 3, true) {
|
||||
tag.getTag("inventory.guirecipe.jeiStyleCycledIngredients").setComment("JEI styled cycled ingredients")
|
||||
.getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.guirecipe.jeiStyleCycledIngredients", true));
|
||||
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return translateN(name + "." + value(), EnumChatFormatting.GOLD + "&");
|
||||
}
|
||||
tag.getTag("inventory.guirecipe.cycledIngredientsTooltip").setComment("Show cycled ingredients tooltip")
|
||||
.getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.guirecipe.cycledIngredientsTooltip", true));
|
||||
|
||||
});
|
||||
tag.getTag("inventory.guirecipe.creativeTabStyle").setComment("Creative or JEI style tabs")
|
||||
.getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.guirecipe.creativeTabStyle", true));
|
||||
|
||||
tag.getTag("inventory.search.oreDictSearchMode").setComment("Search mode for Tag Names (prefix: $)")
|
||||
.getIntValue(0);
|
||||
API.addOption(new OptionCycled("inventory.search.oreDictSearchMode", 3, true) {
|
||||
tag.getTag("inventory.guirecipe.itemPresenceOverlay").setComment("Item presence overlay on ?-hover")
|
||||
.getIntValue(1);
|
||||
API.addOption(new OptionCycled("inventory.guirecipe.itemPresenceOverlay", 3, true));
|
||||
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return translateN(name + "." + value(), EnumChatFormatting.AQUA + "$");
|
||||
}
|
||||
tag.getTag("inventory.guirecipe.slotHighlightPresent").setComment("Highlight Present Item")
|
||||
.getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.guirecipe.slotHighlightPresent", true));
|
||||
|
||||
});
|
||||
tag.getTag("inventory.guirecipe.shiftOverlayRecipe")
|
||||
.setComment("Require holding shift to move items when overlaying recipe").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.guirecipe.shiftOverlayRecipe", true));
|
||||
|
||||
tag.getTag("inventory.search.subsetsSearchMode").setComment("Search mode for Item Subsets (prefix: %)")
|
||||
.getIntValue(2);
|
||||
API.addOption(new OptionCycled("inventory.search.subsetsSearchMode", 3, true) {
|
||||
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return translateN(name + "." + value(), EnumChatFormatting.DARK_PURPLE + "%");
|
||||
}
|
||||
|
||||
});
|
||||
tag.getTag("inventory.guirecipe.profile").getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.guirecipe.profile", true));
|
||||
|
||||
tag.getTag("inventory.history.enabled").setComment("Enable/disable History Panel").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.history.enabled", true));
|
||||
@@ -260,11 +254,17 @@ public class NEIClientConfig {
|
||||
|
||||
@Override
|
||||
public boolean onClick(int button) {
|
||||
super.onClick(button);
|
||||
CollapsibleItems.saveStates();
|
||||
CollapsibleItems.load();
|
||||
LayoutManager.markItemsDirty();
|
||||
return super.onClick(button);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
tag.getTag("inventory.collapsibleItems.customName").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.collapsibleItems.customName", true));
|
||||
|
||||
tag.getTag("inventory.collapsibleItems.expandedColor")
|
||||
.setComment("Color of the collapsible item expanded state").getHexValue(0x335555EE);
|
||||
API.addOption(new OptionIntegerField("inventory.collapsibleItems.expandedColor"));
|
||||
@@ -286,6 +286,31 @@ public class NEIClientConfig {
|
||||
}
|
||||
});
|
||||
|
||||
tag.getTag("inventory.itemzoom.enabled").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.itemzoom.enabled", true));
|
||||
|
||||
tag.getTag("inventory.itemzoom.neiOnly")
|
||||
.setComment("Zoom items only from the JEI ingredient and bookmark list overlays.")
|
||||
.getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.itemzoom.neiOnly", true));
|
||||
|
||||
tag.getTag("inventory.itemzoom.onlySolid").getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.itemzoom.onlySolid", true));
|
||||
|
||||
tag.getTag("inventory.itemzoom.helpText")
|
||||
.setComment("Display name \"Item Zoom\" and the hotkey to toggle this mod below the zoomed item.")
|
||||
.getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.itemzoom.helpText", true));
|
||||
|
||||
tag.getTag("inventory.itemzoom.zoom").getIntValue(500);
|
||||
API.addOption(new OptionIntegerField("inventory.itemzoom.zoom", ItemZoom.MIN_ZOOM, ItemZoom.MAX_ZOOM));
|
||||
|
||||
tag.getTag("inventory.itemzoom.showName").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.itemzoom.showName", true));
|
||||
|
||||
tag.getTag("inventory.itemzoom.nameColor").getHexValue(0xFFFFFFFF);
|
||||
API.addOption(new OptionIntegerField("inventory.itemzoom.nameColor"));
|
||||
|
||||
tag.getTag("inventory.itemIDs").getIntValue(1);
|
||||
API.addOption(new OptionCycled("inventory.itemIDs", 3, true));
|
||||
|
||||
@@ -308,9 +333,6 @@ public class NEIClientConfig {
|
||||
|
||||
API.addOption(new OptionOpenGui("world.presets", GuiPresetList.class));
|
||||
|
||||
tag.getTag("inventory.profileRecipes").getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.profileRecipes", true));
|
||||
|
||||
tag.getTag("inventory.disableMouseScrollTransfer").getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.disableMouseScrollTransfer", true));
|
||||
|
||||
@@ -339,83 +361,13 @@ public class NEIClientConfig {
|
||||
tag.getTag("command.heal").setDefaultValue("");
|
||||
API.addOption(new OptionTextField("command.heal"));
|
||||
|
||||
tag.getTag("inventory.worldSpecificBookmarks").setComment("Global or world specific bookmarks")
|
||||
.getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.worldSpecificBookmarks", true) {
|
||||
|
||||
@Override
|
||||
public boolean onClick(int button) {
|
||||
super.onClick(button);
|
||||
initBookmarkFile(worldPath);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
tag.getTag("inventory.worldSpecificPresets").setComment("Global or world specific presets")
|
||||
.getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.worldSpecificPresets", true) {
|
||||
|
||||
@Override
|
||||
public boolean onClick(int button) {
|
||||
super.onClick(button);
|
||||
initPresetsFile(worldPath);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
tag.getTag("inventory.bookmarksEnabled").setComment("Enable/disable bookmarks").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.bookmarksEnabled", true));
|
||||
|
||||
tag.getTag("inventory.bookmarksAnimationEnabled").setComment("REI Style Animation in Bookmarks")
|
||||
.getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.bookmarksAnimationEnabled", true));
|
||||
|
||||
tag.getTag("inventory.recipeTooltipsMode").setComment("Show recipe tooltips in Bookmarks").getIntValue(1);
|
||||
API.addOption(new OptionCycled("inventory.recipeTooltipsMode", 4, true));
|
||||
|
||||
tag.getTag("inventory.showRecipeMarker").setComment("Show Recipe Marker").getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.showRecipeMarker", true));
|
||||
|
||||
tag.getTag("inventory.showItemQuantityWidget").setComment("Show Item Quantity Widget").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.showItemQuantityWidget", true));
|
||||
|
||||
tag.getTag("inventory.firstInvCloseClosesInSearch").setComment(
|
||||
"Pressing the open inventory key when the inventory was just opened when the search is focused will close it instead of typing in the search")
|
||||
.getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.firstInvCloseClosesInSearch", true));
|
||||
|
||||
tag.getTag("inventory.jei_style_tabs").setComment("Enable/disable JEI Style Tabs").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButtonBoubs("inventory.jei_style_tabs", true));
|
||||
|
||||
tag.getTag("inventory.itemPresenceOverlay").setComment("Item presence overlay on ?-hover").getIntValue(1);
|
||||
API.addOption(new OptionCycled("inventory.itemPresenceOverlay", 3, true));
|
||||
|
||||
tag.getTag("inventory.slotHighlightPresent").setComment("Highlight Present Item").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.slotHighlightPresent", true));
|
||||
|
||||
tag.getTag("inventory.jei_style_recipe_catalyst").setComment("Enable/disable JEI Style Recipe Catalysts")
|
||||
.getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.jei_style_recipe_catalyst", true));
|
||||
|
||||
tag.getTag("inventory.creative_tab_style").setComment("Creative or JEI style tabs").getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.creative_tab_style", true));
|
||||
|
||||
tag.getTag("inventory.ignore_potion_overlap").setComment("Ignore overlap with potion effect HUD")
|
||||
.getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.ignore_potion_overlap", true));
|
||||
|
||||
tag.getTag("inventory.optimize_gui_overlap_computation").setComment("Optimize computation for GUI overlap")
|
||||
.getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.optimize_gui_overlap_computation", true));
|
||||
|
||||
tag.getTag("inventory.jei_style_cycled_ingredients").setComment("JEI styled cycled ingredients")
|
||||
.getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.jei_style_cycled_ingredients", true));
|
||||
|
||||
tag.getTag("inventory.shift_overlay_recipe")
|
||||
.setComment("Require holding shift to move items when overlaying recipe").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.shift_overlay_recipe", true));
|
||||
|
||||
tag.getTag("tools.handler_load_from_config").setComment("ADVANCED: Load handlers from config")
|
||||
.getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("tools.handler_load_from_config", true) {
|
||||
@@ -468,6 +420,207 @@ public class NEIClientConfig {
|
||||
});
|
||||
}
|
||||
|
||||
private static void setInventorySearchDefaults(ConfigTagParent tag) {
|
||||
|
||||
tag.getTag("inventory.search.widgetPosition").setComment("Widget Position").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.search.widgetPosition", true));
|
||||
|
||||
tag.getTag("inventory.search.widgetAutofocus")
|
||||
.setComment(
|
||||
"Focus Search Widget on Open, blurs/unfocuses on mouse move unless typing has started first")
|
||||
.getIntValue(0);
|
||||
API.addOption(new OptionCycled("inventory.search.widgetAutofocus", 3, true));
|
||||
|
||||
tag.getTag("inventory.search.patternMode").setComment("Search Mode").getIntValue(1);
|
||||
API.addOption(new OptionCycled("inventory.search.patternMode", 3, true) {
|
||||
|
||||
@Override
|
||||
public boolean onClick(int button) {
|
||||
SearchField.searchParser.clearCache();
|
||||
return super.onClick(button);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
tag.getTag("inventory.search.quoteDropItemName").setComment("Quote Drop Item Name").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.search.quoteDropItemName", true));
|
||||
|
||||
tag.getTag("inventory.search.format").setComment("Search Format (true: old format, false: custom format)")
|
||||
.getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.search.format", true) {
|
||||
|
||||
@Override
|
||||
public boolean onClick(int button) {
|
||||
|
||||
if (!super.onClick(button)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (state()) {
|
||||
NEIClientConfig.setIntSetting("inventory.search.modNameSearchMode", 0);
|
||||
NEIClientConfig.setIntSetting("inventory.search.tooltipSearchMode", 0);
|
||||
NEIClientConfig.setIntSetting("inventory.search.identifierSearchMode", 0);
|
||||
NEIClientConfig.setIntSetting("inventory.search.oreDictSearchMode", 0);
|
||||
NEIClientConfig.setIntSetting("inventory.search.subsetsSearchMode", 1);
|
||||
tag.getTag("inventory.search.prefixRedefinitions").setValue("{\"%\": \"@\", \"@\": \"%\"}");
|
||||
SearchField.searchParser.prefixRedefinitions.clear();
|
||||
SearchField.searchParser.prefixRedefinitions.put('%', '@');
|
||||
SearchField.searchParser.prefixRedefinitions.put('@', '%');
|
||||
SearchField.searchParser.clearCache();
|
||||
} else {
|
||||
NEIClientConfig.setIntSetting("inventory.search.modNameSearchMode", 1);
|
||||
NEIClientConfig.setIntSetting("inventory.search.tooltipSearchMode", 0);
|
||||
NEIClientConfig.setIntSetting("inventory.search.identifierSearchMode", 0);
|
||||
NEIClientConfig.setIntSetting("inventory.search.oreDictSearchMode", 0);
|
||||
NEIClientConfig.setIntSetting("inventory.search.subsetsSearchMode", 1);
|
||||
tag.getTag("inventory.search.prefixRedefinitions").setValue("{}");
|
||||
SearchField.searchParser.prefixRedefinitions.clear();
|
||||
SearchField.searchParser.clearCache();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
tag.getTag("inventory.search.modNameSearchMode").setComment("Search mode for Mod Names (prefix: @)")
|
||||
.getIntValue(1);
|
||||
API.addOption(new OptionCycled("inventory.search.modNameSearchMode", 3, true) {
|
||||
|
||||
@Override
|
||||
public boolean onClick(int button) {
|
||||
SearchField.searchParser.clearCache();
|
||||
return super.onClick(button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return translateN(
|
||||
name + "." + value(),
|
||||
EnumChatFormatting.LIGHT_PURPLE
|
||||
+ String.valueOf(SearchField.searchParser.getRedefinedPrefix('@')));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return !tag.getTag("inventory.search.format").getBooleanValue();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
tag.getTag("inventory.search.tooltipSearchMode").setComment("Search mode for Tooltips (prefix: #)")
|
||||
.getIntValue(0);
|
||||
API.addOption(new OptionCycled("inventory.search.tooltipSearchMode", 3, true) {
|
||||
|
||||
@Override
|
||||
public boolean onClick(int button) {
|
||||
SearchField.searchParser.clearCache();
|
||||
return super.onClick(button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return translateN(
|
||||
name + "." + value(),
|
||||
EnumChatFormatting.YELLOW + String.valueOf(SearchField.searchParser.getRedefinedPrefix('#')));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return !tag.getTag("inventory.search.format").getBooleanValue();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
tag.getTag("inventory.search.identifierSearchMode").setComment("Search mode for identifier (prefix: &)")
|
||||
.getIntValue(0);
|
||||
API.addOption(new OptionCycled("inventory.search.identifierSearchMode", 3, true) {
|
||||
|
||||
@Override
|
||||
public boolean onClick(int button) {
|
||||
SearchField.searchParser.clearCache();
|
||||
return super.onClick(button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return translateN(
|
||||
name + "." + value(),
|
||||
EnumChatFormatting.GOLD + String.valueOf(SearchField.searchParser.getRedefinedPrefix('&')));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return !tag.getTag("inventory.search.format").getBooleanValue();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
tag.getTag("inventory.search.oreDictSearchMode").setComment("Search mode for Tag Names (prefix: $)")
|
||||
.getIntValue(0);
|
||||
API.addOption(new OptionCycled("inventory.search.oreDictSearchMode", 3, true) {
|
||||
|
||||
@Override
|
||||
public boolean onClick(int button) {
|
||||
SearchField.searchParser.clearCache();
|
||||
return super.onClick(button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return translateN(
|
||||
name + "." + value(),
|
||||
EnumChatFormatting.AQUA + String.valueOf(SearchField.searchParser.getRedefinedPrefix('$')));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return !tag.getTag("inventory.search.format").getBooleanValue();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
tag.getTag("inventory.search.subsetsSearchMode").setComment("Search mode for Item Subsets (prefix: %)")
|
||||
.getIntValue(1);
|
||||
API.addOption(new OptionCycled("inventory.search.subsetsSearchMode", 3, true) {
|
||||
|
||||
@Override
|
||||
public boolean onClick(int button) {
|
||||
SearchField.searchParser.clearCache();
|
||||
return super.onClick(button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return translateN(
|
||||
name + "." + value(),
|
||||
EnumChatFormatting.DARK_PURPLE
|
||||
+ String.valueOf(SearchField.searchParser.getRedefinedPrefix('%')));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return !tag.getTag("inventory.search.format").getBooleanValue();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
String prefixRedefinitions = tag.getTag("inventory.search.prefixRedefinitions").setComment(
|
||||
"Redefine search prefixes by providing a char-to-char map (JSON). The keys are the original prefixes, the values the new ones. Example: { \"$\": \"€\", \"#\": \"+\", \"@\": \"°\", \"%\": \"!\" }")
|
||||
.getValue("{}");
|
||||
try {
|
||||
TypeToken<Map<Character, Character>> typeToken = new TypeToken<Map<Character, Character>>() {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
};
|
||||
Map<Character, Character> charMap = new Gson().fromJson(prefixRedefinitions, typeToken.getType());
|
||||
SearchField.searchParser.prefixRedefinitions.putAll(charMap);
|
||||
} catch (JsonParseException e) {
|
||||
logger.warn("Failed to convert prefix redefinitions from JSON to CharToCharMap:", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void setDefaultKeyBindings() {
|
||||
API.addHashBind("gui.recipe", Keyboard.KEY_R);
|
||||
API.addHashBind("gui.usage", Keyboard.KEY_U);
|
||||
@@ -484,6 +637,7 @@ public class NEIClientConfig {
|
||||
API.addHashBind("gui.search", Keyboard.KEY_F);
|
||||
API.addHashBind("gui.bookmark", Keyboard.KEY_A);
|
||||
API.addHashBind("gui.bookmark_recipe", Keyboard.KEY_A + NEIClientUtils.SHIFT_HASH);
|
||||
API.addHashBind("gui.remove_recipe", Keyboard.KEY_A + NEIClientUtils.SHIFT_HASH);
|
||||
API.addHashBind("gui.bookmark_count", Keyboard.KEY_A + NEIClientUtils.CTRL_HASH);
|
||||
API.addHashBind(
|
||||
"gui.bookmark_recipe_count",
|
||||
@@ -498,6 +652,11 @@ public class NEIClientConfig {
|
||||
API.addKeyBind("gui.getnextsearch", Keyboard.KEY_DOWN);
|
||||
API.addHashBind("gui.next_tooltip", Keyboard.KEY_Z);
|
||||
|
||||
API.addHashBind("gui.itemzoom_toggle", Keyboard.KEY_Z + NEIClientUtils.SHIFT_HASH);
|
||||
API.addHashBind("gui.itemzoom_hold", 0);
|
||||
API.addHashBind("gui.itemzoom_zoom_in", 0);
|
||||
API.addHashBind("gui.itemzoom_zoom_out", 0);
|
||||
|
||||
API.addKeyBind("world.chunkoverlay", Keyboard.KEY_F9);
|
||||
API.addKeyBind("world.moboverlay", Keyboard.KEY_F7);
|
||||
API.addKeyBind("world.highlight_tips", Keyboard.KEY_NUMPAD0);
|
||||
@@ -517,11 +676,11 @@ public class NEIClientConfig {
|
||||
}
|
||||
|
||||
public static void loadWorld(String worldPath) {
|
||||
unloadWorld();
|
||||
NEIClientConfig.worldPath = worldPath;
|
||||
|
||||
setInternalEnabled(true);
|
||||
logger.debug("Loading " + (Minecraft.getMinecraft().isSingleplayer() ? "Local" : "Remote") + " World");
|
||||
bootNEI(ClientUtils.getWorld());
|
||||
|
||||
final File specificDir = new File(CommonUtils.getMinecraftDir(), "saves/NEI/" + worldPath);
|
||||
final boolean newWorld = !specificDir.exists();
|
||||
@@ -530,12 +689,17 @@ public class NEIClientConfig {
|
||||
specificDir.mkdirs();
|
||||
}
|
||||
|
||||
initBookmarkFile(worldPath);
|
||||
initPresetsFile(worldPath);
|
||||
world = new ConfigSet(new File(specificDir, "NEI.dat"), new ConfigFile(new File(specificDir, "NEI.cfg")));
|
||||
bootNEI(ClientUtils.getWorld());
|
||||
CollapsibleItems.load();
|
||||
ItemPanels.bookmarkPanel.load();
|
||||
onWorldLoad(newWorld);
|
||||
}
|
||||
|
||||
public static String getWorldPath() {
|
||||
return NEIClientConfig.worldPath;
|
||||
}
|
||||
|
||||
private static void onWorldLoad(boolean newWorld) {
|
||||
world.config.setComment(
|
||||
"World based configuration of NEI.\nMost of these options can be changed ingame.\nDeleting any element will restore it to it's default value");
|
||||
@@ -566,6 +730,8 @@ public class NEIClientConfig {
|
||||
ItemPanels.bookmarkPanel.saveBookmarks();
|
||||
}
|
||||
|
||||
CollapsibleItems.saveStates();
|
||||
|
||||
if (world != null) {
|
||||
world.saveNBT();
|
||||
}
|
||||
@@ -587,101 +753,61 @@ public class NEIClientConfig {
|
||||
return hash != Keyboard.CHAR_NONE && hash == NEIClientUtils.getKeyHash();
|
||||
}
|
||||
|
||||
public static String getKeyName(int keyBind, boolean useHash) {
|
||||
return getKeyName(keyBind, useHash, false);
|
||||
}
|
||||
public static String getKeyName(String keyBind) {
|
||||
final int hash = getKeyBinding(keyBind);
|
||||
|
||||
public static String getKeyName(int keyBind, boolean useHash, boolean showOnlyHash) {
|
||||
String keyText = "";
|
||||
|
||||
if (useHash) {
|
||||
final String DELIMITER = " + ";
|
||||
if ((keyBind & NEIClientUtils.CTRL_HASH) != 0) {
|
||||
keyText += NEIClientUtils.translate(Minecraft.isRunningOnMac ? "key.ctrl.mac" : "key.ctrl") + DELIMITER;
|
||||
}
|
||||
if ((keyBind & NEIClientUtils.SHIFT_HASH) != 0) {
|
||||
keyText += "SHIFT" + DELIMITER;
|
||||
}
|
||||
if ((keyBind & NEIClientUtils.ALT_HASH) != 0) {
|
||||
keyText += "ALT" + DELIMITER;
|
||||
}
|
||||
if (hash == Keyboard.CHAR_NONE) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!showOnlyHash) {
|
||||
keyText += Keyboard.getKeyName(unHashKey(keyBind));
|
||||
}
|
||||
return keyText;
|
||||
}
|
||||
|
||||
public static int unHashKey(int keyBind) {
|
||||
return keyBind & ~(NEIClientUtils.CTRL_HASH | NEIClientUtils.SHIFT_HASH | NEIClientUtils.ALT_HASH);
|
||||
return NEIClientUtils.getKeyName(hash);
|
||||
}
|
||||
|
||||
public static void bootNEI(World world) {
|
||||
if (mainNEIConfigLoaded) return;
|
||||
if (!mainNEIConfigLoaded) {
|
||||
// main NEI config loading
|
||||
ItemInfo.load(world);
|
||||
GuiInfo.load();
|
||||
RecipeInfo.load();
|
||||
HeldItemHandler.load();
|
||||
LayoutManager.load();
|
||||
NEIController.load();
|
||||
BookmarkContainerInfo.load();
|
||||
mainNEIConfigLoaded = true;
|
||||
|
||||
// main NEI config loading
|
||||
ItemInfo.load(world);
|
||||
GuiInfo.load();
|
||||
RecipeInfo.load();
|
||||
LayoutManager.load();
|
||||
NEIController.load();
|
||||
BookmarkContainerInfo.load();
|
||||
mainNEIConfigLoaded = true;
|
||||
new Thread("NEI Plugin Loader") {
|
||||
|
||||
new Thread("NEI Plugin Loader") {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
logger.debug("Started NEI plugin loading");
|
||||
ClassDiscoverer classDiscoverer = new ClassDiscoverer(
|
||||
test -> test.startsWith("NEI") && test.endsWith("Config.class"),
|
||||
IConfigureNEI.class);
|
||||
NEIClientConfig.pluginsList.parallelStream().forEach(clazz -> {
|
||||
try {
|
||||
IConfigureNEI config = (IConfigureNEI) clazz.getConstructor().newInstance();
|
||||
config.loadConfig();
|
||||
NEIModContainer.plugins.add(config);
|
||||
logger.debug("Loaded {}", clazz.getName());
|
||||
} catch (Throwable e) {
|
||||
logger.error("Failed to Load {}", clazz.getName(), e);
|
||||
}
|
||||
});
|
||||
|
||||
classDiscoverer.findClasses();
|
||||
RecipeCatalysts.loadCatalystInfo();
|
||||
ItemSorter.loadConfig();
|
||||
|
||||
for (Class<?> clazz : classDiscoverer.classes) {
|
||||
try {
|
||||
IConfigureNEI config = (IConfigureNEI) clazz.newInstance();
|
||||
config.loadConfig();
|
||||
NEIModContainer.plugins.add(config);
|
||||
logger.debug("Loaded " + clazz.getName());
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed to Load " + clazz.getName(), e);
|
||||
}
|
||||
// Set pluginNEIConfigLoaded here before posting the NEIConfigsLoadedEvent. This used to be the
|
||||
// other way around, but apparently if your modpack includes 800 mods the event poster might not
|
||||
// return in time and cause issues when loading a world for a second time as configLoaded is still
|
||||
// false. This may cause issues in case one of the event handler calls the (non-thread-safe) NEI
|
||||
// API. I don't expect any handler to do this, but who knows what modders have come up with...
|
||||
pluginNEIConfigLoaded = true;
|
||||
MinecraftForge.EVENT_BUS.post(new NEIConfigsLoadedEvent());
|
||||
|
||||
ItemList.loadItems.restart();
|
||||
}
|
||||
|
||||
RecipeCatalysts.loadCatalystInfo();
|
||||
|
||||
// Set pluginNEIConfigLoaded here before posting the NEIConfigsLoadedEvent. This used to be the other
|
||||
// way around, but apparently if your modpack includes 800 mods the event poster might not return in
|
||||
// time and cause issues when loading a world for a second time as configLoaded is still false. This may
|
||||
// cause issues in case one of the event handler calls the (non-thread-safe) NEI API. I don't expect any
|
||||
// handler to do this, but who knows what modders have come up with...
|
||||
pluginNEIConfigLoaded = true;
|
||||
logger.debug("NEI plugin loading finished");
|
||||
MinecraftForge.EVENT_BUS.post(new NEIConfigsLoadedEvent());
|
||||
}
|
||||
}.start();
|
||||
ItemSorter.loadConfig();
|
||||
}
|
||||
|
||||
private static void initBookmarkFile(String worldPath) {
|
||||
|
||||
if (!global.config.getTag("inventory.worldSpecificBookmarks").getBooleanValue()) {
|
||||
worldPath = "global";
|
||||
}.start();
|
||||
} else {
|
||||
ItemList.loadItems.restart();
|
||||
}
|
||||
|
||||
ItemPanels.bookmarkPanel.setBookmarkFile(worldPath);
|
||||
}
|
||||
|
||||
private static void initPresetsFile(String worldPath) {
|
||||
|
||||
if (!global.config.getTag("inventory.worldSpecificPresets").getBooleanValue()) {
|
||||
worldPath = "global";
|
||||
}
|
||||
|
||||
PresetsList.setPresetsFile(worldPath);
|
||||
}
|
||||
|
||||
public static boolean isWorldSpecific(String setting) {
|
||||
@@ -703,19 +829,19 @@ public class NEIClientConfig {
|
||||
}
|
||||
|
||||
public static boolean isBookmarkPanelHidden() {
|
||||
return !getBooleanSetting("inventory.bookmarksEnabled");
|
||||
return !getBooleanSetting("inventory.bookmarks.enabled");
|
||||
}
|
||||
|
||||
public static boolean areBookmarksAnimated() {
|
||||
return getBooleanSetting("inventory.bookmarksAnimationEnabled");
|
||||
return getBooleanSetting("inventory.bookmarks.animation");
|
||||
}
|
||||
|
||||
public static int getRecipeTooltipsMode() {
|
||||
return getIntSetting("inventory.recipeTooltipsMode");
|
||||
return getIntSetting("inventory.bookmarks.recipeTooltipsMode");
|
||||
}
|
||||
|
||||
public static boolean showRecipeMarker() {
|
||||
return getBooleanSetting("inventory.showRecipeMarker");
|
||||
return getBooleanSetting("inventory.bookmarks.showRecipeMarker");
|
||||
}
|
||||
|
||||
public static boolean showItemQuantityWidget() {
|
||||
@@ -726,36 +852,36 @@ public class NEIClientConfig {
|
||||
return getBooleanSetting("inventory.search.widgetPosition");
|
||||
}
|
||||
|
||||
public static boolean searchWidgetAutofocus() {
|
||||
return getBooleanSetting("inventory.search.widgetAutofocus");
|
||||
}
|
||||
|
||||
public static boolean isFirstInvCloseClosesInSearch() {
|
||||
return getBooleanSetting("inventory.firstInvCloseClosesInSearch");
|
||||
public static int searchWidgetAutofocus() {
|
||||
return getIntSetting("inventory.search.widgetAutofocus");
|
||||
}
|
||||
|
||||
public static boolean areJEIStyleTabsVisible() {
|
||||
return getBooleanSetting("inventory.jei_style_tabs");
|
||||
return getBooleanSetting("inventory.guirecipe.jeiStyleTabs");
|
||||
}
|
||||
|
||||
public static int itemPresenceOverlay() {
|
||||
return getIntSetting("inventory.itemPresenceOverlay");
|
||||
return getIntSetting("inventory.guirecipe.itemPresenceOverlay");
|
||||
}
|
||||
|
||||
public static boolean isSlotHighlightPresent() {
|
||||
return getBooleanSetting("inventory.slotHighlightPresent");
|
||||
return getBooleanSetting("inventory.guirecipe.slotHighlightPresent");
|
||||
}
|
||||
|
||||
public static boolean areJEIStyleRecipeCatalystsVisible() {
|
||||
return getBooleanSetting("inventory.jei_style_recipe_catalyst");
|
||||
return getBooleanSetting("inventory.guirecipe.jeiStyleRecipeCatalyst");
|
||||
}
|
||||
|
||||
public static boolean useCreativeTabStyle() {
|
||||
return getBooleanSetting("inventory.creative_tab_style");
|
||||
return getBooleanSetting("inventory.guirecipe.creativeTabStyle");
|
||||
}
|
||||
|
||||
public static boolean ignorePotionOverlap() {
|
||||
return getBooleanSetting("inventory.ignore_potion_overlap");
|
||||
return getBooleanSetting("inventory.bookmarks.ignorePotionOverlap");
|
||||
}
|
||||
|
||||
public static int craftingChainDir() {
|
||||
return getIntSetting("inventory.bookmarks.craftingChainDir");
|
||||
}
|
||||
|
||||
public static boolean optimizeGuiOverlapComputation() {
|
||||
@@ -763,11 +889,15 @@ public class NEIClientConfig {
|
||||
}
|
||||
|
||||
public static boolean useJEIStyledCycledIngredients() {
|
||||
return getBooleanSetting("inventory.jei_style_cycled_ingredients");
|
||||
return getBooleanSetting("inventory.guirecipe.jeiStyleCycledIngredients");
|
||||
}
|
||||
|
||||
public static boolean showCycledIngredientsTooltip() {
|
||||
return getBooleanSetting("inventory.guirecipe.cycledIngredientsTooltip");
|
||||
}
|
||||
|
||||
public static boolean requireShiftForOverlayRecipe() {
|
||||
return getBooleanSetting("inventory.shift_overlay_recipe");
|
||||
return getBooleanSetting("inventory.guirecipe.shiftOverlayRecipe");
|
||||
}
|
||||
|
||||
public static boolean isEnabled() {
|
||||
@@ -787,7 +917,7 @@ public class NEIClientConfig {
|
||||
}
|
||||
|
||||
public static boolean isProfileRecipeEnabled() {
|
||||
return NEIClientConfig.getBooleanSetting("inventory.profileRecipes");
|
||||
return NEIClientConfig.getBooleanSetting("inventory.guirecipe.profile");
|
||||
}
|
||||
|
||||
public static void setEnabled(boolean flag) {
|
||||
@@ -802,8 +932,13 @@ public class NEIClientConfig {
|
||||
return getIntSetting("inventory.cheatmode");
|
||||
}
|
||||
|
||||
private static void checkCheatMode() {
|
||||
if (getLockedMode() != -1) setIntSetting("inventory.cheatmode", getLockedMode());
|
||||
public static boolean canChangeCheatMode() {
|
||||
if (getLockedMode() != -1) {
|
||||
setIntSetting("inventory.cheatmode", getLockedMode());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int getLockedMode() {
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -36,8 +37,6 @@ import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
@@ -58,11 +57,26 @@ public class NEIClientUtils extends NEIServerUtils {
|
||||
|
||||
/** Formats a number with group separator and at most 2 fraction digits. */
|
||||
private static final Map<Locale, DecimalFormat> decimalFormatters = new HashMap<>();
|
||||
private static final Map<Integer, Integer> keyHashMap = new HashMap<>();
|
||||
|
||||
public static final int ALT_HASH = 1 << 27;
|
||||
public static final int SHIFT_HASH = 1 << 26;
|
||||
public static final int CTRL_HASH = 1 << 25;
|
||||
|
||||
static {
|
||||
keyHashMap.put(Keyboard.KEY_LSHIFT, SHIFT_HASH);
|
||||
keyHashMap.put(Keyboard.KEY_RSHIFT, SHIFT_HASH);
|
||||
|
||||
keyHashMap.put(Keyboard.KEY_LCONTROL, CTRL_HASH);
|
||||
keyHashMap.put(Keyboard.KEY_LCONTROL, CTRL_HASH);
|
||||
|
||||
keyHashMap.put(Keyboard.KEY_LMETA, CTRL_HASH);
|
||||
keyHashMap.put(Keyboard.KEY_RMETA, CTRL_HASH);
|
||||
|
||||
keyHashMap.put(Keyboard.KEY_LMENU, ALT_HASH);
|
||||
keyHashMap.put(Keyboard.KEY_LMENU, ALT_HASH);
|
||||
}
|
||||
|
||||
public static Minecraft mc() {
|
||||
return Minecraft.getMinecraft();
|
||||
}
|
||||
@@ -367,18 +381,23 @@ public class NEIClientUtils extends NEIServerUtils {
|
||||
}
|
||||
|
||||
public static String cropText(FontRenderer fontRenderer, String text, int containerWidth) {
|
||||
|
||||
int textWidth = fontRenderer.getStringWidth(text);
|
||||
|
||||
if (textWidth > containerWidth) {
|
||||
textWidth += fontRenderer.getStringWidth("...");
|
||||
int dots = fontRenderer.getStringWidth("...");
|
||||
|
||||
while (textWidth > containerWidth) {
|
||||
textWidth -= fontRenderer.getCharWidth(text.charAt(text.length() - 1));
|
||||
text = text.substring(0, text.length() - 1);
|
||||
if (containerWidth > dots) {
|
||||
textWidth += dots;
|
||||
|
||||
while (textWidth > containerWidth) {
|
||||
textWidth -= fontRenderer.getCharWidth(text.charAt(text.length() - 1));
|
||||
text = text.substring(0, text.length() - 1);
|
||||
}
|
||||
|
||||
return text + "...";
|
||||
}
|
||||
|
||||
return text + "...";
|
||||
return "...";
|
||||
}
|
||||
|
||||
return text;
|
||||
@@ -433,11 +452,7 @@ public class NEIClientUtils extends NEIServerUtils {
|
||||
if (Keyboard.getEventKeyState()) {
|
||||
final int keycode = Keyboard.getEventKey();
|
||||
|
||||
if (keycode != Keyboard.KEY_LSHIFT && keycode != Keyboard.KEY_RSHIFT
|
||||
&& keycode != Keyboard.KEY_LCONTROL
|
||||
&& keycode != Keyboard.KEY_RCONTROL
|
||||
&& keycode != Keyboard.KEY_LMENU
|
||||
&& keycode != Keyboard.KEY_RMENU) {
|
||||
if (!keyHashMap.containsKey(keycode)) {
|
||||
return getMetaHash() + keycode;
|
||||
}
|
||||
}
|
||||
@@ -445,6 +460,45 @@ public class NEIClientUtils extends NEIServerUtils {
|
||||
return Keyboard.CHAR_NONE;
|
||||
}
|
||||
|
||||
public static String getKeyHashName(int keyBind) {
|
||||
StringJoiner keyText = new StringJoiner(" + ");
|
||||
|
||||
if ((keyBind & CTRL_HASH) != 0) {
|
||||
keyText.add(translate(Minecraft.isRunningOnMac ? "key.ctrl.mac" : "key.ctrl"));
|
||||
}
|
||||
|
||||
if ((keyBind & SHIFT_HASH) != 0) {
|
||||
keyText.add(translate("key.shift"));
|
||||
}
|
||||
|
||||
if ((keyBind & ALT_HASH) != 0) {
|
||||
keyText.add(translate("key.alt"));
|
||||
}
|
||||
|
||||
return keyText.toString();
|
||||
}
|
||||
|
||||
public static String getKeyName(int keyBind) {
|
||||
keyBind = keyHashMap.getOrDefault(keyBind, keyBind);
|
||||
StringJoiner keyText = new StringJoiner(" + ");
|
||||
String hashText = getKeyHashName(keyBind);
|
||||
int keyID = unHashKey(keyBind);
|
||||
|
||||
if (!hashText.isEmpty()) {
|
||||
keyText.add(hashText);
|
||||
}
|
||||
|
||||
if (keyID != Keyboard.CHAR_NONE || hashText.isEmpty()) {
|
||||
keyText.add(Keyboard.getKeyName(keyID));
|
||||
}
|
||||
|
||||
return keyText.toString();
|
||||
}
|
||||
|
||||
public static int unHashKey(int keyBind) {
|
||||
return keyBind & ~(CTRL_HASH | SHIFT_HASH | ALT_HASH);
|
||||
}
|
||||
|
||||
public static void playClickSound() {
|
||||
mc().getSoundHandler()
|
||||
.playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
@@ -456,16 +510,9 @@ public class NEIClientUtils extends NEIServerUtils {
|
||||
String stackTrace = cause + sw;
|
||||
if (buffer.contains(stackTrace)) return;
|
||||
|
||||
System.err.println("Error while rendering: " + cause);
|
||||
System.err.println("Error while rendering: " + cause + " (" + e.getMessage() + ")");
|
||||
e.printStackTrace();
|
||||
buffer.add(stackTrace);
|
||||
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
if (player != null) {
|
||||
IChatComponent chat = new ChatComponentTranslation("nei.chat.render.error");
|
||||
chat.getChatStyle().setColor(EnumChatFormatting.RED);
|
||||
player.addChatComponentMessage(chat);
|
||||
}
|
||||
}
|
||||
|
||||
public static void reportErrorBuffered(Throwable e, Set<String> buffer, ItemStack cause) {
|
||||
|
||||
@@ -127,6 +127,8 @@ public class NEIModContainer extends DummyModContainer {
|
||||
public void loadComplete(FMLLoadCompleteEvent event) {
|
||||
if (CommonUtils.isClient()) {
|
||||
GuiRecipeTab.loadHandlerInfo();
|
||||
ClientHandler.loadPluginsList();
|
||||
ClientHandler.loadHandlerOrdering();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,9 +89,8 @@ public class NEIServerUtils {
|
||||
else return player.inventory.getStackInSlot(slot);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void deleteAllItems(EntityPlayerMP player) {
|
||||
for (Slot slot : (List<Slot>) player.openContainer.inventorySlots) slot.putStack(null);
|
||||
for (Slot slot : player.openContainer.inventorySlots) slot.putStack(null);
|
||||
|
||||
player.sendContainerAndContentsToPlayer(player.openContainer, player.openContainer.getInventory());
|
||||
}
|
||||
|
||||
@@ -11,11 +11,12 @@ import codechicken.nei.ItemPanel.ItemPanelSlot;
|
||||
import codechicken.nei.api.GuiInfo;
|
||||
import codechicken.nei.api.INEIGuiHandler;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.guihook.IContainerTooltipHandler;
|
||||
import codechicken.nei.recipe.GuiCraftingRecipe;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.GuiUsageRecipe;
|
||||
|
||||
public abstract class PanelWidget extends Widget {
|
||||
public abstract class PanelWidget extends Widget implements IContainerTooltipHandler {
|
||||
|
||||
protected static final int PADDING = 2;
|
||||
|
||||
@@ -197,13 +198,12 @@ public abstract class PanelWidget extends Widget {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postDrawTooltips(int mx, int my, List<String> tooltip) {
|
||||
grid.postDrawTooltips(mx, my, tooltip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(int mousex, int mousey, int button, long heldTime) {
|
||||
if (mouseDownSlot >= grid.realItems.size()) {
|
||||
mouseDownSlot = -1;
|
||||
}
|
||||
|
||||
if (mouseDownSlot >= 0 && draggedStack == null
|
||||
&& NEIClientUtils.getHeldItem() == null
|
||||
&& NEIClientConfig.hasSMPCounterPart()) {
|
||||
@@ -220,28 +220,8 @@ public abstract class PanelWidget extends Widget {
|
||||
|
||||
@Override
|
||||
public boolean handleClick(int mousex, int mousey, int button) {
|
||||
|
||||
if (handleClickExt(mousex, mousey, button)) return true;
|
||||
|
||||
if (NEIClientUtils.getHeldItem() != null) {
|
||||
|
||||
if (!grid.contains(mousex, mousey)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (NEIClientConfig.canPerformAction("delete") && NEIClientConfig.canPerformAction("item")) {
|
||||
if (button == 1) {
|
||||
NEIClientUtils.decreaseSlotStack(-999);
|
||||
} else {
|
||||
NEIClientUtils.deleteHeldItem();
|
||||
}
|
||||
} else {
|
||||
NEIClientUtils.dropHeldItem();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ItemPanelSlot hoverSlot = getSlotMouseOver(mousex, mousey);
|
||||
if (hoverSlot != null) {
|
||||
|
||||
@@ -336,7 +316,8 @@ public abstract class PanelWidget extends Widget {
|
||||
if (hoverSlot != null && hoverSlot.slotIndex == mouseDownSlot && draggedStack == null) {
|
||||
ItemStack item = hoverSlot.item.copy();
|
||||
|
||||
if (NEIController.manager.window instanceof GuiRecipe || !NEIClientConfig.canCheatItem(item)) {
|
||||
if (NEIController.manager.window instanceof GuiRecipe || NEIClientUtils.shiftKey()
|
||||
|| !NEIClientConfig.canCheatItem(item)) {
|
||||
|
||||
if (button == 0) {
|
||||
GuiCraftingRecipe.openRecipeGui("item", item);
|
||||
@@ -400,4 +381,21 @@ public abstract class PanelWidget extends Widget {
|
||||
public boolean contains(int px, int py) {
|
||||
return grid.contains(px, py);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleTooltip(GuiContainer gui, int mousex, int mousey, List<String> currenttip) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleItemDisplayName(GuiContainer gui, ItemStack itemstack, List<String> currenttip) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleItemTooltip(GuiContainer gui, ItemStack itemstack, int mousex, int mousey,
|
||||
List<String> currenttip) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,8 +4,6 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@@ -34,7 +32,7 @@ import codechicken.nei.util.NBTJson;
|
||||
|
||||
public class PresetsList {
|
||||
|
||||
public static enum PresetMode {
|
||||
public enum PresetMode {
|
||||
HIDE,
|
||||
REMOVE,
|
||||
GROUP;
|
||||
@@ -145,62 +143,20 @@ public class PresetsList {
|
||||
}
|
||||
|
||||
public static final List<Preset> presets = new ArrayList<>();
|
||||
|
||||
protected static File presetsFile;
|
||||
protected static RecipesFilter recipeFilter = new RecipesFilter();
|
||||
protected static ItemPanelFilter itemFilter = new ItemPanelFilter();
|
||||
|
||||
static {
|
||||
API.addItemFilter(itemFilter);
|
||||
API.addRecipeFilter(recipeFilter);
|
||||
ItemList.loadCallbacks.add(PresetsList::itemsLoaded);
|
||||
}
|
||||
|
||||
public static ItemFilter getItemFilter() {
|
||||
return itemFilter.getFilter();
|
||||
}
|
||||
|
||||
public static void itemsLoaded() {
|
||||
recipeFilter.cache = null;
|
||||
itemFilter.cache = null;
|
||||
ItemList.collapsibleItems.reload();
|
||||
}
|
||||
|
||||
public static void setPresetsFile(String worldPath) {
|
||||
final File dir = new File(CommonUtils.getMinecraftDir(), "saves/NEI/" + worldPath);
|
||||
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
|
||||
presetsFile = new File(dir, "presets.ini");
|
||||
|
||||
if (!presetsFile.exists()) {
|
||||
final File globalPresets = new File(CommonUtils.getMinecraftDir(), "saves/NEI/global/presets.ini");
|
||||
final File configPresets = new File(NEIClientConfig.configDir, "presets.ini");
|
||||
final File defaultBookmarks = configPresets.exists() ? configPresets : globalPresets;
|
||||
|
||||
if (defaultBookmarks.exists()) {
|
||||
|
||||
try {
|
||||
presetsFile.createNewFile();
|
||||
|
||||
InputStream src = new FileInputStream(defaultBookmarks);
|
||||
OutputStream dst = new FileOutputStream(presetsFile);
|
||||
|
||||
IOUtils.copy(src, dst);
|
||||
|
||||
src.close();
|
||||
dst.close();
|
||||
|
||||
} catch (IOException e) {}
|
||||
}
|
||||
}
|
||||
|
||||
loadPresets();
|
||||
}
|
||||
|
||||
protected static void loadPresets() {
|
||||
public static void load() {
|
||||
final File presetsFile = new File(CommonUtils.getMinecraftDir(), "saves/NEI/global/presets.ini");
|
||||
|
||||
if (presetsFile == null || !presetsFile.exists()) {
|
||||
return;
|
||||
@@ -236,15 +192,15 @@ public class PresetsList {
|
||||
preset = new Preset();
|
||||
}
|
||||
|
||||
if (settings.get("name") != null) {
|
||||
if (settings.has("name")) {
|
||||
preset.name = settings.get("name").getAsString();
|
||||
}
|
||||
|
||||
if (settings.get("enabled") != null) {
|
||||
if (settings.has("enabled")) {
|
||||
preset.enabled = settings.get("enabled").getAsBoolean();
|
||||
}
|
||||
|
||||
if (settings.get("mode") != null) {
|
||||
if (settings.has("mode")) {
|
||||
preset.mode = PresetMode.valueOf(settings.get("mode").getAsString());
|
||||
}
|
||||
|
||||
@@ -260,17 +216,11 @@ public class PresetsList {
|
||||
if (!preset.items.isEmpty()) {
|
||||
presets.add(preset);
|
||||
}
|
||||
|
||||
itemsLoaded();
|
||||
}
|
||||
|
||||
public static void savePresets() {
|
||||
|
||||
if (presetsFile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> strings = new ArrayList<>();
|
||||
final File presetsFile = new File(CommonUtils.getMinecraftDir(), "saves/NEI/global/presets.ini");
|
||||
final List<String> strings = new ArrayList<>();
|
||||
|
||||
for (Preset preset : presets) {
|
||||
JsonObject settings = new JsonObject();
|
||||
@@ -289,7 +239,11 @@ public class PresetsList {
|
||||
NEIClientConfig.logger.error("Filed to save presets list to file {}", presetsFile, e);
|
||||
}
|
||||
|
||||
itemsLoaded();
|
||||
recipeFilter.cache = null;
|
||||
itemFilter.cache = null;
|
||||
CollapsibleItems.saveStates();
|
||||
CollapsibleItems.load();
|
||||
LayoutManager.markItemsDirty();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -243,18 +243,18 @@ public class SearchField extends TextField implements ItemFilterProvider {
|
||||
search = search.substring(2, search.length() - 1);
|
||||
} else {
|
||||
final Matcher matcher = Pattern.compile("(\\?|\\*)").matcher(search);
|
||||
String cleanedString = "";
|
||||
final StringBuilder cleanedString = new StringBuilder();
|
||||
int lastEndIndex = 0;
|
||||
|
||||
while (matcher.find()) {
|
||||
cleanedString += Pattern.quote(search.substring(lastEndIndex, matcher.start()));
|
||||
cleanedString.append(Pattern.quote(search.substring(lastEndIndex, matcher.start())));
|
||||
|
||||
switch (matcher.group(0).charAt(0)) {
|
||||
case '?':
|
||||
cleanedString += ".";
|
||||
cleanedString.append(".");
|
||||
break;
|
||||
case '*':
|
||||
cleanedString += ".+?";
|
||||
cleanedString.append(".+?");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -266,6 +266,8 @@ public class SearchField extends TextField implements ItemFilterProvider {
|
||||
search = cleanedString + Pattern.quote(search.substring(lastEndIndex, search.length()));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!search.isEmpty()) {
|
||||
@@ -300,6 +302,8 @@ public class SearchField extends TextField implements ItemFilterProvider {
|
||||
case 2:
|
||||
text = text.replaceAll("[{}()\\[\\].+*?^$\\\\|]", "\\\\$0");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (text.contains(" ") && NEIClientConfig.getBooleanSetting("inventory.search.quoteDropItemName")) {
|
||||
|
||||
@@ -3,15 +3,16 @@ package codechicken.nei;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.Language;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import codechicken.nei.ItemList.AllMultiItemFilter;
|
||||
@@ -20,6 +21,8 @@ import codechicken.nei.ItemList.EverythingItemFilter;
|
||||
import codechicken.nei.ItemList.NegatedItemFilter;
|
||||
import codechicken.nei.ItemList.NothingItemFilter;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
import gnu.trove.map.TCharCharMap;
|
||||
import gnu.trove.map.hash.TCharCharHashMap;
|
||||
|
||||
public class SearchTokenParser {
|
||||
|
||||
@@ -30,16 +33,11 @@ public class SearchTokenParser {
|
||||
NEVER;
|
||||
|
||||
public static SearchMode fromInt(int value) {
|
||||
switch (value) {
|
||||
case 0:
|
||||
return ALWAYS;
|
||||
case 1:
|
||||
return PREFIX;
|
||||
case 2:
|
||||
return NEVER;
|
||||
default:
|
||||
return ALWAYS;
|
||||
}
|
||||
return switch (value) {
|
||||
case 0 -> ALWAYS;
|
||||
case 1 -> PREFIX;
|
||||
default -> NEVER;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +45,6 @@ public class SearchTokenParser {
|
||||
|
||||
public ItemFilter getFilter(String searchText);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<Language> getAllLanguages() {
|
||||
return new ArrayList<>(Minecraft.getMinecraft().getLanguageManager().getLanguages());
|
||||
}
|
||||
@@ -74,8 +71,35 @@ public class SearchTokenParser {
|
||||
}
|
||||
}
|
||||
|
||||
private static class IsRegisteredItemFilter implements ItemFilter {
|
||||
|
||||
public ItemFilter filter;
|
||||
|
||||
public IsRegisteredItemFilter(ItemFilter filter) {
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ItemStack item) {
|
||||
return item != null && item.getItem() != null
|
||||
&& item.getItem().delegate.name() != null
|
||||
&& this.filter.matches(item);
|
||||
}
|
||||
}
|
||||
|
||||
private final LinkedHashMap<String, ItemFilter> filtersCache = new LinkedHashMap<>() {
|
||||
|
||||
private static final long serialVersionUID = 1042213947848622164L;
|
||||
|
||||
@Override
|
||||
protected boolean removeEldestEntry(Map.Entry<String, ItemFilter> eldest) {
|
||||
return size() > 20;
|
||||
}
|
||||
};
|
||||
|
||||
protected final List<ISearchParserProvider> searchProviders;
|
||||
protected final ProvidersCache providersCache = new ProvidersCache();
|
||||
protected final TCharCharMap prefixRedefinitions = new TCharCharHashMap();
|
||||
|
||||
public SearchTokenParser(List<ISearchParserProvider> searchProviders) {
|
||||
this.searchProviders = searchProviders;
|
||||
@@ -88,6 +112,11 @@ public class SearchTokenParser {
|
||||
public void addProvider(ISearchParserProvider provider) {
|
||||
this.searchProviders.add(provider);
|
||||
this.providersCache.clear();
|
||||
this.filtersCache.clear();
|
||||
}
|
||||
|
||||
public void clearCache() {
|
||||
this.filtersCache.clear();
|
||||
}
|
||||
|
||||
protected List<ISearchParserProvider> getProviders() {
|
||||
@@ -114,37 +143,51 @@ public class SearchTokenParser {
|
||||
|
||||
public ISearchParserProvider getProvider(char ch) {
|
||||
return getProviders().stream()
|
||||
.filter(provider -> provider.getSearchMode() == SearchMode.PREFIX && provider.getPrefix() == ch)
|
||||
.filter(
|
||||
provider -> provider.getSearchMode() == SearchMode.PREFIX
|
||||
&& getRedefinedPrefix(provider.getPrefix()) == ch)
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public ItemFilter getFilter(String filterText) {
|
||||
final String[] parts = EnumChatFormatting.getTextWithoutFormattingCodes(filterText).toLowerCase().split("\\|");
|
||||
final List<ItemFilter> searchTokens = Arrays.stream(parts).map(s -> parseSearchText(s)).filter(s -> s != null)
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
public synchronized ItemFilter getFilter(String filterText) {
|
||||
filterText = EnumChatFormatting.getTextWithoutFormattingCodes(filterText).toLowerCase();
|
||||
|
||||
return this.filtersCache.computeIfAbsent(filterText, text -> {
|
||||
final String[] parts = text.split("\\|");
|
||||
final List<ItemFilter> searchTokens = Arrays.stream(parts).map(this::parseSearchText).filter(s -> s != null)
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
if (searchTokens.isEmpty()) {
|
||||
return new EverythingItemFilter();
|
||||
} else if (searchTokens.size() == 1) {
|
||||
return new IsRegisteredItemFilter(searchTokens.get(0));
|
||||
} else {
|
||||
return new IsRegisteredItemFilter(new AnyMultiItemFilter(searchTokens));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (searchTokens.isEmpty()) {
|
||||
return new EverythingItemFilter();
|
||||
} else if (searchTokens.size() == 1) {
|
||||
return searchTokens.get(0);
|
||||
} else {
|
||||
return new AnyMultiItemFilter(searchTokens);
|
||||
}
|
||||
}
|
||||
|
||||
public Pattern getSplitPattern() {
|
||||
StringJoiner prefixes = new StringJoiner("");
|
||||
prefixes.add(String.valueOf('\0'));
|
||||
StringBuilder prefixes = new StringBuilder().append('\0');
|
||||
|
||||
for (ISearchParserProvider provider : getProviders()) {
|
||||
if (provider.getSearchMode() == SearchMode.PREFIX) {
|
||||
prefixes.add(String.valueOf(provider.getPrefix()));
|
||||
prefixes.append(getRedefinedPrefix(provider.getPrefix()));
|
||||
}
|
||||
}
|
||||
|
||||
return Pattern.compile("((-*)([" + Pattern.quote(prefixes.toString()) + "]*)(\\\".*?(?:\\\"|$)|\\S+))");
|
||||
}
|
||||
|
||||
public char getRedefinedPrefix(char prefix) {
|
||||
if (this.prefixRedefinitions.containsKey(prefix)) {
|
||||
return this.prefixRedefinitions.get(prefix);
|
||||
}
|
||||
return prefix;
|
||||
}
|
||||
|
||||
private ItemFilter parseSearchText(String filterText) {
|
||||
|
||||
if (filterText.isEmpty()) {
|
||||
@@ -188,7 +231,11 @@ public class SearchTokenParser {
|
||||
|
||||
for (ISearchParserProvider _provider : getProviders()) {
|
||||
if (_provider.getSearchMode() == SearchMode.ALWAYS) {
|
||||
filters.add(_provider.getFilter(token));
|
||||
ItemFilter filter = _provider.getFilter(token);
|
||||
|
||||
if (filter != null) {
|
||||
filters.add(filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,6 @@ public class SpawnerRenderer implements IItemRenderer {
|
||||
BossStatus.hasColorModifier = bossHasColorModifier;
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
switch (type) {
|
||||
@@ -75,6 +74,8 @@ public class SpawnerRenderer implements IItemRenderer {
|
||||
case ENTITY:
|
||||
renderInventoryItem((RenderBlocks) data[0], item);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.core.gui.GuiScrollSlot;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
@@ -33,7 +35,6 @@ import codechicken.nei.SearchTokenParser.SearchMode;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
import codechicken.nei.api.ItemFilter.ItemFilterProvider;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
|
||||
public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoadedCallback {
|
||||
@@ -72,7 +73,8 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
|
||||
if (slot < sorted.size()) {
|
||||
SubsetTag tag = sorted.get(slot);
|
||||
if (NEIClientUtils.shiftKey()) {
|
||||
codechicken.nei.LayoutManager.searchField.setText("%" + tag.fullname);
|
||||
LayoutManager.searchField.setText(
|
||||
SearchField.searchParser.getRedefinedPrefix('%') + tag.fullname.replaceAll("\\s+", ""));
|
||||
} else if (button == 0 && count >= 2) {
|
||||
SubsetWidget.showOnly(tag);
|
||||
} else {
|
||||
@@ -94,7 +96,7 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
|
||||
Rectangle4i r = new Rectangle4i(x, y, w, getSlotHeight(slot));
|
||||
if (slot < sorted.size()) {
|
||||
SubsetTag tag = sorted.get(slot);
|
||||
codechicken.nei.LayoutManager.getLayoutStyle()
|
||||
LayoutManager.getLayoutStyle()
|
||||
.drawSubsetTag(tag.displayName(), x, y, r.w, r.h, tag.state.state, r.contains(mx, my));
|
||||
} else {
|
||||
ItemStack stack = state.items.get(slot - sorted.size());
|
||||
@@ -103,8 +105,7 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
|
||||
int itemx = w / 2 - 8;
|
||||
int itemy = 1;
|
||||
|
||||
codechicken.nei.LayoutManager.getLayoutStyle()
|
||||
.drawSubsetTag(null, x, y, r.w, r.h, hidden ? 0 : 2, false);
|
||||
LayoutManager.getLayoutStyle().drawSubsetTag(null, x, y, r.w, r.h, hidden ? 0 : 2, false);
|
||||
|
||||
GuiContainerManager.drawItem(x + itemx, y + itemy, stack);
|
||||
if (new Rectangle4i(itemx, itemy, 16, 16).contains(mx, my)) SubsetWidget.hoverStack = stack;
|
||||
@@ -177,7 +178,7 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
|
||||
private SubsetTag getTag(String name) {
|
||||
int idx = name.indexOf('.');
|
||||
String childname = idx > 0 ? name.substring(0, idx) : name;
|
||||
SubsetTag child = children.get(childname.replaceAll(" ", "").toLowerCase());
|
||||
SubsetTag child = children.get(childname.replaceAll("\\s+", "").toLowerCase());
|
||||
if (child == null) return null;
|
||||
|
||||
return idx > 0 ? child.getTag(name.substring(idx + 1)) : child;
|
||||
@@ -194,7 +195,7 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
|
||||
int idx = name.indexOf('.');
|
||||
|
||||
if (idx < 0) { // add or replace tag
|
||||
SubsetTag prev = children.put(name.replaceAll(" ", "").toLowerCase(), tag);
|
||||
SubsetTag prev = children.put(name.replaceAll("\\s+", "").toLowerCase(), tag);
|
||||
if (prev != null) { // replaced, load children
|
||||
tag.children = prev.children;
|
||||
tag.sorted = prev.sorted;
|
||||
@@ -202,10 +203,10 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
|
||||
recacheChildren();
|
||||
} else {
|
||||
String childname = name.substring(0, idx);
|
||||
SubsetTag child = children.get(childname.replaceAll(" ", "").toLowerCase());
|
||||
SubsetTag child = children.get(childname.replaceAll("\\s+", "").toLowerCase());
|
||||
if (child == null) {
|
||||
children.put(
|
||||
childname.replaceAll(" ", "").toLowerCase(),
|
||||
childname.replaceAll("\\s+", "").toLowerCase(),
|
||||
child = new SubsetTag(fullname == null ? childname : fullname + '.' + childname));
|
||||
}
|
||||
recacheChildren();
|
||||
@@ -642,7 +643,6 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
|
||||
if (reallocate) {
|
||||
for (ItemStack item : ItemList.items) {
|
||||
if (interrupted()) return;
|
||||
if (ItemInfo.isHidden(item)) continue;
|
||||
for (SubsetTag tag : tags) if (tag.filter.matches(item)) state.get(tag.fullname).items.add(item);
|
||||
}
|
||||
}
|
||||
@@ -714,9 +714,14 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
|
||||
|
||||
hoverStack = null;
|
||||
if (root.isVisible()) {
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||
GuiContainerManager.enable2DRender();
|
||||
|
||||
root.resize(area.x, 0, area.y);
|
||||
root.cacheState();
|
||||
root.draw(mx, my);
|
||||
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
public class ThreadOperationTimer extends Thread {
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class TimeoutException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = -8621458005263888185L;
|
||||
public final Object operation;
|
||||
|
||||
public TimeoutException(String msg, Object op) {
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.math.MathHelper;
|
||||
import codechicken.nei.KeyManager.IKeyStateTracker;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
|
||||
public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
|
||||
@@ -26,12 +27,11 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
private static byte[] mobSpawnCache;
|
||||
private static long mobOverlayUpdateTime;
|
||||
private static String oregenPatternName;
|
||||
private static boolean hasOregenPatternBeenSet = false;
|
||||
|
||||
public static void reset() {
|
||||
mobOverlay = 0;
|
||||
chunkOverlay = 0;
|
||||
hasOregenPatternBeenSet = false;
|
||||
oregenPatternName = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -204,7 +204,9 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glLineWidth(1.5F);
|
||||
GL11.glBegin(GL11.GL_LINES);
|
||||
|
||||
final Tessellator tess = Tessellator.instance;
|
||||
tess.startDrawing(GL11.GL_LINES);
|
||||
|
||||
for (int cx = -4; cx <= 4; cx++) for (int cz = -4; cz <= 4; cz++) {
|
||||
double x1 = ((entity.chunkCoordX + cx) << 4) - intOffsetX;
|
||||
@@ -230,22 +232,22 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
|
||||
double dist = Math.pow(1.5, -(cx * cx + cz * cz));
|
||||
|
||||
GL11.glColor4d(0.9, 0, 0, dist);
|
||||
tess.setColorRGBA_F(0.9F, 0, 0, (float) dist);
|
||||
if (cx >= 0 && cz >= 0) {
|
||||
GL11.glVertex3d(x2, y1, z2);
|
||||
GL11.glVertex3d(x2, y2, z2);
|
||||
tess.addVertex(x2, y1, z2);
|
||||
tess.addVertex(x2, y2, z2);
|
||||
}
|
||||
if (cx >= 0 && cz <= 0) {
|
||||
GL11.glVertex3d(x2, y1, z1);
|
||||
GL11.glVertex3d(x2, y2, z1);
|
||||
tess.addVertex(x2, y1, z1);
|
||||
tess.addVertex(x2, y2, z1);
|
||||
}
|
||||
if (cx <= 0 && cz >= 0) {
|
||||
GL11.glVertex3d(x1, y1, z2);
|
||||
GL11.glVertex3d(x1, y2, z2);
|
||||
tess.addVertex(x1, y1, z2);
|
||||
tess.addVertex(x1, y2, z2);
|
||||
}
|
||||
if (cx <= 0 && cz <= 0) {
|
||||
GL11.glVertex3d(x1, y1, z1);
|
||||
GL11.glVertex3d(x1, y2, z1);
|
||||
tess.addVertex(x1, y1, z1);
|
||||
tess.addVertex(x1, y2, z1);
|
||||
}
|
||||
|
||||
if (cx == 0 && cz == 0) {
|
||||
@@ -266,40 +268,31 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
y1 -= intOffsetY;
|
||||
y2 -= intOffsetY;
|
||||
|
||||
GL11.glColor4d(0, 0.9, 0, 0.4);
|
||||
tess.setColorRGBA_F(0, 0.9F, 0, 0.4F);
|
||||
for (double y = (int) y1; y <= y2; y++) {
|
||||
GL11.glVertex3d(x2, y, z1);
|
||||
GL11.glVertex3d(x2, y, z2);
|
||||
GL11.glVertex3d(x1, y, z1);
|
||||
GL11.glVertex3d(x1, y, z2);
|
||||
GL11.glVertex3d(x1, y, z2);
|
||||
GL11.glVertex3d(x2, y, z2);
|
||||
GL11.glVertex3d(x1, y, z1);
|
||||
GL11.glVertex3d(x2, y, z1);
|
||||
tess.addVertex(x2, y, z1);
|
||||
tess.addVertex(x2, y, z2);
|
||||
tess.addVertex(x1, y, z1);
|
||||
tess.addVertex(x1, y, z2);
|
||||
tess.addVertex(x1, y, z2);
|
||||
tess.addVertex(x2, y, z2);
|
||||
tess.addVertex(x1, y, z1);
|
||||
tess.addVertex(x2, y, z1);
|
||||
}
|
||||
for (double h = 1; h <= 15; h++) {
|
||||
GL11.glVertex3d(x1 + h, y1, z1);
|
||||
GL11.glVertex3d(x1 + h, y2, z1);
|
||||
GL11.glVertex3d(x1 + h, y1, z2);
|
||||
GL11.glVertex3d(x1 + h, y2, z2);
|
||||
GL11.glVertex3d(x1, y1, z1 + h);
|
||||
GL11.glVertex3d(x1, y2, z1 + h);
|
||||
GL11.glVertex3d(x2, y1, z1 + h);
|
||||
GL11.glVertex3d(x2, y2, z1 + h);
|
||||
tess.addVertex(x1 + h, y1, z1);
|
||||
tess.addVertex(x1 + h, y2, z1);
|
||||
tess.addVertex(x1 + h, y1, z2);
|
||||
tess.addVertex(x1 + h, y2, z2);
|
||||
tess.addVertex(x1, y1, z1 + h);
|
||||
tess.addVertex(x1, y2, z1 + h);
|
||||
tess.addVertex(x2, y1, z1 + h);
|
||||
tess.addVertex(x2, y2, z1 + h);
|
||||
}
|
||||
} else if (chunkOverlay == 3) {
|
||||
if (!hasOregenPatternBeenSet) {
|
||||
try {
|
||||
oregenPatternName = ((Enum<?>) Class.forName("gregtech.common.GT_Worldgenerator")
|
||||
.getDeclaredField("oregenPattern").get(null)).name();
|
||||
} catch (Exception ignored) {
|
||||
oregenPatternName = "AXISSYMMETRICAL";
|
||||
}
|
||||
hasOregenPatternBeenSet = true;
|
||||
}
|
||||
int gx1;
|
||||
int gz1;
|
||||
if (oregenPatternName.equals("EQUAL_SPACING")) {
|
||||
if (getOregenPatternName().equals("EQUAL_SPACING")) {
|
||||
// gt oregen uses new regular pattern
|
||||
gx1 = ((Math.floorDiv(entity.chunkCoordX, 3) * 3) << 4) - intOffsetX;
|
||||
gz1 = ((Math.floorDiv(entity.chunkCoordZ, 3) * 3) << 4) - intOffsetZ;
|
||||
@@ -319,55 +312,71 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
int gx2 = gx1 + 48;
|
||||
int gz2 = gz1 + 48;
|
||||
|
||||
GL11.glColor4d(0, 0.9, 0, 0.4);
|
||||
tess.setColorRGBA_F(0, 0.9F, 0, 0.4F);
|
||||
for (double y = (int) y1; y <= y2; y++) {
|
||||
GL11.glVertex3d(gx2, y, gz1);
|
||||
GL11.glVertex3d(gx2, y, gz2);
|
||||
GL11.glVertex3d(gx1, y, gz1);
|
||||
GL11.glVertex3d(gx1, y, gz2);
|
||||
GL11.glVertex3d(gx1, y, gz2);
|
||||
GL11.glVertex3d(gx2, y, gz2);
|
||||
GL11.glVertex3d(gx1, y, gz1);
|
||||
GL11.glVertex3d(gx2, y, gz1);
|
||||
tess.addVertex(gx2, y, gz1);
|
||||
tess.addVertex(gx2, y, gz2);
|
||||
tess.addVertex(gx1, y, gz1);
|
||||
tess.addVertex(gx1, y, gz2);
|
||||
tess.addVertex(gx1, y, gz2);
|
||||
tess.addVertex(gx2, y, gz2);
|
||||
tess.addVertex(gx1, y, gz1);
|
||||
tess.addVertex(gx2, y, gz1);
|
||||
}
|
||||
for (double h = 4; h <= 44; h += 4) {
|
||||
if (h % 16 == 0) {
|
||||
continue;
|
||||
}
|
||||
GL11.glVertex3d(gx1 + h, y1, gz1);
|
||||
GL11.glVertex3d(gx1 + h, y2, gz1);
|
||||
GL11.glVertex3d(gx1 + h, y1, gz2);
|
||||
GL11.glVertex3d(gx1 + h, y2, gz2);
|
||||
GL11.glVertex3d(gx1, y1, gz1 + h);
|
||||
GL11.glVertex3d(gx1, y2, gz1 + h);
|
||||
GL11.glVertex3d(gx2, y1, gz1 + h);
|
||||
GL11.glVertex3d(gx2, y2, gz1 + h);
|
||||
tess.addVertex(gx1 + h, y1, gz1);
|
||||
tess.addVertex(gx1 + h, y2, gz1);
|
||||
tess.addVertex(gx1 + h, y1, gz2);
|
||||
tess.addVertex(gx1 + h, y2, gz2);
|
||||
tess.addVertex(gx1, y1, gz1 + h);
|
||||
tess.addVertex(gx1, y2, gz1 + h);
|
||||
tess.addVertex(gx2, y1, gz1 + h);
|
||||
tess.addVertex(gx2, y2, gz1 + h);
|
||||
}
|
||||
|
||||
GL11.glColor4d(0, 0, 0.9, 0.4);
|
||||
tess.setColorRGBA_F(0, 0, 0.9F, 0.4F);
|
||||
gx1 += 23;
|
||||
gz1 += 23;
|
||||
gx2 = gx1 + 1;
|
||||
gz2 = gz1 + 1;
|
||||
|
||||
GL11.glVertex3d(gx1, y1, gz1);
|
||||
GL11.glVertex3d(gx1, y2, gz1);
|
||||
GL11.glVertex3d(gx2, y1, gz1);
|
||||
GL11.glVertex3d(gx2, y2, gz1);
|
||||
GL11.glVertex3d(gx1, y1, gz2);
|
||||
GL11.glVertex3d(gx1, y2, gz2);
|
||||
GL11.glVertex3d(gx2, y1, gz2);
|
||||
GL11.glVertex3d(gx2, y2, gz2);
|
||||
tess.addVertex(gx1, y1, gz1);
|
||||
tess.addVertex(gx1, y2, gz1);
|
||||
tess.addVertex(gx2, y1, gz1);
|
||||
tess.addVertex(gx2, y2, gz1);
|
||||
tess.addVertex(gx1, y1, gz2);
|
||||
tess.addVertex(gx1, y2, gz2);
|
||||
tess.addVertex(gx2, y1, gz2);
|
||||
tess.addVertex(gx2, y2, gz2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glEnd();
|
||||
tess.draw();
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
private static String getOregenPatternName() {
|
||||
|
||||
if (oregenPatternName == null) {
|
||||
try {
|
||||
final ClassLoader loader = WorldOverlayRenderer.class.getClassLoader();
|
||||
final Class<?> gtWorldGenerator = ReflectionHelper
|
||||
.getClass(loader, "gregtech.common.GTWorldgenerator", "gregtech.common.GT_Worldgenerator");
|
||||
oregenPatternName = ((Enum<?>) gtWorldGenerator.getDeclaredField("oregenPattern").get(null)).name();
|
||||
} catch (Exception ignored) {
|
||||
oregenPatternName = "AXISSYMMETRICAL";
|
||||
}
|
||||
}
|
||||
|
||||
return oregenPatternName;
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
KeyManager.trackers.add(new WorldOverlayRenderer());
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ import codechicken.nei.recipe.IUsageHandler;
|
||||
import codechicken.nei.recipe.RecipeCatalysts;
|
||||
import codechicken.nei.recipe.RecipeInfo;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import codechicken.nei.util.ItemStackFilterParser;
|
||||
|
||||
/**
|
||||
* This is the main class that handles item property configuration. WARNING: DO NOT access this class until the world
|
||||
@@ -151,6 +152,14 @@ public class API {
|
||||
}
|
||||
}
|
||||
|
||||
public static void hideItem(String rule) {
|
||||
ItemFilter filter = ItemStackFilterParser.parse(rule);
|
||||
if (filter != null) {
|
||||
ItemInfo.hiddenItemsRules.filters.add(filter);
|
||||
LayoutManager.markItemsDirty();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or replace the name normally shown on the item tooltip
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package codechicken.nei.api;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.drawRect;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -21,20 +23,26 @@ public class DefaultOverlayRenderer implements IRecipeOverlayRenderer {
|
||||
|
||||
@Override
|
||||
public void renderOverlay(GuiContainerManager gui, Slot slot) {
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(770, 1);
|
||||
GL11.glColor4d(0.6, 0.6, 0.6, 0.7);
|
||||
|
||||
GuiContainerManager.setColouredItemRender(true);
|
||||
for (PositionedStack stack : ingreds) {
|
||||
if (stack.relx == slot.xDisplayPosition && stack.rely == slot.yDisplayPosition)
|
||||
if (stack.relx == slot.xDisplayPosition && stack.rely == slot.yDisplayPosition && !slot.getHasStack()) {
|
||||
GuiContainerManager.drawItem(stack.relx, stack.rely, stack.item);
|
||||
drawHover(stack.relx, stack.rely);
|
||||
}
|
||||
}
|
||||
GuiContainerManager.setColouredItemRender(false);
|
||||
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
private static void drawHover(int x, int y) {
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
drawRect(x, y, 16, 16, 0x66555555);
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
final IStackPositioner positioner;
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package codechicken.nei.api;
|
||||
|
||||
/**
|
||||
* Implement this interface on a GuiContainer to enable the autofocus search in NEI (if the autofocus option is enabled)
|
||||
* without needing to add the classname to the config file .
|
||||
*/
|
||||
public interface INEIAutoFocusSearchEnable {
|
||||
}
|
||||
@@ -1,10 +1,44 @@
|
||||
package codechicken.nei.api;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.GuiOverlayButton.ItemOverlayState;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
|
||||
public interface IOverlayHandler {
|
||||
|
||||
void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean shift);
|
||||
|
||||
default List<ItemOverlayState> presenceOverlay(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex) {
|
||||
final List<ItemOverlayState> itemPresenceSlots = new ArrayList<>();
|
||||
final List<PositionedStack> ingredients = recipe.getIngredientStacks(recipeIndex);
|
||||
final List<ItemStack> invStacks = firstGui.inventorySlots.inventorySlots.stream()
|
||||
.filter(
|
||||
s -> s != null && s.getStack() != null
|
||||
&& s.getStack().stackSize > 0
|
||||
&& s.isItemValid(s.getStack())
|
||||
&& s.canTakeStack(firstGui.mc.thePlayer))
|
||||
.map(s -> s.getStack().copy()).collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
for (PositionedStack stack : ingredients) {
|
||||
Optional<ItemStack> used = invStacks.stream().filter(is -> is.stackSize > 0 && stack.contains(is))
|
||||
.findAny();
|
||||
|
||||
itemPresenceSlots.add(new ItemOverlayState(stack, used.isPresent()));
|
||||
|
||||
if (used.isPresent()) {
|
||||
ItemStack is = used.get();
|
||||
is.stackSize -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
return itemPresenceSlots;
|
||||
}
|
||||
}
|
||||
@@ -44,12 +44,14 @@ import codechicken.core.featurehack.GameDataManipulator;
|
||||
import codechicken.nei.InfiniteStackSizeHandler;
|
||||
import codechicken.nei.InfiniteToolHandler;
|
||||
import codechicken.nei.ItemList;
|
||||
import codechicken.nei.ItemList.AnyMultiItemFilter;
|
||||
import codechicken.nei.ItemList.PatternItemFilter;
|
||||
import codechicken.nei.ItemMobSpawner;
|
||||
import codechicken.nei.ItemStackMap;
|
||||
import codechicken.nei.ItemStackSet;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.PopupInputHandler;
|
||||
import codechicken.nei.PresetsList;
|
||||
import codechicken.nei.SearchField.SearchParserProvider;
|
||||
import codechicken.nei.SearchTokenParser.SearchMode;
|
||||
import codechicken.nei.config.ArrayDumper;
|
||||
@@ -82,6 +84,7 @@ public class ItemInfo {
|
||||
public static final ArrayListMultimap<Layout, IHighlightHandler> highlightHandlers = ArrayListMultimap.create();
|
||||
public static final ItemStackMap<String> nameOverrides = new ItemStackMap<>();
|
||||
public static final ItemStackSet hiddenItems = new ItemStackSet();
|
||||
public static final AnyMultiItemFilter hiddenItemsRules = new AnyMultiItemFilter();
|
||||
public static final ItemStackSet finiteItems = new ItemStackSet();
|
||||
public static final ArrayListMultimap<Item, ItemStack> itemOverrides = ArrayListMultimap.create();
|
||||
public static final ArrayListMultimap<Item, ItemStack> itemVariants = ArrayListMultimap.create();
|
||||
@@ -93,9 +96,10 @@ public class ItemInfo {
|
||||
public static final HashMap<Item, String> itemOwners = new HashMap<>();
|
||||
|
||||
public static boolean isHidden(ItemStack stack) {
|
||||
return hiddenItems.contains(stack);
|
||||
return hiddenItems.contains(stack) || hiddenItemsRules.matches(stack);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean isHidden(Item item) {
|
||||
return hiddenItems.containsAll(item);
|
||||
}
|
||||
@@ -130,22 +134,14 @@ public class ItemInfo {
|
||||
addInfiniteHandlers();
|
||||
addInputHandlers();
|
||||
addIDDumps();
|
||||
addHiddenItemFilter();
|
||||
addSearchProviders();
|
||||
PresetsList.load();
|
||||
ItemList.loadCallbacks.add(TooltipFilter::populateSearchMap);
|
||||
}
|
||||
|
||||
private static void addHiddenItemFilter() {
|
||||
API.addItemFilter(() -> item -> !hiddenItems.contains(item));
|
||||
}
|
||||
|
||||
private static void addSearchProviders() {
|
||||
API.addSearchProvider(
|
||||
new SearchParserProvider(
|
||||
'\0',
|
||||
"default",
|
||||
EnumChatFormatting.RESET,
|
||||
(pattern) -> new PatternItemFilter(pattern)) {
|
||||
new SearchParserProvider('\0', "default", EnumChatFormatting.RESET, PatternItemFilter::new) {
|
||||
|
||||
@Override
|
||||
public SearchMode getSearchMode() {
|
||||
@@ -154,29 +150,12 @@ public class ItemInfo {
|
||||
|
||||
});
|
||||
API.addSearchProvider(
|
||||
new SearchParserProvider(
|
||||
'@',
|
||||
"modName",
|
||||
EnumChatFormatting.LIGHT_PURPLE,
|
||||
(pattern) -> new ModNameFilter(pattern)));
|
||||
new SearchParserProvider('@', "modName", EnumChatFormatting.LIGHT_PURPLE, ModNameFilter::new));
|
||||
API.addSearchProvider(
|
||||
new SearchParserProvider(
|
||||
'$',
|
||||
"oreDict",
|
||||
EnumChatFormatting.AQUA,
|
||||
(pattern) -> new OreDictionaryFilter(pattern)));
|
||||
new SearchParserProvider('$', "oreDict", EnumChatFormatting.AQUA, OreDictionaryFilter::new));
|
||||
API.addSearchProvider(new SearchParserProvider('#', "tooltip", EnumChatFormatting.YELLOW, TooltipFilter::new));
|
||||
API.addSearchProvider(
|
||||
new SearchParserProvider(
|
||||
'#',
|
||||
"tooltip",
|
||||
EnumChatFormatting.YELLOW,
|
||||
(pattern) -> new TooltipFilter(pattern)));
|
||||
API.addSearchProvider(
|
||||
new SearchParserProvider(
|
||||
'&',
|
||||
"identifier",
|
||||
EnumChatFormatting.GOLD,
|
||||
(pattern) -> new IdentifierFilter(pattern)));
|
||||
new SearchParserProvider('&', "identifier", EnumChatFormatting.GOLD, IdentifierFilter::new));
|
||||
}
|
||||
|
||||
private static void addIDDumps() {
|
||||
@@ -211,7 +190,7 @@ public class ItemInfo {
|
||||
public String[] dump(Block block, int id, String name) {
|
||||
final Item item = Item.getItemFromBlock(block);
|
||||
return new String[] { name, Integer.toString(id), Boolean.toString(item != null),
|
||||
ItemInfo.itemOwners.get(block), block.getClass().getCanonicalName(),
|
||||
ItemInfo.itemOwners.get(item), block.getClass().getCanonicalName(),
|
||||
item != null ? EnumChatFormatting.getTextWithoutFormattingCodes(
|
||||
GuiContainerManager.itemDisplayNameShort(new ItemStack(item))) : "null" };
|
||||
}
|
||||
@@ -462,7 +441,6 @@ public class ItemInfo {
|
||||
addEntityEgg(EntityIronGolem.class, 0xC5C2C1, 0xffe1cc);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void addEntityEgg(Class<?> entity, int i, int j) {
|
||||
int id = (Integer) EntityList.classToIDMapping.get(entity);
|
||||
EntityList.entityEggs.put(id, new EntityEggInfo(id, i, j));
|
||||
@@ -520,6 +498,6 @@ public class ItemInfo {
|
||||
|
||||
@Deprecated
|
||||
public static String getSearchName(ItemStack stack) {
|
||||
return GuiContainerManager.concatenatedDisplayName(stack, true);
|
||||
return GuiContainerManager.concatenatedDisplayName(stack, true).toLowerCase();
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ public abstract class ShortcutInputHandler {
|
||||
return ItemPanels.bookmarkPanel.pullBookmarkItems(ItemPanels.bookmarkPanel.getHoveredGroupId(true), true);
|
||||
}
|
||||
|
||||
if (stackover == null && NEIClientConfig.isKeyHashDown("gui.bookmark_recipe")) {
|
||||
if (stackover == null && NEIClientConfig.isKeyHashDown("gui.remove_recipe")) {
|
||||
final int groupId = ItemPanels.bookmarkPanel.getHoveredGroupId(true);
|
||||
|
||||
if (groupId != -1) {
|
||||
|
||||
@@ -66,16 +66,6 @@ public class NEITransformer implements IClassTransformer {
|
||||
"func_149689_a",
|
||||
"(Lnet/minecraft/world/World;IIILnet/minecraft/entity/EntityLivingBase;Lnet/minecraft/item/ItemStack;)V"),
|
||||
asmblocks.get("spawnerPlaced")));
|
||||
|
||||
// Make MobSpawnerBaseLogic use getSpawnerWorld when creating new entities
|
||||
transformer.add(
|
||||
new MethodReplacer(
|
||||
new ObfMapping(
|
||||
"net/minecraft/tileentity/MobSpawnerBaseLogic",
|
||||
"func_98281_h",
|
||||
"()Lnet/minecraft/entity/Entity;"),
|
||||
asmblocks.get("d_spawnerWorld"),
|
||||
asmblocks.get("spawnerWorld")));
|
||||
}
|
||||
|
||||
// Removes trailing seperators from NBTTagList/Compound.toString because OCD
|
||||
|
||||
@@ -7,7 +7,6 @@ import java.awt.Rectangle;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
|
||||
public class OptionKeyBind extends OptionButton {
|
||||
@@ -122,8 +121,12 @@ public class OptionKeyBind extends OptionButton {
|
||||
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
final int metahash = Math.max(editing ? NEIClientUtils.getMetaHash() : getValue(), 0);
|
||||
return NEIClientConfig.getKeyName(metahash, useHash, editing);
|
||||
|
||||
if (editing) {
|
||||
return NEIClientUtils.getKeyHashName(NEIClientUtils.getMetaHash());
|
||||
}
|
||||
|
||||
return NEIClientUtils.getKeyName(Math.max(getValue(), 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,30 +11,29 @@ import codechicken.nei.config.GuiOptionList.OptionScrollSlot;
|
||||
|
||||
public class OptionTextField extends Option {
|
||||
|
||||
private TextField textField = new TextField("test") {
|
||||
protected final TextField textField = new TextField("test") {
|
||||
|
||||
{
|
||||
this.h = 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChange(String oldText) {
|
||||
if (focused() && isValidValue(text())) if (!defaulting() || !text().equals(getTag().getValue())) // don't
|
||||
// override
|
||||
// global
|
||||
// if text
|
||||
// hasn't
|
||||
// changed
|
||||
// don't override global if text hasn't changed
|
||||
if (focused() && isValidValue(text()) && (!defaulting() || !text().equals(getTag().getValue()))) {
|
||||
getTag().setValue(text());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFocus(boolean focus) {
|
||||
if (!focus && !isValidValue(text())) setText(renderTag().getValue());
|
||||
|
||||
super.setFocus(focus);
|
||||
}
|
||||
};
|
||||
|
||||
public OptionTextField(String name) {
|
||||
super(name);
|
||||
textField.h = 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -46,6 +46,8 @@ public class OptionUtilities extends OptionStringSet {
|
||||
x += 24;
|
||||
LayoutManager.drawIcon(x + 4, 4, new Image(132, 12, 12, 12));
|
||||
x += 24;
|
||||
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
ItemStack sword = new ItemStack(Items.diamond_sword);
|
||||
@@ -55,5 +57,6 @@ public class OptionUtilities extends OptionStringSet {
|
||||
GuiContainerManager.drawItem(x + 2, 2, new ItemStack(Items.potionitem));
|
||||
x += 24;
|
||||
GuiContainerManager.drawItem(x + 2, 2, new ItemStack(Blocks.stone));
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ public abstract class RegistryDumper<T> extends DataDumper {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Iterable<String[]> dump(int mode) {
|
||||
LinkedList<String[]> list = new LinkedList<>();
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.awt.Rectangle;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -22,28 +23,36 @@ import codechicken.nei.config.Option;
|
||||
public class GuiPresetList extends GuiOptionPane {
|
||||
|
||||
private final Option opt;
|
||||
protected final static int SLOT_HEIGHT = 24;
|
||||
protected final static int BUTTON_HEIGHT = 20;
|
||||
protected static final int SLOT_HEIGHT = 24;
|
||||
protected static final int BUTTON_HEIGHT = 20;
|
||||
protected GuiCCButton createButton;
|
||||
protected GuiCCButton toggleButton;
|
||||
protected int sortingItemIndex = -1;
|
||||
|
||||
public GuiPresetList(Option opt) {
|
||||
this.opt = opt;
|
||||
this.createButton = new GuiCCButton(0, 2, 0, 16, NEIClientUtils.translate("presets.new"))
|
||||
.setActionCommand("create");
|
||||
this.toggleButton = new GuiCCButton(0, 2, 0, 16, NEIClientUtils.translate("presets.toggle"))
|
||||
.setActionCommand("toggle");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
this.createButton.width = getStringWidth(this.createButton.text) + 15;
|
||||
this.createButton.x = width - this.createButton.width - 15;
|
||||
|
||||
this.toggleButton.width = getStringWidth(this.toggleButton.text) + 15;
|
||||
this.toggleButton.x = width - this.toggleButton.width - 15 - this.createButton.width - 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addWidgets() {
|
||||
super.addWidgets();
|
||||
add(this.createButton);
|
||||
add(this.toggleButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,11 +62,10 @@ public class GuiPresetList extends GuiOptionPane {
|
||||
if (ident.equals("create")) {
|
||||
cretePreset();
|
||||
}
|
||||
}
|
||||
|
||||
protected void mouseClicked(int x, int y, int button) {
|
||||
super.mouseClicked(x, y, button);
|
||||
|
||||
if (ident.equals("toggle")) {
|
||||
togglePreset();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -138,6 +146,16 @@ public class GuiPresetList extends GuiOptionPane {
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiPresetSettings(this, -1));
|
||||
}
|
||||
|
||||
protected void togglePreset() {
|
||||
boolean enabled = PresetsList.presets.stream().noneMatch(g -> g.enabled);
|
||||
|
||||
for (Preset preset : PresetsList.presets) {
|
||||
preset.enabled = enabled;
|
||||
}
|
||||
|
||||
PresetsList.savePresets();
|
||||
}
|
||||
|
||||
protected void openPreset(int slot) {
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiPresetSettings(this, slot));
|
||||
}
|
||||
@@ -186,13 +204,16 @@ public class GuiPresetList extends GuiOptionPane {
|
||||
|
||||
switch (preset.mode) {
|
||||
case HIDE:
|
||||
modeName = NEIClientUtils.translate("presets.mode.hide.char");
|
||||
modeName = EnumChatFormatting.GOLD + NEIClientUtils.translate("presets.mode.hide.char")
|
||||
+ EnumChatFormatting.RESET;
|
||||
break;
|
||||
case REMOVE:
|
||||
modeName = NEIClientUtils.translate("presets.mode.remove.char");
|
||||
modeName = EnumChatFormatting.RED + NEIClientUtils.translate("presets.mode.remove.char")
|
||||
+ EnumChatFormatting.RESET;
|
||||
break;
|
||||
case GROUP:
|
||||
modeName = NEIClientUtils.translate("presets.mode.group.char");
|
||||
modeName = EnumChatFormatting.AQUA + NEIClientUtils.translate("presets.mode.group.char")
|
||||
+ EnumChatFormatting.RESET;
|
||||
break;
|
||||
default:
|
||||
modeName = "?";
|
||||
@@ -215,7 +236,7 @@ public class GuiPresetList extends GuiOptionPane {
|
||||
LayoutManager.drawButtonBackground(option.x, option.y, option.w, option.h, true, optionState);
|
||||
GuiDraw.drawString("⋮⋮", option.x + 4, option.y + 5, optionState == 2 ? 0xFFFFFFA0 : 0xFFE0E0E0);
|
||||
GuiDraw.drawString(
|
||||
NEIClientUtils.cropText(this.fontRendererObj, modeName + ": " + displayName, option.w - 16),
|
||||
NEIClientUtils.cropText(this.fontRendererObj, modeName + " " + displayName, option.w - 16),
|
||||
option.x + 6 + 4,
|
||||
option.y + 6,
|
||||
optionState == 2 ? 0xFFFFFFA0 : 0xFFE0E0E0);
|
||||
|
||||
@@ -13,7 +13,6 @@ import org.lwjgl.opengl.GL12;
|
||||
import codechicken.core.gui.GuiWidget;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.ItemList.AllMultiItemFilter;
|
||||
import codechicken.nei.ItemPanel.ItemPanelSlot;
|
||||
import codechicken.nei.ItemsGrid;
|
||||
import codechicken.nei.Label;
|
||||
@@ -22,7 +21,6 @@ import codechicken.nei.PresetsList.Preset;
|
||||
import codechicken.nei.PresetsList.PresetMode;
|
||||
import codechicken.nei.TextField;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.guihook.IContainerTooltipHandler;
|
||||
|
||||
@@ -52,9 +50,7 @@ public class LeftPanel extends GuiWidget {
|
||||
@Override
|
||||
protected ItemFilter getFilter() {
|
||||
Set<String> identifiers = preset.items;
|
||||
return new AllMultiItemFilter(
|
||||
item -> !ItemInfo.hiddenItems.contains(item),
|
||||
item -> identifiers.contains(Preset.getIdentifier(item)));
|
||||
return item -> identifiers.contains(Preset.getIdentifier(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -146,6 +142,7 @@ public class LeftPanel extends GuiWidget {
|
||||
grid.restartFilter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int x, int y, int button) {
|
||||
grid.mouseClicked(x, y, button);
|
||||
|
||||
@@ -183,6 +180,7 @@ public class LeftPanel extends GuiWidget {
|
||||
|
||||
protected void onItemsChanges() {}
|
||||
|
||||
@Override
|
||||
public void mouseMovedOrUp(int x, int y, int button) {
|
||||
nameField.mouseUp(x, y, button);
|
||||
|
||||
@@ -203,6 +201,7 @@ public class LeftPanel extends GuiWidget {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(int x, int y, int button, long time) {
|
||||
nameField.mouseDragged(x, y, button, time);
|
||||
|
||||
@@ -233,6 +232,7 @@ public class LeftPanel extends GuiWidget {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
int CHECKBOX_WIDTH = (this.width - 12) / 3;
|
||||
nameLabel.x = this.x + 2;
|
||||
@@ -271,6 +271,7 @@ public class LeftPanel extends GuiWidget {
|
||||
grid.refresh(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int mousex, int mousey, float frame) {
|
||||
nameLabel.draw(mousex, mousey);
|
||||
nameField.draw(mousex, mousey);
|
||||
@@ -305,7 +306,7 @@ public class LeftPanel extends GuiWidget {
|
||||
}
|
||||
}
|
||||
|
||||
if (tooltip.size() > 0) {
|
||||
if (!tooltip.isEmpty()) {
|
||||
tooltip.set(0, tooltip.get(0) + GuiDraw.TOOLTIP_LINESPACE); // add space after 'title'
|
||||
}
|
||||
|
||||
@@ -320,8 +321,16 @@ public class LeftPanel extends GuiWidget {
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(char c, int keycode) {
|
||||
nameField.handleKeyPress(keycode, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseScrolled(int x, int y, int scroll) {
|
||||
if (grid.contains(x, y)) {
|
||||
grid.shiftPage(-scroll);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public abstract class PresetItemsGrid extends ItemsGrid {
|
||||
}
|
||||
};
|
||||
|
||||
public PresetItemsGrid() {
|
||||
protected PresetItemsGrid() {
|
||||
|
||||
pageLabel = new Label("0/0", true);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.lwjgl.opengl.GL12;
|
||||
import codechicken.core.gui.GuiWidget;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.ItemList;
|
||||
import codechicken.nei.CollapsibleItems;
|
||||
import codechicken.nei.ItemList.AllMultiItemFilter;
|
||||
import codechicken.nei.ItemList.AnyMultiItemFilter;
|
||||
import codechicken.nei.ItemList.NegatedItemFilter;
|
||||
@@ -28,7 +28,6 @@ import codechicken.nei.PresetsList.Preset;
|
||||
import codechicken.nei.SearchField.GuiSearchField;
|
||||
import codechicken.nei.TextField;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.guihook.IContainerTooltipHandler;
|
||||
import codechicken.nei.util.TextHistory;
|
||||
@@ -55,11 +54,11 @@ public class RightPanel extends GuiWidget {
|
||||
}
|
||||
}
|
||||
|
||||
protected static abstract class PresetSearchField extends TextField {
|
||||
protected abstract static class PresetSearchField extends TextField {
|
||||
|
||||
private static final TextHistory history = new TextHistory();
|
||||
|
||||
public PresetSearchField(String ident) {
|
||||
protected PresetSearchField(String ident) {
|
||||
super(ident);
|
||||
}
|
||||
|
||||
@@ -134,9 +133,7 @@ public class RightPanel extends GuiWidget {
|
||||
|
||||
@Override
|
||||
protected ItemFilter getFilter() {
|
||||
AllMultiItemFilter filter = new AllMultiItemFilter();
|
||||
filter.filters.add(item -> !ItemInfo.hiddenItems.contains(item));
|
||||
filter.filters.add(searchField.getFilter());
|
||||
AllMultiItemFilter filter = new AllMultiItemFilter(searchField.getFilter());
|
||||
|
||||
if (enabledPresets.isChecked()) {
|
||||
AllMultiItemFilter andFilter = new AllMultiItemFilter();
|
||||
@@ -145,7 +142,7 @@ public class RightPanel extends GuiWidget {
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
andFilter.filters.add(item -> !identifiers.contains(Preset.getIdentifier(item)));
|
||||
andFilter.filters.add(new NegatedItemFilter(ItemList.collapsibleItems.getItemFilter()));
|
||||
andFilter.filters.add(new NegatedItemFilter(CollapsibleItems.getItemFilter()));
|
||||
|
||||
if (slotIndex != -1) {
|
||||
orFilter.filters.add(PresetsList.presets.get(slotIndex));
|
||||
@@ -162,7 +159,7 @@ public class RightPanel extends GuiWidget {
|
||||
protected boolean isSelected(ItemStack stack) {
|
||||
|
||||
if (mouseSelection != null && mouseSelection.items.contains(stack)) {
|
||||
return mouseSelection.append != false;
|
||||
return mouseSelection.append;
|
||||
}
|
||||
|
||||
return preset.items.contains(Preset.getIdentifier(stack));
|
||||
@@ -206,6 +203,7 @@ public class RightPanel extends GuiWidget {
|
||||
grid.restartFilter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int x, int y, int button) {
|
||||
grid.mouseClicked(x, y, button);
|
||||
|
||||
@@ -231,6 +229,7 @@ public class RightPanel extends GuiWidget {
|
||||
|
||||
protected void onItemsChanges() {}
|
||||
|
||||
@Override
|
||||
public void mouseMovedOrUp(int x, int y, int button) {
|
||||
searchField.mouseUp(x, y, button);
|
||||
|
||||
@@ -300,6 +299,7 @@ public class RightPanel extends GuiWidget {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(int x, int y, int button, long time) {
|
||||
searchField.mouseDragged(x, y, button, time);
|
||||
|
||||
@@ -330,6 +330,7 @@ public class RightPanel extends GuiWidget {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
enabledPresets.w = 20;
|
||||
enabledPresets.h = INPUT_HEIGHT;
|
||||
@@ -345,6 +346,7 @@ public class RightPanel extends GuiWidget {
|
||||
grid.refresh(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int mousex, int mousey, float frame) {
|
||||
enabledPresets.draw(mousex, mousey);
|
||||
searchField.draw(mousex, mousey);
|
||||
@@ -372,7 +374,7 @@ public class RightPanel extends GuiWidget {
|
||||
}
|
||||
}
|
||||
|
||||
if (tooltip.size() > 0) {
|
||||
if (!tooltip.isEmpty()) {
|
||||
tooltip.set(0, tooltip.get(0) + GuiDraw.TOOLTIP_LINESPACE); // add space after 'title'
|
||||
}
|
||||
|
||||
@@ -383,10 +385,12 @@ public class RightPanel extends GuiWidget {
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(char c, int keycode) {
|
||||
searchField.handleKeyPress(keycode, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseScrolled(int x, int y, int scroll) {
|
||||
if (grid.contains(x, y)) {
|
||||
grid.shiftPage(-scroll);
|
||||
|
||||
@@ -17,7 +17,6 @@ import cpw.mods.fml.common.eventhandler.Event;
|
||||
* <br>
|
||||
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class NEIRegisterHandlerInfosEvent extends Event {
|
||||
|
||||
public void registerHandlerInfo(HandlerInfo info) {
|
||||
|
||||
@@ -4,13 +4,16 @@ import static codechicken.lib.gui.GuiDraw.drawMultilineTip;
|
||||
import static codechicken.lib.gui.GuiDraw.fontRenderer;
|
||||
import static codechicken.lib.gui.GuiDraw.getMousePosition;
|
||||
import static codechicken.lib.gui.GuiDraw.renderEngine;
|
||||
import static codechicken.nei.NEIClientUtils.translate;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -23,6 +26,9 @@ import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManagerReloadListener;
|
||||
import net.minecraft.client.resources.SimpleReloadableResourceManager;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -32,16 +38,28 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.ItemStackSet;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.SearchField;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import codechicken.nei.search.TooltipFilter;
|
||||
import codechicken.nei.util.ReadableNumberConverter;
|
||||
|
||||
public class GuiContainerManager {
|
||||
|
||||
private static class ResourcePackReloaded implements IResourceManagerReloadListener {
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager p_110549_1_) {
|
||||
renderingErrorItems.clear();
|
||||
TooltipFilter.populateSearchMap();
|
||||
SearchField.searchParser.clearCache();
|
||||
}
|
||||
}
|
||||
|
||||
public GuiContainer window;
|
||||
|
||||
public static RenderItem drawItems = new RenderItem();
|
||||
@@ -134,20 +152,21 @@ public class GuiContainerManager {
|
||||
* @param includeHandlers If true tooltip handlers will add to the item tip
|
||||
* @return A list of Strings representing the text to be displayed on each line of the tool tip.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<String> itemDisplayNameMultiline(ItemStack stack, GuiContainer gui, boolean includeHandlers) {
|
||||
List<String> namelist = null;
|
||||
try {
|
||||
namelist = stack.getTooltip(
|
||||
Minecraft.getMinecraft().thePlayer,
|
||||
includeHandlers && Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
|
||||
} catch (Throwable ignored) {}
|
||||
} catch (Throwable ignored) {
|
||||
namelist = new ArrayList<>();
|
||||
}
|
||||
|
||||
if (namelist == null) namelist = new ArrayList<>();
|
||||
|
||||
if (namelist.size() == 0) namelist.add("Unnamed");
|
||||
|
||||
if (namelist.get(0) == null || namelist.get(0).equals("")) namelist.set(0, "Unnamed");
|
||||
if (namelist.isEmpty()) {
|
||||
namelist.add("Unnamed");
|
||||
} else if (namelist.get(0) == null || namelist.get(0).isEmpty()) {
|
||||
namelist.set(0, "Unnamed");
|
||||
}
|
||||
|
||||
if (includeHandlers) {
|
||||
for (IContainerTooltipHandler handler : tooltipHandlers) {
|
||||
@@ -222,7 +241,6 @@ public class GuiContainerManager {
|
||||
public static String itemDisplayNameShort(ItemStack itemstack) {
|
||||
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> namelist = itemstack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
|
||||
|
||||
if (!namelist.isEmpty() && !"".equals(namelist.get(0))) {
|
||||
@@ -255,36 +273,32 @@ public class GuiContainerManager {
|
||||
return EnumChatFormatting.getTextWithoutFormattingCodes(sb.toString());
|
||||
}
|
||||
|
||||
public static void drawItem(int i, int j, ItemStack itemstack) {
|
||||
drawItem(i, j, itemstack, false);
|
||||
public static void drawItem(int offsetX, int offsetY, ItemStack itemstack) {
|
||||
drawItem(offsetX, offsetY, itemstack, false);
|
||||
}
|
||||
|
||||
public static void drawItem(int i, int j, ItemStack itemstack, boolean smallAmount) {
|
||||
drawItem(i, j, itemstack, smallAmount, null);
|
||||
public static void drawItem(int offsetX, int offsetY, ItemStack itemstack, boolean smallAmount) {
|
||||
drawItem(offsetX, offsetY, itemstack, smallAmount, null);
|
||||
}
|
||||
|
||||
public static void drawItem(int i, int j, ItemStack itemstack, boolean smallAmount, String stackSize) {
|
||||
drawItem(i, j, itemstack, getFontRenderer(itemstack), smallAmount, stackSize);
|
||||
public static void drawItem(int offsetX, int offsetY, ItemStack itemstack, boolean smallAmount, String quantity) {
|
||||
drawItem(offsetX, offsetY, itemstack, getFontRenderer(itemstack), smallAmount, quantity);
|
||||
}
|
||||
|
||||
public static void drawItem(int i, int j, ItemStack itemstack, FontRenderer fontRenderer) {
|
||||
drawItem(i, j, itemstack, fontRenderer, false, null);
|
||||
public static void drawItem(int offsetX, int offsetY, ItemStack itemstack, FontRenderer fontRenderer) {
|
||||
drawItem(offsetX, offsetY, itemstack, fontRenderer, false, null);
|
||||
}
|
||||
|
||||
private static int modelviewDepth = -1;
|
||||
private static final HashSet<String> stackTraces = new HashSet<>();
|
||||
private static final ItemStackSet renderingErrorItems = new ItemStackSet();
|
||||
|
||||
public static void drawItem(int i, int j, ItemStack itemstack, FontRenderer fontRenderer, boolean smallAmount,
|
||||
String stackSize) {
|
||||
enable3DRender();
|
||||
// for lighting correction
|
||||
boolean glRescale = GL11.glGetBoolean(GL12.GL_RESCALE_NORMAL);
|
||||
public static void drawItem(int offsetX, int offsetY, ItemStack itemstack, FontRenderer fontRenderer,
|
||||
boolean smallAmount, String quantity) {
|
||||
|
||||
float zLevel = drawItems.zLevel += 100F;
|
||||
float scale = smallAmount ? 0.5f : 1f;
|
||||
|
||||
try {
|
||||
drawItems.renderItemAndEffectIntoGUI(fontRenderer, renderEngine, itemstack, i, j);
|
||||
safeItemRenderContext(itemstack, offsetX, offsetY, fontRenderer, () -> {
|
||||
float scale = smallAmount ? 0.5f : 1f;
|
||||
String stackSize = quantity;
|
||||
|
||||
if (stackSize == null) {
|
||||
if (itemstack.stackSize > 1) {
|
||||
@@ -301,41 +315,17 @@ public class GuiContainerManager {
|
||||
} else {
|
||||
stackSize = "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (scale != 1f) {
|
||||
drawItems.renderItemAndEffectIntoGUI(fontRenderer, renderEngine, itemstack, offsetX, offsetY);
|
||||
|
||||
if (!stackSize.isEmpty()) {
|
||||
drawBigStackSize(i, j, stackSize, scale);
|
||||
}
|
||||
|
||||
// stackSize = "". it needed for correct draw item with alpha and blend
|
||||
drawItems.renderItemOverlayIntoGUI(fontRenderer, renderEngine, itemstack, i, j, "");
|
||||
} else {
|
||||
drawItems.renderItemOverlayIntoGUI(fontRenderer, renderEngine, itemstack, i, j, stackSize);
|
||||
if (scale != 1f && !stackSize.isEmpty()) {
|
||||
drawBigStackSize(offsetX, offsetY, stackSize, scale);
|
||||
stackSize = "";
|
||||
}
|
||||
|
||||
if (!checkMatrixStack()) throw new IllegalStateException("Modelview matrix stack too deep");
|
||||
if (Tessellator.instance.isDrawing) throw new IllegalStateException("Still drawing");
|
||||
} catch (Exception e) {
|
||||
NEIClientUtils.reportErrorBuffered(e, stackTraces, itemstack);
|
||||
|
||||
restoreMatrixStack();
|
||||
if (Tessellator.instance.isDrawing) Tessellator.instance.draw();
|
||||
|
||||
drawItems.zLevel = zLevel;
|
||||
drawItems.renderItemIntoGUI(fontRenderer, renderEngine, new ItemStack(Blocks.fire), i, j);
|
||||
}
|
||||
|
||||
if (glRescale) {
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
} else {
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
}
|
||||
|
||||
enable2DRender();
|
||||
drawItems.zLevel = zLevel - 100;
|
||||
drawItems.renderItemOverlayIntoGUI(fontRenderer, renderEngine, itemstack, offsetX, offsetY, stackSize);
|
||||
});
|
||||
}
|
||||
|
||||
// copy from appeng.client.render.AppEngRenderItem
|
||||
@@ -345,15 +335,52 @@ public class GuiContainerManager {
|
||||
enable2DRender();
|
||||
GL11.glScaled(scale, scale, scale);
|
||||
|
||||
final int X = (int) (((float) offsetX + 16.0f - fontRenderer.getStringWidth(stackSize) * scale)
|
||||
* inverseScaleFactor);
|
||||
final int Y = (int) (((float) offsetY + 16.0f - 7.0f * scale) * inverseScaleFactor);
|
||||
final int X = (int) ((offsetX + 16.0f - fontRenderer.getStringWidth(stackSize) * scale) * inverseScaleFactor);
|
||||
final int Y = (int) ((offsetY + 16.0f - 7.0f * scale) * inverseScaleFactor);
|
||||
fontRenderer.drawStringWithShadow(stackSize, X, Y, 16777215);
|
||||
|
||||
GL11.glScaled(inverseScaleFactor, inverseScaleFactor, inverseScaleFactor);
|
||||
enable3DRender();
|
||||
}
|
||||
|
||||
private static void safeItemRenderContext(ItemStack stack, int x, int y, FontRenderer fontRenderer,
|
||||
Runnable callback) {
|
||||
float zLevel = drawItems.zLevel += 100F;
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||
enable3DRender();
|
||||
|
||||
if (!renderingErrorItems.contains(stack)) {
|
||||
try {
|
||||
callback.run();
|
||||
|
||||
if (!checkMatrixStack()) throw new IllegalStateException("Modelview matrix stack too deep");
|
||||
if (Tessellator.instance.isDrawing) throw new IllegalStateException("Still drawing");
|
||||
} catch (Exception e) {
|
||||
NEIClientUtils.reportErrorBuffered(e, stackTraces, stack);
|
||||
|
||||
restoreMatrixStack();
|
||||
if (Tessellator.instance.isDrawing) Tessellator.instance.draw();
|
||||
|
||||
drawItems.zLevel = zLevel;
|
||||
drawItems.renderItemIntoGUI(fontRenderer, renderEngine, new ItemStack(Blocks.fire), x, y);
|
||||
renderingErrorItems.add(stack);
|
||||
}
|
||||
} else {
|
||||
drawItems.renderItemIntoGUI(fontRenderer, renderEngine, new ItemStack(Blocks.fire), x, y);
|
||||
}
|
||||
|
||||
GL11.glPopAttrib();
|
||||
drawItems.zLevel = zLevel - 100;
|
||||
}
|
||||
|
||||
public static void registerReloadResourceListener() {
|
||||
if (Minecraft.getMinecraft().getResourceManager() instanceof SimpleReloadableResourceManager) {
|
||||
SimpleReloadableResourceManager manager = (SimpleReloadableResourceManager) Minecraft.getMinecraft()
|
||||
.getResourceManager();
|
||||
manager.registerReloadListener(new ResourcePackReloaded());
|
||||
}
|
||||
}
|
||||
|
||||
public static void enableMatrixStackLogging() {
|
||||
modelviewDepth = GL11.glGetInteger(GL11.GL_MODELVIEW_STACK_DEPTH);
|
||||
}
|
||||
@@ -517,6 +544,7 @@ public class GuiContainerManager {
|
||||
|
||||
public void renderToolTips(int mousex, int mousey) {
|
||||
List<String> tooltip = new LinkedList<>();
|
||||
Map<String, String> hotkeys = new HashMap<>();
|
||||
FontRenderer font = GuiDraw.fontRenderer;
|
||||
|
||||
synchronized (instanceTooltipHandlers) {
|
||||
@@ -538,7 +566,39 @@ public class GuiContainerManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (tooltip.size() > 0) tooltip.set(0, tooltip.get(0) + GuiDraw.TOOLTIP_LINESPACE); // add space after 'title'
|
||||
if (!tooltip.isEmpty()) tooltip.set(0, tooltip.get(0) + GuiDraw.TOOLTIP_LINESPACE); // add space after 'title'
|
||||
|
||||
synchronized (instanceTooltipHandlers) {
|
||||
for (IContainerTooltipHandler handler : instanceTooltipHandlers) {
|
||||
hotkeys = handler.handleHotkeys(window, mousex, mousey, hotkeys);
|
||||
}
|
||||
}
|
||||
|
||||
if (!hotkeys.isEmpty()) {
|
||||
List<String> hotkeystips = new ArrayList<>();
|
||||
|
||||
if (!NEIClientUtils.altKey()) {
|
||||
hotkeystips.add(
|
||||
EnumChatFormatting.GRAY
|
||||
+ translate("showHotkeys", EnumChatFormatting.GOLD + "ALT" + EnumChatFormatting.GRAY));
|
||||
} else {
|
||||
|
||||
for (Map.Entry<String, String> entry : hotkeys.entrySet()) {
|
||||
hotkeystips.add(getHotkeyTip(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
|
||||
hotkeystips.sort((a, b) -> Integer.compare(a.indexOf(" - "), b.indexOf(" - ")));
|
||||
hotkeystips.set(
|
||||
hotkeystips.size() - 1,
|
||||
hotkeystips.get(hotkeystips.size() - 1) + GuiDraw.TOOLTIP_LINESPACE);
|
||||
}
|
||||
|
||||
if (tooltip.isEmpty()) {
|
||||
tooltip.addAll(hotkeystips);
|
||||
} else {
|
||||
tooltip.addAll(1, hotkeystips);
|
||||
}
|
||||
}
|
||||
|
||||
drawPagedTooltip(font, mousex + 12, mousey - 12, tooltip);
|
||||
|
||||
@@ -547,6 +607,10 @@ public class GuiContainerManager {
|
||||
}
|
||||
}
|
||||
|
||||
private String getHotkeyTip(String key, String message) {
|
||||
return EnumChatFormatting.GOLD + key + EnumChatFormatting.GRAY + " - " + message + EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
private static int tooltipPage;
|
||||
|
||||
public static void drawPagedTooltip(FontRenderer font, int x, int y, List<String> list) {
|
||||
@@ -559,7 +623,7 @@ public class GuiContainerManager {
|
||||
"inventory.tooltip.page",
|
||||
tooltipPage + 1,
|
||||
tooltips.size(),
|
||||
NEIClientConfig.getKeyName(NEIClientConfig.getKeyBinding("gui.next_tooltip"), true)));
|
||||
NEIClientConfig.getKeyName("gui.next_tooltip")));
|
||||
}
|
||||
drawMultilineTip(font, x, y, tooltips.get(tooltipPage));
|
||||
}
|
||||
@@ -590,6 +654,7 @@ public class GuiContainerManager {
|
||||
}
|
||||
|
||||
public static boolean shouldShowTooltip(GuiContainer window) {
|
||||
if (window == null) return false;
|
||||
for (IContainerObjectHandler handler : objectHandlers) if (!handler.shouldShowTooltip(window)) return false;
|
||||
|
||||
return window.mc.thePlayer.inventory.getItemStack() == null;
|
||||
@@ -671,38 +736,17 @@ public class GuiContainerManager {
|
||||
* Delegate for changing item rendering for certain slots. Eg. Shrinking text for large itemstacks
|
||||
*/
|
||||
public void drawSlotItem(Slot slot, ItemStack stack, int x, int y, String quantity) {
|
||||
// for lighting correction
|
||||
boolean glRescale = GL11.glGetBoolean(GL12.GL_RESCALE_NORMAL);
|
||||
float zLevel = drawItems.zLevel += 100F;
|
||||
|
||||
try {
|
||||
if (window instanceof IGuiSlotDraw) {
|
||||
((IGuiSlotDraw) window).drawSlotItem(slot, stack, x, y, quantity);
|
||||
} else {
|
||||
|
||||
if (quantity == null) {
|
||||
quantity = stack != null && stack.stackSize > 1 ? String.valueOf(stack.stackSize) : "";
|
||||
}
|
||||
|
||||
drawItems.renderItemAndEffectIntoGUI(fontRenderer, renderEngine, stack, x, y);
|
||||
drawItems.renderItemOverlayIntoGUI(fontRenderer, renderEngine, stack, x, y, quantity);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
NEIClientUtils.reportErrorBuffered(e, stackTraces, stack);
|
||||
|
||||
restoreMatrixStack();
|
||||
if (Tessellator.instance.isDrawing) Tessellator.instance.draw();
|
||||
|
||||
drawItems.zLevel = zLevel;
|
||||
drawItems.renderItemIntoGUI(fontRenderer, renderEngine, new ItemStack(Blocks.fire), x, y);
|
||||
if (window instanceof IGuiSlotDraw) {
|
||||
safeItemRenderContext(
|
||||
stack,
|
||||
x,
|
||||
y,
|
||||
fontRenderer,
|
||||
() -> ((IGuiSlotDraw) window).drawSlotItem(slot, stack, x, y, quantity));
|
||||
} else if (stack != null) {
|
||||
drawItem(x, y, stack, false, quantity);
|
||||
}
|
||||
|
||||
if (glRescale) {
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
} else {
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
}
|
||||
drawItems.zLevel = zLevel - 100;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.stream.Stream;
|
||||
*/
|
||||
final class HideousLinkedList<E> extends LinkedList<E> {
|
||||
|
||||
private static final long serialVersionUID = -8504433551965776915L;
|
||||
private final List<E> backing;
|
||||
|
||||
HideousLinkedList(List<E> backing) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package codechicken.nei.guihook;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -15,36 +16,54 @@ public interface IContainerTooltipHandler {
|
||||
* Use this to add tooltips for other objects. If the current tip has lines in it after this call, the item tootip
|
||||
* will not be handled. GuiContainerManager.shouldShowTooltip is not enforced here. It is recommended that you make
|
||||
* this check yourself
|
||||
*
|
||||
*
|
||||
* @param gui An instance of the currentscreen
|
||||
* @param mousex The x position of the mouse in pixels from left
|
||||
* @param mousey The y position of the mouse in pixels from top
|
||||
* @param currenttip A list of strings, representing each line of the current tooltip as modified by other handlers
|
||||
* @return The modified list. NOTE: Do not return null
|
||||
*/
|
||||
public List<String> handleTooltip(GuiContainer gui, int mousex, int mousey, List<String> currenttip);
|
||||
default List<String> handleTooltip(GuiContainer gui, int mousex, int mousey, List<String> currenttip) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this for modifying the multiline display name of an item which may not necessarily be under the mouse.
|
||||
* GuiContainerManager.shouldShowTooltip is enforced here.
|
||||
*
|
||||
*
|
||||
* @param gui An instance of the currentscreen. If only general information about the item is wanted (Eg.
|
||||
* potion effects) then this may be null.
|
||||
* @param itemstack The ItemStack under the mouse
|
||||
* @param currenttip A list of strings, representing each line of the current tooltip as modified by other handlers
|
||||
* @return The modified list. NOTE: Do not return null
|
||||
*/
|
||||
public List<String> handleItemDisplayName(GuiContainer gui, ItemStack itemstack, List<String> currenttip);
|
||||
default List<String> handleItemDisplayName(GuiContainer gui, ItemStack itemstack, List<String> currenttip) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this for modifying the tooltips of items that are under the mouse. GuiContainerManager.shouldShowTooltip is
|
||||
* enforced here.
|
||||
*
|
||||
*
|
||||
* @param gui An instance of the currentscreen
|
||||
* @param itemstack The ItemStack under the mouse
|
||||
* @param currenttip A list of strings, representing each line of the current tooltip as modified by other handlers
|
||||
* @return The modified list. NOTE: Do not return null
|
||||
*/
|
||||
public List<String> handleItemTooltip(GuiContainer gui, ItemStack itemstack, int mousex, int mousey,
|
||||
List<String> currenttip);
|
||||
default List<String> handleItemTooltip(GuiContainer gui, ItemStack itemstack, int mousex, int mousey,
|
||||
List<String> currenttip) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this to specify a list of hotkeys that will work when hovering over an element that is under the mouse
|
||||
* pointer.
|
||||
*
|
||||
* @param gui An instance of the currentscreen
|
||||
* @param mousex The x position of the mouse in pixels from left
|
||||
* @param mousey The y position of the mouse in pixels from top
|
||||
*/
|
||||
default Map<String, String> handleHotkeys(GuiContainer gui, int mousex, int mousey, Map<String, String> hotkeys) {
|
||||
return hotkeys;
|
||||
}
|
||||
}
|
||||
@@ -16,17 +16,19 @@ import codechicken.lib.inventory.InventoryUtils;
|
||||
import codechicken.nei.FastTransferManager;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.api.IOverlayHandler;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
|
||||
@SuppressWarnings("rawtypes, unchecked")
|
||||
public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
|
||||
public static Class gtItem;
|
||||
private static Class<?> gtItem;
|
||||
|
||||
static {
|
||||
try {
|
||||
gtItem = Class.forName("gregtech.api.items.GT_MetaBase_Item");
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
gtItem = null;
|
||||
final ClassLoader loader = DefaultOverlayHandler.class.getClassLoader();
|
||||
gtItem = ReflectionHelper
|
||||
.getClass(loader, "gregtech.api.items.MetaBaseItem", "gregtech.api.items.GT_MetaBase_Item");
|
||||
} catch (Exception ignored) {
|
||||
/* Do nothing */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,20 +87,21 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
if (quantity != 0) moveIngredients(gui, assignedIngredients, quantity);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private boolean clearIngredients(GuiContainer gui, List<PositionedStack> ingreds) {
|
||||
for (PositionedStack pstack : ingreds) for (Slot slot : (List<Slot>) gui.inventorySlots.inventorySlots)
|
||||
if (slot.xDisplayPosition == pstack.relx + offsetx && slot.yDisplayPosition == pstack.rely + offsety) {
|
||||
if (!slot.getHasStack()) continue;
|
||||
for (PositionedStack pstack : ingreds) {
|
||||
for (Slot slot : gui.inventorySlots.inventorySlots) {
|
||||
if (slot.xDisplayPosition == pstack.relx + offsetx && slot.yDisplayPosition == pstack.rely + offsety) {
|
||||
if (!slot.getHasStack()) continue;
|
||||
|
||||
FastTransferManager.clickSlot(gui, slot.slotNumber, 0, 1);
|
||||
if (slot.getHasStack()) return false;
|
||||
FastTransferManager.clickSlot(gui, slot.slotNumber, 0, 1);
|
||||
if (slot.getHasStack()) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void moveIngredients(GuiContainer gui, List<IngredientDistribution> assignedIngredients, int quantity) {
|
||||
for (IngredientDistribution distrib : assignedIngredients) {
|
||||
if (distrib.slots.length == 0) continue;
|
||||
@@ -112,7 +115,7 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
int slotTransferred = 0;
|
||||
int slotTransferCap = pstack.getMaxStackSize();
|
||||
|
||||
for (Slot slot : (List<Slot>) gui.inventorySlots.inventorySlots) {
|
||||
for (Slot slot : gui.inventorySlots.inventorySlots) {
|
||||
if (!slot.getHasStack() || !canMoveFrom(slot, gui)) continue;
|
||||
|
||||
ItemStack stack = slot.getStack();
|
||||
@@ -181,7 +184,7 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
assignedSlots.add(new LinkedList<>());
|
||||
}
|
||||
|
||||
while (avaliableSlots.size() > 0 && remainingIngreds.size() > 0) {
|
||||
while (!avaliableSlots.isEmpty() && !remainingIngreds.isEmpty()) {
|
||||
for (Iterator<Integer> iterator = remainingIngreds.iterator(); iterator.hasNext();) {
|
||||
int i = iterator.next();
|
||||
boolean assigned = false;
|
||||
@@ -199,8 +202,9 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
}
|
||||
}
|
||||
|
||||
if (!assigned || istack.numSlots * istack.stack.getMaxStackSize() >= istack.invAmount)
|
||||
if (!assigned || istack.numSlots * istack.stack.getMaxStackSize() >= istack.invAmount) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,9 +249,8 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
return assignedIngredients;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void findInventoryQuantities(GuiContainer gui, List<DistributedIngred> ingredStacks) {
|
||||
for (Slot slot : (List<Slot>) gui.inventorySlots.inventorySlots) /* work out how much we have to go round */ {
|
||||
for (Slot slot : gui.inventorySlots.inventorySlots) /* work out how much we have to go round */ {
|
||||
if (slot.getHasStack() && canMoveFrom(slot, gui)) {
|
||||
ItemStack pstack = slot.getStack();
|
||||
DistributedIngred istack = findIngred(ingredStacks, pstack);
|
||||
@@ -272,13 +275,12 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
return slot.inventory instanceof InventoryPlayer;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Slot[][] mapIngredSlots(GuiContainer gui, List<PositionedStack> ingredients) {
|
||||
Slot[][] recipeSlotList = new Slot[ingredients.size()][];
|
||||
for (int i = 0; i < ingredients.size(); i++) /* identify slots */ {
|
||||
LinkedList<Slot> recipeSlots = new LinkedList<>();
|
||||
PositionedStack pstack = ingredients.get(i);
|
||||
for (Slot slot : (List<Slot>) gui.inventorySlots.inventorySlots) {
|
||||
for (Slot slot : gui.inventorySlots.inventorySlots) {
|
||||
if (slot.xDisplayPosition == pstack.relx + offsetx && slot.yDisplayPosition == pstack.rely + offsety) {
|
||||
recipeSlots.add(slot);
|
||||
break;
|
||||
|
||||
@@ -51,7 +51,6 @@ public class FuelRecipeHandler extends FurnaceRecipeHandler {
|
||||
return NEIClientUtils.translate("recipe.fuel");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void loadAllSmelting() {
|
||||
// Note: Not safe as written for parallelStream
|
||||
final Map<ItemStack, ItemStack> smeltingRecipes = (Map<ItemStack, ItemStack>) FurnaceRecipes.smelting()
|
||||
|
||||
@@ -5,7 +5,9 @@ import static codechicken.lib.gui.GuiDraw.getMousePosition;
|
||||
import java.awt.Point;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -24,6 +26,7 @@ public class GuiCraftingRecipe extends GuiRecipe<ICraftingHandler> {
|
||||
|
||||
public static ArrayList<ICraftingHandler> craftinghandlers = new ArrayList<>();
|
||||
public static ArrayList<ICraftingHandler> serialCraftingHandlers = new ArrayList<>();
|
||||
private static Set<String> existingHandlers = new HashSet<>();
|
||||
|
||||
public static boolean openRecipeGui(String outputId, Object... results) {
|
||||
return createRecipeGui(outputId, true, results) != null;
|
||||
@@ -41,7 +44,7 @@ public class GuiCraftingRecipe extends GuiRecipe<ICraftingHandler> {
|
||||
} else if ("recipeId".equals(outputId)) {
|
||||
recipeId = (BookmarkRecipeId) results[1];
|
||||
} else {
|
||||
recipeId = getCurrentRecipe(mc.currentScreen);
|
||||
recipeId = getCurrentRecipeId(mc.currentScreen);
|
||||
}
|
||||
|
||||
final ArrayList<ICraftingHandler> handlers = getCraftingHandlers(outputId, results);
|
||||
@@ -155,12 +158,24 @@ public class GuiCraftingRecipe extends GuiRecipe<ICraftingHandler> {
|
||||
public static void registerRecipeHandler(ICraftingHandler handler) {
|
||||
final String handlerId = handler.getHandlerId();
|
||||
|
||||
if (craftinghandlers.stream().anyMatch(h -> h.getHandlerId().equals(handlerId))
|
||||
|| serialCraftingHandlers.stream().anyMatch(h -> h.getHandlerId().equals(handlerId)))
|
||||
if (existingHandlers.contains(handlerId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (existingHandlers) {
|
||||
existingHandlers.add(handlerId);
|
||||
}
|
||||
|
||||
if (NEIClientConfig.serialHandlers.contains(handlerId)) {
|
||||
synchronized (serialCraftingHandlers) {
|
||||
serialCraftingHandlers.add(handler);
|
||||
}
|
||||
} else {
|
||||
synchronized (craftinghandlers) {
|
||||
craftinghandlers.add(handler);
|
||||
}
|
||||
}
|
||||
|
||||
if (NEIClientConfig.serialHandlers.contains(handlerId)) serialCraftingHandlers.add(handler);
|
||||
else craftinghandlers.add(handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,357 @@
|
||||
package codechicken.nei.recipe;
|
||||
|
||||
import static codechicken.nei.NEIClientUtils.translate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.BookmarkPanel.BookmarkRecipe;
|
||||
import codechicken.nei.GuiNEIButton;
|
||||
import codechicken.nei.ItemPanels;
|
||||
import codechicken.nei.ItemsTooltipLineHandler;
|
||||
import codechicken.nei.LayoutManager;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.api.IOverlayHandler;
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
|
||||
public class GuiOverlayButton extends GuiNEIButton {
|
||||
|
||||
public static class UpdateOverlayButtonsEvent extends GuiScreenEvent {
|
||||
|
||||
public List<GuiOverlayButton> buttonList;
|
||||
|
||||
public UpdateOverlayButtonsEvent(GuiRecipe<?> gui, List<GuiOverlayButton> buttonList) {
|
||||
super(gui);
|
||||
this.buttonList = new ArrayList<>(buttonList);
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class Pre extends UpdateOverlayButtonsEvent {
|
||||
|
||||
public int xOffset;
|
||||
public int yOffset;
|
||||
public int height;
|
||||
public HandlerInfo handlerInfo;
|
||||
|
||||
public Pre(GuiRecipe<?> gui, int xOffset, int yOffset, int height, HandlerInfo handlerInfo) {
|
||||
super(gui, new ArrayList<>());
|
||||
this.xOffset = xOffset;
|
||||
this.yOffset = yOffset;
|
||||
this.height = height;
|
||||
this.handlerInfo = handlerInfo;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Post extends UpdateOverlayButtonsEvent {
|
||||
|
||||
public Post(GuiRecipe<?> gui, List<GuiOverlayButton> buttonList) {
|
||||
super(gui, buttonList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum ItemOverlayFormat {
|
||||
|
||||
BACKGROUND,
|
||||
ICON;
|
||||
|
||||
public static ItemOverlayFormat from(int overlay) {
|
||||
return overlay == 2 ? ItemOverlayFormat.BACKGROUND : ItemOverlayFormat.ICON;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ItemOverlayState {
|
||||
|
||||
protected PositionedStack slot;
|
||||
protected boolean isPresent;
|
||||
|
||||
public ItemOverlayState(PositionedStack slot, boolean isPresent) {
|
||||
this.slot = slot;
|
||||
this.isPresent = isPresent;
|
||||
}
|
||||
|
||||
public boolean isPresent() {
|
||||
return this.isPresent;
|
||||
}
|
||||
|
||||
public PositionedStack getSlot() {
|
||||
return this.slot;
|
||||
}
|
||||
|
||||
public void draw(ItemOverlayFormat format) {
|
||||
LayoutManager.drawItemPresenceOverlay(
|
||||
this.slot.relx,
|
||||
this.slot.rely,
|
||||
this.isPresent,
|
||||
format == ItemOverlayFormat.BACKGROUND);
|
||||
}
|
||||
}
|
||||
|
||||
private static final int OVERLAY_BUTTON_ID_START = 4;
|
||||
|
||||
public final GuiContainer firstGui;
|
||||
public final IRecipeHandler handler;
|
||||
public final int recipeIndex;
|
||||
|
||||
protected ItemsTooltipLineHandler missedMaterialsTooltipLineHandler;
|
||||
|
||||
protected final IOverlayHandler overlayHandler;
|
||||
protected final List<ItemOverlayState> itemPresenceCache = new ArrayList<>();
|
||||
protected boolean requireShiftForOverlayRecipe = true;
|
||||
protected boolean useOverlayRenderer = false;
|
||||
protected boolean hasOverlay = false;
|
||||
|
||||
public GuiOverlayButton(GuiContainer firstGui, IRecipeHandler handler, int recipeIndex, int x, int y, int width,
|
||||
int height) {
|
||||
super(OVERLAY_BUTTON_ID_START + recipeIndex, x, y, width, height, "+");
|
||||
this.firstGui = firstGui != null && firstGui.inventorySlots != null ? firstGui : null;
|
||||
this.handler = handler;
|
||||
this.recipeIndex = recipeIndex;
|
||||
this.hasOverlay = this.firstGui != null
|
||||
&& handler.hasOverlay(this.firstGui, this.firstGui.inventorySlots, recipeIndex);
|
||||
this.useOverlayRenderer = this.hasOverlay && handler.getOverlayRenderer(firstGui, recipeIndex) != null;
|
||||
this.overlayHandler = this.hasOverlay ? handler.getOverlayHandler(firstGui, recipeIndex) : null;
|
||||
|
||||
setRequireShiftForOverlayRecipe(NEIClientConfig.requireShiftForOverlayRecipe());
|
||||
ingredientsOverlay();
|
||||
}
|
||||
|
||||
public List<String> handleTooltip(GuiRecipe<?> gui, List<String> currenttip) {
|
||||
currenttip.add(translate("recipe.overlay"));
|
||||
|
||||
if (!this.enabled && this.requireShiftForOverlayRecipe && this.overlayHandler == null) {
|
||||
currenttip.set(currenttip.size() - 1, currenttip.get(currenttip.size() - 1) + GuiDraw.TOOLTIP_LINESPACE);
|
||||
currenttip.add(EnumChatFormatting.RED + translate("recipe.overlay.mismatch") + EnumChatFormatting.RESET);
|
||||
} else if (this.missedMaterialsTooltipLineHandler != null) {
|
||||
|
||||
if ((!this.requireShiftForOverlayRecipe || NEIClientUtils.shiftKey()) && this.overlayHandler != null) {
|
||||
this.missedMaterialsTooltipLineHandler.setLabelColor(EnumChatFormatting.RED);
|
||||
} else {
|
||||
this.missedMaterialsTooltipLineHandler.setLabelColor(EnumChatFormatting.GRAY);
|
||||
}
|
||||
|
||||
currenttip.add(GuiDraw.TOOLTIP_HANDLER + GuiDraw.getTipLineId(this.missedMaterialsTooltipLineHandler));
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
public Map<String, String> handleHotkeys(GuiContainer gui, int mousex, int mousey, Map<String, String> hotkeys) {
|
||||
|
||||
if (this.requireShiftForOverlayRecipe && this.useOverlayRenderer) {
|
||||
hotkeys.put(translate("recipe.overlay.fillCraftingGrid.key"), translate("recipe.overlay.fillCraftingGrid"));
|
||||
}
|
||||
|
||||
String keyName = NEIClientConfig.getKeyName("gui.bookmark");
|
||||
if (keyName != null) {
|
||||
hotkeys.put(keyName, translate("recipe.overlay.bookmark"));
|
||||
}
|
||||
|
||||
keyName = NEIClientConfig.getKeyName("gui.bookmark_recipe");
|
||||
if (keyName != null) {
|
||||
hotkeys.put(keyName, translate("recipe.overlay.bookmarkRecipe"));
|
||||
}
|
||||
|
||||
keyName = NEIClientConfig.getKeyName("gui.bookmark_count");
|
||||
if (keyName != null) {
|
||||
hotkeys.put(keyName, translate("recipe.overlay.bookmarkAmount"));
|
||||
}
|
||||
|
||||
keyName = NEIClientConfig.getKeyName("gui.bookmark_recipe_count");
|
||||
if (keyName != null) {
|
||||
hotkeys.put(keyName, translate("recipe.overlay.bookmarkRecipeAndAmount"));
|
||||
}
|
||||
|
||||
return hotkeys;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int mouseX, int mouseY) {
|
||||
if (this.firstGui != null) {
|
||||
this.firstGui.mc.displayGuiScreen(this.firstGui);
|
||||
overlayRecipe(NEIClientUtils.shiftKey());
|
||||
}
|
||||
}
|
||||
|
||||
public void drawItemPresenceOverlay() {
|
||||
final int presenceOverlay = NEIClientConfig.itemPresenceOverlay();
|
||||
final boolean highlightPresentItem = NEIClientConfig.isSlotHighlightPresent();
|
||||
final ItemOverlayFormat format = ItemOverlayFormat.from(presenceOverlay);
|
||||
|
||||
for (ItemOverlayState overlay : ingredientsOverlay()) {
|
||||
if (highlightPresentItem || !overlay.isPresent()) {
|
||||
overlay.draw(format);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected List<ItemOverlayState> ingredientsOverlay() {
|
||||
List<PositionedStack> ingredients = this.handler.getIngredientStacks(recipeIndex);
|
||||
|
||||
if (this.itemPresenceCache.size() != ingredients.size()) {
|
||||
this.itemPresenceCache.clear();
|
||||
|
||||
if (this.overlayHandler != null) {
|
||||
this.itemPresenceCache
|
||||
.addAll(this.overlayHandler.presenceOverlay(this.firstGui, this.handler, this.recipeIndex));
|
||||
} else if (this.firstGui != null) {
|
||||
this.itemPresenceCache.addAll(presenceOverlay(ingredients));
|
||||
}
|
||||
|
||||
List<ItemStack> items = this.itemPresenceCache.stream().filter(state -> !state.isPresent())
|
||||
.map(state -> state.getSlot().item).collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
if (!items.isEmpty()) {
|
||||
this.missedMaterialsTooltipLineHandler = new ItemsTooltipLineHandler(
|
||||
translate("recipe.overlay.missing"),
|
||||
items,
|
||||
true,
|
||||
Integer.MAX_VALUE);
|
||||
} else {
|
||||
this.missedMaterialsTooltipLineHandler = null;
|
||||
}
|
||||
}
|
||||
|
||||
return this.itemPresenceCache;
|
||||
}
|
||||
|
||||
public void setRequireShiftForOverlayRecipe(boolean require) {
|
||||
this.requireShiftForOverlayRecipe = require;
|
||||
this.enabled = this.hasOverlay && (this.requireShiftForOverlayRecipe || this.overlayHandler != null);
|
||||
}
|
||||
|
||||
public void setUseOverlayRenderer(boolean use) {
|
||||
this.useOverlayRenderer = use;
|
||||
}
|
||||
|
||||
public boolean useOverlayRenderer() {
|
||||
return this.useOverlayRenderer;
|
||||
}
|
||||
|
||||
public boolean canFillCraftingGrid() {
|
||||
return this.missedMaterialsTooltipLineHandler == null;
|
||||
}
|
||||
|
||||
public boolean hasOverlay() {
|
||||
return this.hasOverlay;
|
||||
}
|
||||
|
||||
private List<ItemOverlayState> presenceOverlay(List<PositionedStack> ingredients) {
|
||||
final List<ItemOverlayState> itemPresenceSlots = new ArrayList<>();
|
||||
final List<ItemStack> invStacks = this.firstGui.inventorySlots.inventorySlots.stream()
|
||||
.filter(
|
||||
s -> s != null && s.getStack() != null
|
||||
&& s.getStack().stackSize > 0
|
||||
&& s.isItemValid(s.getStack())
|
||||
&& s.canTakeStack(this.firstGui.mc.thePlayer))
|
||||
.map(s -> s.getStack().copy()).collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
for (PositionedStack stack : ingredients) {
|
||||
Optional<ItemStack> used = invStacks.stream().filter(is -> is.stackSize > 0 && stack.contains(is))
|
||||
.findAny();
|
||||
|
||||
itemPresenceSlots.add(new ItemOverlayState(stack, used.isPresent()));
|
||||
|
||||
if (used.isPresent()) {
|
||||
ItemStack is = used.get();
|
||||
is.stackSize -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
return itemPresenceSlots;
|
||||
}
|
||||
|
||||
public void overlayRecipe(boolean shift) {
|
||||
if (!this.hasOverlay) return;
|
||||
|
||||
if (!this.useOverlayRenderer || !this.requireShiftForOverlayRecipe || shift) {
|
||||
if (this.overlayHandler != null) {
|
||||
this.overlayHandler.overlayRecipe(
|
||||
this.firstGui,
|
||||
this.handler,
|
||||
this.recipeIndex,
|
||||
!this.requireShiftForOverlayRecipe || shift);
|
||||
}
|
||||
} else {
|
||||
LayoutManager.overlayRenderer = this.handler.getOverlayRenderer(this.firstGui, this.recipeIndex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void lastKeyTyped(GuiRecipe<?> gui, char keyChar, int keyID) {
|
||||
|
||||
if (NEIClientConfig.isKeyHashDown("gui.bookmark")) {
|
||||
saveRecipeInBookmark(false, false);
|
||||
} else if (NEIClientConfig.isKeyHashDown("gui.bookmark_recipe")) {
|
||||
saveRecipeInBookmark(true, false);
|
||||
} else if (NEIClientConfig.isKeyHashDown("gui.bookmark_count")) {
|
||||
saveRecipeInBookmark(false, true);
|
||||
} else if (NEIClientConfig.isKeyHashDown("gui.bookmark_recipe_count")) {
|
||||
saveRecipeInBookmark(true, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void saveRecipeInBookmark(boolean saveIngredients, boolean saveStackSize) {
|
||||
final HandlerInfo handlerInfo = GuiRecipeTab.getHandlerInfo(this.handler);
|
||||
final List<PositionedStack> ingredients = this.handler.getIngredientStacks(this.recipeIndex);
|
||||
final BookmarkRecipeId recipeId = new BookmarkRecipeId(handlerInfo.getHandlerName(), ingredients);
|
||||
|
||||
if (!ItemPanels.bookmarkPanel.removeBookmarkRecipeId(recipeId)) {
|
||||
BookmarkRecipe recipe = new BookmarkRecipe();
|
||||
recipe.handlerName = recipeId.handlerName;
|
||||
recipe.recipeId = recipeId;
|
||||
|
||||
if (saveIngredients) {
|
||||
for (PositionedStack stack : ingredients) {
|
||||
recipe.ingredients.add(stack.item);
|
||||
}
|
||||
}
|
||||
|
||||
PositionedStack result = this.handler.getResultStack(this.recipeIndex);
|
||||
|
||||
if (result != null) {
|
||||
recipe.result.add(result.item);
|
||||
} else {
|
||||
for (PositionedStack stack : this.handler.getOtherStacks(this.recipeIndex)) {
|
||||
recipe.result.add(stack.item);
|
||||
}
|
||||
}
|
||||
|
||||
ItemPanels.bookmarkPanel.addRecipe(recipe, saveStackSize);
|
||||
}
|
||||
}
|
||||
|
||||
public int getResultStackSize(ItemStack stackover) {
|
||||
final List<PositionedStack> stacks = this.handler.getOtherStacks(this.recipeIndex);
|
||||
int stackSize = stackover.stackSize;
|
||||
|
||||
for (PositionedStack pStack : stacks) {
|
||||
if (StackInfo.equalItemAndNBT(pStack.item, stackover, true)) {
|
||||
stackSize += pStack.item.stackSize;
|
||||
}
|
||||
}
|
||||
|
||||
return stackSize;
|
||||
}
|
||||
|
||||
public Rectangle4i bounds() {
|
||||
return new Rectangle4i(this.xPosition, this.yPosition, this.width, this.height);
|
||||
}
|
||||
|
||||
public boolean contains(int mx, int my) {
|
||||
return bounds().contains(mx, my);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package codechicken.nei.recipe;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.fontRenderer;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
@@ -9,7 +8,7 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -21,6 +20,8 @@ import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -28,6 +29,8 @@ import org.lwjgl.opengl.GL11;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.Button;
|
||||
import codechicken.nei.GuiNEIButton;
|
||||
import codechicken.nei.ItemStackSet;
|
||||
import codechicken.nei.ItemsTooltipLineHandler;
|
||||
import codechicken.nei.LayoutManager;
|
||||
import codechicken.nei.NEICPH;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
@@ -51,6 +54,7 @@ import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.guihook.IContainerTooltipHandler;
|
||||
import codechicken.nei.guihook.IGuiClientSide;
|
||||
import codechicken.nei.guihook.IGuiHandleMouseWheel;
|
||||
import codechicken.nei.recipe.GuiOverlayButton.UpdateOverlayButtonsEvent;
|
||||
|
||||
public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer implements IGuiContainerOverlay,
|
||||
IGuiClientSide, IGuiHandleMouseWheel, IContainerTooltipHandler, INEIGuiHandler {
|
||||
@@ -72,6 +76,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
public static final List<IRecipeFilterProvider> recipeFilterers = new LinkedList<>();
|
||||
|
||||
protected boolean limitToOneRecipe = false;
|
||||
protected PermutationTooltipLineHandler permutationTooltipLineHandler;
|
||||
|
||||
// Background image
|
||||
final DrawableResource bgTop = new DrawableBuilder("nei:textures/gui/recipebg.png", 0, BG_TOP_Y, 176, BG_TOP_HEIGHT)
|
||||
@@ -103,8 +108,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
private GuiButton nexttype;
|
||||
private GuiButton prevtype;
|
||||
|
||||
private final int OVERLAY_BUTTON_ID_START = 4;
|
||||
private GuiButton[] overlayButtons;
|
||||
private GuiOverlayButton[] overlayButtons = new GuiOverlayButton[0];
|
||||
|
||||
private final Rectangle area = new Rectangle();
|
||||
private final GuiRecipeTabs recipeTabs;
|
||||
@@ -114,6 +118,35 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
|
||||
private int yShift = 0;
|
||||
|
||||
protected static class PermutationTooltipLineHandler extends ItemsTooltipLineHandler {
|
||||
|
||||
protected PositionedStack pStack = null;
|
||||
|
||||
public PermutationTooltipLineHandler(PositionedStack pStack, List<ItemStack> items) {
|
||||
super(NEIClientUtils.translate("recipe.accepts"), items, false, 5);
|
||||
this.pStack = pStack;
|
||||
}
|
||||
|
||||
public static PermutationTooltipLineHandler getInstance(PositionedStack pStack) {
|
||||
final ItemFilter filter = TemplateRecipeHandler.getItemFilter();
|
||||
List<ItemStack> items = Arrays.asList(pStack.items).stream().filter(filter::matches)
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
if (items.isEmpty()) {
|
||||
items = Arrays.asList(pStack.items);
|
||||
}
|
||||
|
||||
items = new ItemStackSet().addAll(items).keys();
|
||||
|
||||
if (items.size() > 1) {
|
||||
return new PermutationTooltipLineHandler(pStack, items);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class ItemRecipeFilter implements IRecipeFilter {
|
||||
|
||||
public ItemFilter filter;
|
||||
@@ -211,7 +244,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
guiRecipe.changePage(0);
|
||||
} else {
|
||||
final IRecipeFilter filter = new ItemRecipeFilter(GuiRecipe.searchField.getFilter());
|
||||
ArrayList<Integer> filtered = searchHandler.getSearchResult(filter);
|
||||
List<Integer> filtered = searchHandler.getSearchResult(filter);
|
||||
|
||||
if (filtered == null) {
|
||||
stop();
|
||||
@@ -376,7 +409,6 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void initGui() {
|
||||
xSize = 176;
|
||||
ySize = Math.min(Math.max(height - 68, 166), 370);
|
||||
@@ -384,7 +416,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
super.initGui();
|
||||
} else {
|
||||
this.guiLeft = (this.width - this.xSize) / 2;
|
||||
this.ySize = this.getHeightAsWidget();
|
||||
this.ySize = this.getWidgetSize().height;
|
||||
this.mc = NEIClientUtils.mc();
|
||||
this.fontRendererObj = mc.fontRenderer;
|
||||
ScaledResolution scaledresolution = new ScaledResolution(
|
||||
@@ -400,7 +432,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
if (handler == null) {
|
||||
setRecipePage(recipetype);
|
||||
} else {
|
||||
initOverlayButtons();
|
||||
updateOverlayButtons();
|
||||
}
|
||||
|
||||
checkYShift();
|
||||
@@ -408,15 +440,40 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
final int rightButtonX = guiLeft + xSize - borderPadding - buttonWidth;
|
||||
final int leftButtonX = guiLeft + borderPadding;
|
||||
|
||||
nexttype = new GuiNEIButton(0, leftButtonX, guiTop + 3, buttonWidth, buttonHeight, "<");
|
||||
prevtype = new GuiNEIButton(1, rightButtonX, guiTop + 3, buttonWidth, buttonHeight, ">");
|
||||
nexttype = new GuiNEIButton(0, leftButtonX, guiTop + 3, buttonWidth, buttonHeight, "<") {
|
||||
|
||||
nextpage = new GuiNEIButton(2, leftButtonX, guiTop + 17, buttonWidth, buttonHeight, "<");
|
||||
prevpage = new GuiNEIButton(3, rightButtonX, guiTop + 17, buttonWidth, buttonHeight, ">");
|
||||
@Override
|
||||
public void mouseReleased(int mouseX, int mouseY) {
|
||||
prevType();
|
||||
}
|
||||
};
|
||||
prevtype = new GuiNEIButton(1, rightButtonX, guiTop + 3, buttonWidth, buttonHeight, ">") {
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int mouseX, int mouseY) {
|
||||
nextType();
|
||||
}
|
||||
};
|
||||
|
||||
nextpage = new GuiNEIButton(2, leftButtonX, guiTop + 17, buttonWidth, buttonHeight, "<") {
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int mouseX, int mouseY) {
|
||||
prevPage();
|
||||
}
|
||||
};
|
||||
prevpage = new GuiNEIButton(3, rightButtonX, guiTop + 17, buttonWidth, buttonHeight, ">") {
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int mouseX, int mouseY) {
|
||||
nextPage();
|
||||
}
|
||||
};
|
||||
|
||||
toggleSearch.icon = new DrawableBuilder("nei:textures/nei_sprites.png", 0, 76, 10, 10).build();
|
||||
|
||||
buttonList.addAll(Arrays.asList(nexttype, prevtype, nextpage, prevpage));
|
||||
this.buttonList.addAll(Arrays.asList(nexttype, prevtype, nextpage, prevpage));
|
||||
this.overlayButtons = new GuiOverlayButton[0];
|
||||
|
||||
if (currenthandlers.size() == 1) {
|
||||
nexttype.visible = false;
|
||||
@@ -427,35 +484,71 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
refreshPage();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void initOverlayButtons() {
|
||||
if (overlayButtons != null) {
|
||||
buttonList.removeIf(Arrays.asList(overlayButtons)::contains);
|
||||
private void updateOverlayButtons() {
|
||||
final List<Integer> indices = getRecipeIndices();
|
||||
|
||||
if (isDirtyOverlayButtons(indices)) {
|
||||
this.buttonList.removeIf(Arrays.asList(this.overlayButtons)::contains);
|
||||
|
||||
final int xOffset = (limitToOneRecipe ? 0 : guiLeft) + xSize - borderPadding;
|
||||
final int yOffset = (limitToOneRecipe ? -buttonHeight : guiTop - 18) + getRecipePosition(0).y;
|
||||
final int height = handlerInfo.getHeight() - yShift;
|
||||
final UpdateOverlayButtonsEvent.Pre preEvent = new UpdateOverlayButtonsEvent.Pre(
|
||||
this,
|
||||
xOffset,
|
||||
yOffset,
|
||||
height,
|
||||
handlerInfo);
|
||||
List<GuiOverlayButton> buttons = new ArrayList<>();
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(preEvent)) {
|
||||
buttons = preEvent.buttonList;
|
||||
} else {
|
||||
|
||||
for (int refIndex = 0; refIndex < indices.size(); refIndex++) {
|
||||
final int recipeIndex = indices.get(refIndex);
|
||||
|
||||
if (handler.original.getResultStack(recipeIndex) == null
|
||||
&& handler.original.getOtherStacks(recipeIndex).isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
buttons.add(
|
||||
new GuiOverlayButton(
|
||||
firstGui,
|
||||
handler.original,
|
||||
recipeIndex,
|
||||
xOffset - buttonWidth,
|
||||
yOffset + height * (refIndex + 1),
|
||||
buttonWidth,
|
||||
buttonHeight));
|
||||
}
|
||||
|
||||
if (this.equals(this.mc.currentScreen)) {
|
||||
UpdateOverlayButtonsEvent.Post postEvent = new UpdateOverlayButtonsEvent.Post(this, buttons);
|
||||
MinecraftForge.EVENT_BUS.post(postEvent);
|
||||
buttons = postEvent.buttonList;
|
||||
}
|
||||
}
|
||||
|
||||
this.overlayButtons = buttons.toArray(new GuiOverlayButton[buttons.size()]);
|
||||
this.buttonList.addAll(buttons);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isDirtyOverlayButtons(List<Integer> indices) {
|
||||
|
||||
if (this.overlayButtons.length == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final int recipesPerPage = getRecipesPerPage();
|
||||
overlayButtons = new GuiButton[recipesPerPage];
|
||||
final int xOffset = limitToOneRecipe ? ((xSize / 2) - 2) : (width / 2);
|
||||
final int yOffset = limitToOneRecipe ? 0 : guiTop - 18;
|
||||
final String overlayKeyName = NEIClientConfig
|
||||
.getKeyName(NEIClientConfig.getKeyBinding("gui.overlay_use"), true);
|
||||
for (int i = 0; i < recipesPerPage; i++) {
|
||||
overlayButtons[i] = new GuiNEIButton(
|
||||
OVERLAY_BUTTON_ID_START + i,
|
||||
xOffset + 65,
|
||||
yOffset + getRecipePosition(i).y + handlerInfo.getHeight(),
|
||||
buttonWidth,
|
||||
buttonHeight,
|
||||
"?");
|
||||
if (overlayKeyName != null && limitToOneRecipe) {
|
||||
overlayButtons[i].visible = true;
|
||||
overlayButtons[i].displayString = overlayKeyName;
|
||||
overlayButtons[i].width = fontRenderer.getStringWidth(overlayKeyName) + 6;
|
||||
overlayButtons[i].xPosition = xOffset + 85 - overlayButtons[i].width;
|
||||
for (GuiOverlayButton button : this.overlayButtons) {
|
||||
if (button.handler != handler.original || !indices.contains(button.recipeIndex)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Collections.addAll(buttonList, overlayButtons);
|
||||
itemPresenceCacheRecipe = -1;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static IRecipeFilter getRecipeListFilter() {
|
||||
@@ -501,11 +594,10 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
changePage(0);
|
||||
recipeTabs.calcPageNumber();
|
||||
checkYShift();
|
||||
initOverlayButtons();
|
||||
}
|
||||
|
||||
public List<GuiButton> getOverlayButtons() {
|
||||
return Collections.unmodifiableList(Arrays.asList(overlayButtons));
|
||||
return Collections.unmodifiableList(Arrays.asList(this.overlayButtons));
|
||||
}
|
||||
|
||||
public int openTargetRecipe(BookmarkRecipeId recipeId) {
|
||||
@@ -649,6 +741,14 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Point mouse = GuiDraw.getMousePosition();
|
||||
|
||||
for (GuiOverlayButton button : this.overlayButtons) {
|
||||
if (button.contains(mouse.x, mouse.y)) {
|
||||
button.lastKeyTyped(this, c, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i == mc.gameSettings.keyBindInventory.getKeyCode()) {
|
||||
@@ -734,44 +834,9 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guibutton) {
|
||||
super.actionPerformed(guibutton);
|
||||
switch (guibutton.id) {
|
||||
case 0:
|
||||
prevType();
|
||||
return;
|
||||
case 1:
|
||||
nextType();
|
||||
return;
|
||||
case 2:
|
||||
prevPage();
|
||||
return;
|
||||
case 3:
|
||||
nextPage();
|
||||
return;
|
||||
}
|
||||
|
||||
if (overlayButtons != null && guibutton.id >= OVERLAY_BUTTON_ID_START
|
||||
&& guibutton.id < OVERLAY_BUTTON_ID_START + overlayButtons.length) {
|
||||
final List<Integer> indices = getRecipeIndices();
|
||||
final int refIndex = guibutton.id - OVERLAY_BUTTON_ID_START;
|
||||
|
||||
if (refIndex >= 0 && refIndex < indices.size()) {
|
||||
mc.displayGuiScreen(firstGui);
|
||||
overlayRecipe(indices.get(refIndex), NEIClientUtils.shiftKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
super.updateScreen();
|
||||
updateAsTooltip();
|
||||
}
|
||||
|
||||
/** updateScreen() that's safe to call when this isn't the currently open GUI */
|
||||
public void updateAsTooltip() {
|
||||
handler.original.onUpdate();
|
||||
refreshPage();
|
||||
}
|
||||
@@ -783,6 +848,12 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
for (int recipeIndex : getRecipeIndices()) {
|
||||
currenttip = handler.original.handleTooltip(this, currenttip, recipeIndex);
|
||||
}
|
||||
|
||||
for (GuiOverlayButton button : this.overlayButtons) {
|
||||
if (button.contains(mousex, mousey)) {
|
||||
currenttip = button.handleTooltip(this, currenttip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
recipeTabs.handleTooltip(mousex, mousey, currenttip);
|
||||
@@ -802,18 +873,66 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleItemTooltip(GuiContainer gui, ItemStack stack, int mousex, int mousey,
|
||||
public List<String> handleItemTooltip(GuiContainer gui, ItemStack itemstack, int mousex, int mousey,
|
||||
List<String> currenttip) {
|
||||
|
||||
List<Integer> indices = getRecipeIndices();
|
||||
|
||||
try (CompatibilityHacks compatibilityHacks = new CompatibilityHacks()) {
|
||||
for (int recipeIndex : getRecipeIndices()) {
|
||||
currenttip = handler.original.handleItemTooltip(this, stack, currenttip, recipeIndex);
|
||||
for (int recipeIndex : indices) {
|
||||
currenttip = handler.original.handleItemTooltip(this, itemstack, currenttip, recipeIndex);
|
||||
}
|
||||
}
|
||||
|
||||
if (NEIClientConfig.showCycledIngredientsTooltip()) {
|
||||
PositionedStack focused = null;
|
||||
|
||||
for (int refIndex = 0; refIndex < indices.size(); refIndex++) {
|
||||
final int recipeIndex = indices.get(refIndex);
|
||||
|
||||
if (itemstack != null && focused == null) {
|
||||
final List<PositionedStack> stacks = handler.original.getIngredientStacks(recipeIndex);
|
||||
|
||||
for (PositionedStack pStack : stacks) {
|
||||
if (isMouseOver(pStack, refIndex)) {
|
||||
focused = pStack;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (focused == null || focused.items.length <= 1) {
|
||||
this.permutationTooltipLineHandler = null;
|
||||
} else if (this.permutationTooltipLineHandler == null
|
||||
|| this.permutationTooltipLineHandler.pStack != focused) {
|
||||
this.permutationTooltipLineHandler = PermutationTooltipLineHandler.getInstance(focused);
|
||||
}
|
||||
} else if (this.permutationTooltipLineHandler != null) {
|
||||
this.permutationTooltipLineHandler = null;
|
||||
}
|
||||
|
||||
if (this.permutationTooltipLineHandler != null) {
|
||||
currenttip.add(GuiDraw.TOOLTIP_HANDLER + GuiDraw.getTipLineId(this.permutationTooltipLineHandler));
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> handleHotkeys(GuiContainer gui, int mousex, int mousey, Map<String, String> hotkeys) {
|
||||
|
||||
try (CompatibilityHacks compatibilityHacks = new CompatibilityHacks()) {
|
||||
for (GuiOverlayButton button : this.overlayButtons) {
|
||||
if (button.contains(mousex, mousey)) {
|
||||
hotkeys = button.handleHotkeys(gui, mousex, mousey, hotkeys);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return hotkeys;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleItemDisplayName(GuiContainer gui, ItemStack itemstack, List<String> currenttip) {
|
||||
return currenttip;
|
||||
@@ -835,19 +954,20 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
setRecipePage(--recipetype);
|
||||
}
|
||||
|
||||
protected void overlayRecipe(int recipeIndex, final boolean shift) {
|
||||
protected void overlayRecipe(int recipeIndex, boolean shift) {
|
||||
|
||||
if (handler == null || !handler.original.hasOverlay(firstGui, firstGui.inventorySlots, recipeIndex)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean moveItems = shift || !NEIClientConfig.requireShiftForOverlayRecipe();
|
||||
final IRecipeOverlayRenderer renderer = handler.original.getOverlayRenderer(firstGui, recipeIndex);
|
||||
final boolean requireShiftForOverlayRecipe = NEIClientConfig.requireShiftForOverlayRecipe();
|
||||
final IOverlayHandler overlayHandler = handler.original.getOverlayHandler(firstGui, recipeIndex);
|
||||
final IRecipeOverlayRenderer renderer = handler.original.getOverlayRenderer(firstGui, recipeIndex);
|
||||
|
||||
if (renderer == null || moveItems) {
|
||||
if (renderer == null || !requireShiftForOverlayRecipe || shift) {
|
||||
if (overlayHandler != null) {
|
||||
overlayHandler.overlayRecipe(firstGui, handler.original, recipeIndex, moveItems);
|
||||
overlayHandler
|
||||
.overlayRecipe(firstGui, handler.original, recipeIndex, !requireShiftForOverlayRecipe || shift);
|
||||
}
|
||||
} else {
|
||||
LayoutManager.overlayRenderer = renderer;
|
||||
@@ -865,11 +985,9 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
} else {
|
||||
this.page = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void refreshPage() {
|
||||
RecipeCatalysts.updatePosition(ySize - BG_TOP_HEIGHT - (GuiRecipeCatalyst.fullBorder * 2));
|
||||
changePage(0);
|
||||
refreshSlots();
|
||||
final int recipesPerPage = getRecipesPerPage();
|
||||
@@ -883,6 +1001,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
checkYShift();
|
||||
|
||||
if (!limitToOneRecipe) {
|
||||
RecipeCatalysts.updatePosition(ySize - BG_TOP_HEIGHT - (GuiRecipeCatalyst.fullBorder * 2));
|
||||
toggleSearch.w = toggleSearch.h = 12;
|
||||
toggleSearch.x = borderPadding + buttonWidth;
|
||||
toggleSearch.y = 17;
|
||||
@@ -895,22 +1014,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
|
||||
nextpage.enabled = prevpage.enabled = multiplepages;
|
||||
|
||||
if (firstGui == null) {
|
||||
for (GuiButton overlay : overlayButtons) {
|
||||
overlay.visible = false;
|
||||
}
|
||||
} else {
|
||||
final List<Integer> indices = getRecipeIndices();
|
||||
for (int i = 0; i < overlayButtons.length; i++) {
|
||||
if (i >= indices.size()) {
|
||||
overlayButtons[i].visible = false;
|
||||
} else {
|
||||
overlayButtons[i].visible = handler.original
|
||||
.hasOverlay(firstGui, firstGui.inventorySlots, indices.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateOverlayButtons();
|
||||
recipeTabs.refreshPage();
|
||||
}
|
||||
|
||||
@@ -952,39 +1056,11 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
}
|
||||
}
|
||||
|
||||
private int itemPresenceCacheRecipe = -1;
|
||||
private ArrayList<Boolean> itemPresenceCacheSlots;
|
||||
|
||||
private void updateItemPresenceCache(int recipeIndex) {
|
||||
if (itemPresenceCacheSlots == null) {
|
||||
itemPresenceCacheSlots = new ArrayList<>();
|
||||
}
|
||||
itemPresenceCacheRecipe = recipeIndex;
|
||||
itemPresenceCacheSlots.clear();
|
||||
List<PositionedStack> ingredients = handler.original.getIngredientStacks(recipeIndex);
|
||||
ArrayList<ItemStack> invStacks = ((List<Slot>) firstGui.inventorySlots.inventorySlots).stream()
|
||||
.filter(
|
||||
s -> s != null && s.getStack() != null
|
||||
&& s.getStack().stackSize > 0
|
||||
&& s.isItemValid(s.getStack())
|
||||
&& s.canTakeStack(mc.thePlayer))
|
||||
.map(s -> s.getStack().copy()).collect(Collectors.toCollection(ArrayList::new));
|
||||
for (PositionedStack stack : ingredients) {
|
||||
Optional<ItemStack> used = invStacks.stream().filter(is -> is.stackSize > 0 && stack.contains(is))
|
||||
.findFirst();
|
||||
itemPresenceCacheSlots.add(used.isPresent());
|
||||
if (used.isPresent()) {
|
||||
ItemStack is = used.get();
|
||||
is.stackSize -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
GuiContainerManager.enable2DRender();
|
||||
final int recipesPerPage = getRecipesPerPage();
|
||||
final int ySkip = limitToOneRecipe ? 25 : 0;
|
||||
final int ySkip = limitToOneRecipe ? BG_TOP_HEIGHT + 1 : 32;
|
||||
|
||||
if (!limitToOneRecipe) {
|
||||
String s = handler.original.getRecipeName().trim();
|
||||
@@ -1012,52 +1088,62 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
|
||||
}
|
||||
|
||||
final int presenceOverlay = NEIClientConfig.itemPresenceOverlay();
|
||||
final boolean highlightPresentItem = NEIClientConfig.isSlotHighlightPresent();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(5, 32 - ySkip + yShift, 0);
|
||||
try (CompatibilityHacks compatibilityHacks = new CompatibilityHacks()) {
|
||||
List<Integer> indices = getRecipeIndices();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(5, ySkip + yShift, 0);
|
||||
|
||||
for (int refIndex = 0; refIndex < indices.size(); refIndex++) {
|
||||
int recipeIndex = indices.get(refIndex);
|
||||
|
||||
handler.original.drawForeground(recipeIndex);
|
||||
|
||||
if (presenceOverlay > 0 && firstGui != null
|
||||
&& firstGui.inventorySlots != null
|
||||
&& (isMouseOverOverlayButton(refIndex) || limitToOneRecipe)) {
|
||||
if (limitToOneRecipe) {
|
||||
GuiOverlayButton overlayButton = Arrays.asList(this.overlayButtons).stream()
|
||||
.filter(b -> b.recipeIndex == recipeIndex).findAny().orElse(null);
|
||||
|
||||
List<PositionedStack> ingredients = handler.original.getIngredientStacks(recipeIndex);
|
||||
if (overlayButton != null && overlayButton.enabled) {
|
||||
final String overlayKeyName = NEIClientConfig.getKeyName("gui.overlay_use");
|
||||
|
||||
if (itemPresenceCacheRecipe != recipeIndex || itemPresenceCacheSlots == null
|
||||
|| itemPresenceCacheSlots.size() != ingredients.size()) {
|
||||
updateItemPresenceCache(recipeIndex);
|
||||
}
|
||||
|
||||
for (int j = 0; j < ingredients.size(); j++) {
|
||||
PositionedStack stack = ingredients.get(j);
|
||||
boolean isPresent = itemPresenceCacheSlots.get(j);
|
||||
|
||||
if (highlightPresentItem || !isPresent) {
|
||||
LayoutManager
|
||||
.drawItemPresenceOverlay(stack.relx, stack.rely, isPresent, presenceOverlay == 2);
|
||||
if (overlayKeyName != null) {
|
||||
fontRendererObj.drawStringWithShadow(
|
||||
EnumChatFormatting.ITALIC + overlayKeyName,
|
||||
xSize - borderPadding - fontRendererObj.getStringWidth(overlayKeyName) - 10,
|
||||
handlerInfo.getHeight() - fontRendererObj.FONT_HEIGHT,
|
||||
0xffffff);
|
||||
}
|
||||
|
||||
overlayButton.drawItemPresenceOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glTranslatef(0, handlerInfo.getHeight(), 0);
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(5, ySkip + yShift, 0);
|
||||
|
||||
if (!limitToOneRecipe && NEIClientConfig.itemPresenceOverlay() > 0) {
|
||||
for (GuiOverlayButton button : this.overlayButtons) {
|
||||
if (button.contains(mouseX, mouseY)) {
|
||||
GL11.glTranslatef(0, handlerInfo.getHeight() * indices.indexOf(button.recipeIndex), 0);
|
||||
button.drawItemPresenceOverlay();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
|
||||
final int ySkip = limitToOneRecipe ? 25 : 0;
|
||||
final int ySkip = limitToOneRecipe ? BG_TOP_HEIGHT + 1 : 32;
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
|
||||
drawBackgroundTiled(guiLeft, guiTop);
|
||||
@@ -1086,7 +1172,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(guiLeft + 5, guiTop - ySkip + 32 + yShift, 0);
|
||||
GL11.glTranslatef(guiLeft + 5, guiTop + ySkip + yShift, 0);
|
||||
try (CompatibilityHacks compatibilityHacks = new CompatibilityHacks()) {
|
||||
|
||||
for (int recipeIndex : getRecipeIndices()) {
|
||||
@@ -1099,13 +1185,13 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
}
|
||||
|
||||
private void drawBackgroundTiled(int j, int k) {
|
||||
final int handlerHeight = getWidgetSize().height;
|
||||
|
||||
// Draw the top
|
||||
final int ySkip = limitToOneRecipe ? 25 : 0;
|
||||
final int handlerHeight = limitToOneRecipe ? getHeightAsWidget() : ySize;
|
||||
bgTop.draw(j, k + BG_TOP_Y);
|
||||
|
||||
// Maybe Tile the middle
|
||||
final int tiledHeight = handlerHeight - ySkip - BG_TOP_HEIGHT - BG_BOTTOM_HEIGHT;
|
||||
final int tiledHeight = handlerHeight - BG_TOP_HEIGHT - BG_BOTTOM_HEIGHT;
|
||||
|
||||
if (tiledHeight > 0) {
|
||||
final int yTileCount = tiledHeight / BG_MIDDLE_HEIGHT;
|
||||
@@ -1122,11 +1208,18 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
}
|
||||
|
||||
// Draw the bottom
|
||||
bgBottom.draw(j, k + handlerHeight - ySkip - BG_BOTTOM_HEIGHT);
|
||||
bgBottom.draw(j, k + handlerHeight - BG_BOTTOM_HEIGHT);
|
||||
}
|
||||
|
||||
public int getHeightAsWidget() {
|
||||
return (handlerInfo == null) ? ySize : (handlerInfo.getHeight() + 56);
|
||||
public Dimension getWidgetSize() {
|
||||
|
||||
if (handlerInfo == null) {
|
||||
return new Dimension(xSize, ySize);
|
||||
}
|
||||
|
||||
final int handlerHeight = limitToOneRecipe ? handlerInfo.getHeight() + yShift + BG_TOP_HEIGHT + BG_BOTTOM_HEIGHT
|
||||
: ySize;
|
||||
return new Dimension(xSize, handlerHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1148,19 +1241,6 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
return stackSlot == mouseoverSlot;
|
||||
}
|
||||
|
||||
private boolean isMouseOverOverlayButton(int buttonId) {
|
||||
if (buttonId >= 0 && buttonId < overlayButtons.length) {
|
||||
GuiButton button = overlayButtons[buttonId];
|
||||
Point mousePos = GuiDraw.getMousePosition();
|
||||
return button.visible && mousePos.x >= button.xPosition
|
||||
&& mousePos.y >= button.yPosition
|
||||
&& mousePos.x < button.xPosition + button.width
|
||||
&& mousePos.y < button.yPosition + button.height;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private int getRecipesPerPage() {
|
||||
return limitToOneRecipe ? 1 : getRecipesPerPage(handlerInfo);
|
||||
}
|
||||
@@ -1223,7 +1303,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
return area.intersects(x, y, w, h);
|
||||
}
|
||||
|
||||
protected static BookmarkRecipeId getCurrentRecipe(GuiScreen gui) {
|
||||
protected static BookmarkRecipeId getCurrentRecipeId(GuiScreen gui) {
|
||||
|
||||
if (gui instanceof GuiRecipe && ((GuiRecipe<?>) gui).handler.numRecipes() > 0) {
|
||||
final GuiRecipe<?> gRecipe = (GuiRecipe<?>) gui;
|
||||
|
||||
@@ -213,10 +213,9 @@ public abstract class GuiRecipeTab extends Widget {
|
||||
File handlerFile = NEIClientConfig.handlerFile;
|
||||
if (!handlerFile.exists()) {
|
||||
NEIClientConfig.logger.info("Config file doesn't exist, creating");
|
||||
try {
|
||||
try (FileOutputStream fileOutputStream = new FileOutputStream(handlerFile.getAbsoluteFile())) {
|
||||
assert handlerUrl != null;
|
||||
ReadableByteChannel readableByteChannel = Channels.newChannel(handlerUrl.openStream());
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(handlerFile.getAbsoluteFile());
|
||||
FileChannel fileChannel = fileOutputStream.getChannel();
|
||||
fileChannel.transferFrom(readableByteChannel, 0, Long.MAX_VALUE);
|
||||
} catch (IOException e) {
|
||||
@@ -233,7 +232,7 @@ public abstract class GuiRecipeTab extends Widget {
|
||||
}
|
||||
}
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()))) {
|
||||
CSVParser csvParser = CSVFormat.EXCEL.withFirstRecordAsHeader().parse(reader);
|
||||
CSVParser csvParser = CSVFormat.EXCEL.builder().setHeader().setSkipHeaderRecord(true).build().parse(reader);
|
||||
for (CSVRecord record : csvParser) {
|
||||
final String handler = record.get("handler");
|
||||
final String modName = record.get("modName");
|
||||
|
||||
@@ -2,6 +2,8 @@ package codechicken.nei.recipe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -14,6 +16,7 @@ public class GuiUsageRecipe extends GuiRecipe<IUsageHandler> {
|
||||
|
||||
public static ArrayList<IUsageHandler> usagehandlers = new ArrayList<>();
|
||||
public static ArrayList<IUsageHandler> serialUsageHandlers = new ArrayList<>();
|
||||
private static Set<String> existingHandlers = new HashSet<>();
|
||||
|
||||
public static boolean openRecipeGui(String inputId, Object... ingredients) {
|
||||
|
||||
@@ -27,7 +30,7 @@ public class GuiUsageRecipe extends GuiRecipe<IUsageHandler> {
|
||||
|
||||
if (!handlers.isEmpty()) {
|
||||
final Minecraft mc = NEIClientUtils.mc();
|
||||
final BookmarkRecipeId recipeId = getCurrentRecipe(mc.currentScreen);
|
||||
final BookmarkRecipeId recipeId = getCurrentRecipeId(mc.currentScreen);
|
||||
final GuiUsageRecipe gui = new GuiUsageRecipe(handlers);
|
||||
|
||||
mc.displayGuiScreen(gui);
|
||||
@@ -65,12 +68,25 @@ public class GuiUsageRecipe extends GuiRecipe<IUsageHandler> {
|
||||
|
||||
public static void registerUsageHandler(IUsageHandler handler) {
|
||||
final String handlerId = handler.getHandlerId();
|
||||
if (usagehandlers.stream().anyMatch(h -> h.getHandlerId().equals(handlerId))
|
||||
|| serialUsageHandlers.stream().anyMatch(h -> h.getHandlerId().equals(handlerId)))
|
||||
return;
|
||||
|
||||
if (NEIClientConfig.serialHandlers.contains(handlerId)) serialUsageHandlers.add(handler);
|
||||
else usagehandlers.add(handler);
|
||||
if (existingHandlers.contains(handlerId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (existingHandlers) {
|
||||
existingHandlers.add(handlerId);
|
||||
}
|
||||
|
||||
if (NEIClientConfig.serialHandlers.contains(handlerId)) {
|
||||
synchronized (serialUsageHandlers) {
|
||||
serialUsageHandlers.add(handler);
|
||||
}
|
||||
} else {
|
||||
synchronized (usagehandlers) {
|
||||
usagehandlers.add(handler);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static IUsageHandler getUsageOrCatalystHandler(IUsageHandler handler, String inputId,
|
||||
|
||||
@@ -70,12 +70,12 @@ class ItemsHistoryHandler implements ICraftingHandler, IUsageHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) {
|
||||
public boolean keyTyped(GuiRecipe<?> gui, char keyChar, int keyCode, int recipe) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(GuiRecipe gui, int button, int recipe) {
|
||||
public boolean mouseClicked(GuiRecipe<?> gui, int button, int recipe) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -145,10 +145,9 @@ public class RecipeCatalysts {
|
||||
File catalystFile = NEIClientConfig.catalystFile;
|
||||
if (!catalystFile.exists()) {
|
||||
NEIClientConfig.logger.info("Config file doesn't exist, creating");
|
||||
try {
|
||||
try (FileOutputStream fileOutputStream = new FileOutputStream(catalystFile.getAbsoluteFile())) {
|
||||
assert handlerUrl != null;
|
||||
ReadableByteChannel readableByteChannel = Channels.newChannel(handlerUrl.openStream());
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(catalystFile.getAbsoluteFile());
|
||||
FileChannel fileChannel = fileOutputStream.getChannel();
|
||||
fileChannel.transferFrom(readableByteChannel, 0, Long.MAX_VALUE);
|
||||
} catch (IOException e) {
|
||||
@@ -165,7 +164,7 @@ public class RecipeCatalysts {
|
||||
}
|
||||
}
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()))) {
|
||||
CSVParser csvParser = CSVFormat.EXCEL.withFirstRecordAsHeader().parse(reader);
|
||||
CSVParser csvParser = CSVFormat.EXCEL.builder().setHeader().setSkipHeaderRecord(true).build().parse(reader);
|
||||
for (CSVRecord record : csvParser) {
|
||||
final String handler = record.get("handler");
|
||||
final String modId = record.get("modId");
|
||||
@@ -194,7 +193,7 @@ public class RecipeCatalysts {
|
||||
try {
|
||||
// gently handling copy&paste from handlers.csv
|
||||
Class<?> clazz = Class.forName(handler);
|
||||
Object object = clazz.newInstance();
|
||||
Object object = clazz.getConstructor().newInstance();
|
||||
if (object instanceof IRecipeHandler) {
|
||||
if (forceClassName) {
|
||||
forceClassNameList.add(handler);
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package codechicken.nei.recipe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.IntPredicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.Stream;
|
||||
@@ -14,9 +15,9 @@ class SearchRecipeHandler<H extends IRecipeHandler> {
|
||||
|
||||
public H original;
|
||||
|
||||
private ArrayList<Integer> filteredRecipes;
|
||||
private List<Integer> filteredRecipes;
|
||||
|
||||
private ArrayList<Integer> searchRecipes;
|
||||
private List<Integer> searchRecipes;
|
||||
|
||||
public SearchRecipeHandler(H handler) {
|
||||
this.original = handler;
|
||||
@@ -52,7 +53,7 @@ class SearchRecipeHandler<H extends IRecipeHandler> {
|
||||
return handler instanceof TemplateRecipeHandler;
|
||||
}
|
||||
|
||||
public static int findFirst(IRecipeHandler handler, Predicate<Integer> predicate) {
|
||||
public static int findFirst(IRecipeHandler handler, IntPredicate predicate) {
|
||||
final IRecipeFilter filter = searchingAvailable(handler) ? GuiRecipe.getRecipeListFilter() : null;
|
||||
int refIndex = -1;
|
||||
|
||||
@@ -69,14 +70,14 @@ class SearchRecipeHandler<H extends IRecipeHandler> {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public ArrayList<Integer> getSearchResult(IRecipeFilter filter) {
|
||||
public List<Integer> getSearchResult(IRecipeFilter filter) {
|
||||
|
||||
if (filteredRecipes.isEmpty() || !this.searchingAvailable()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ArrayList<Integer> filtered = null;
|
||||
final ArrayList<Integer> recipes = IntStream.range(0, filteredRecipes.size()).boxed()
|
||||
List<Integer> filtered = null;
|
||||
final List<Integer> recipes = IntStream.range(0, filteredRecipes.size()).boxed()
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
try {
|
||||
@@ -95,7 +96,7 @@ class SearchRecipeHandler<H extends IRecipeHandler> {
|
||||
return filtered;
|
||||
}
|
||||
|
||||
public void setSearchIndices(ArrayList<Integer> searchRecipes) {
|
||||
public void setSearchIndices(List<Integer> searchRecipes) {
|
||||
this.searchRecipes = searchRecipes;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
package codechicken.nei.recipe;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -20,10 +13,8 @@ import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import codechicken.nei.ClientHandler;
|
||||
import codechicken.nei.ItemStackMap;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.api.IStackStringifyHandler;
|
||||
import codechicken.nei.recipe.stackinfo.DefaultStackStringifyHandler;
|
||||
import codechicken.nei.recipe.stackinfo.GTFluidStackStringifyHandler;
|
||||
@@ -33,7 +24,9 @@ public class StackInfo {
|
||||
public static final ArrayList<IStackStringifyHandler> stackStringifyHandlers = new ArrayList<>();
|
||||
private static final HashMap<String, HashMap<String, String[]>> guidfilters = new HashMap<>();
|
||||
private static final ItemStackMap<String> guidcache = new ItemStackMap<>();
|
||||
private static final LinkedHashMap<ItemStack, FluidStack> fluidcache = new LinkedHashMap<ItemStack, FluidStack>() {
|
||||
private static final LinkedHashMap<ItemStack, FluidStack> fluidcache = new LinkedHashMap<>() {
|
||||
|
||||
private static final long serialVersionUID = 1042213947848622164L;
|
||||
|
||||
@Override
|
||||
protected boolean removeEldestEntry(Map.Entry<ItemStack, FluidStack> eldest) {
|
||||
@@ -187,37 +180,9 @@ public class StackInfo {
|
||||
}
|
||||
|
||||
public static void loadGuidFilters() {
|
||||
|
||||
guidfilters.clear();
|
||||
|
||||
final File guidFlitersFile = new File(NEIClientConfig.configDir, "guidfilters.cfg");
|
||||
List<String> itemStrings = new ArrayList<>();
|
||||
|
||||
if (guidFlitersFile.exists()) {
|
||||
|
||||
try (FileReader reader = new FileReader(guidFlitersFile)) {
|
||||
NEIClientConfig.logger.info("Loading guid filters from file {}", guidFlitersFile);
|
||||
itemStrings = IOUtils.readLines(reader);
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Failed to load bookmarks from file {}", guidFlitersFile, e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
} else {
|
||||
final URL filterUrl = StackInfo.class.getResource("/assets/nei/guidfilters.cfg");
|
||||
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(filterUrl.openStream()))) {
|
||||
itemStrings = IOUtils.readLines(reader);
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.info("Error parsing guid filters");
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
NEIClientConfig.logger.info("Error parsing guid filters");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
for (String guidStr : itemStrings) {
|
||||
ClientHandler.loadSettingsFile("guidfilters.cfg", lines -> lines.forEach(guidStr -> {
|
||||
final String[] parts = guidStr.split(",");
|
||||
final HashMap<String, String[]> rules = new HashMap<>();
|
||||
|
||||
@@ -226,7 +191,7 @@ public class StackInfo {
|
||||
}
|
||||
|
||||
guidfilters.put(parts[0], rules);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public static ItemStack getItemStackWithMinimumDamage(ItemStack[] stacks) {
|
||||
|
||||
@@ -8,13 +8,14 @@ import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -311,7 +312,7 @@ public abstract class TemplateRecipeHandler implements ICraftingHandler, IUsageH
|
||||
|
||||
public static class RecipeTransferRectHandler implements IContainerInputHandler, IContainerTooltipHandler {
|
||||
|
||||
private static final HashMap<Class<? extends GuiContainer>, HashSet<RecipeTransferRect>> guiMap = new HashMap<>();
|
||||
private static final Map<Class<? extends GuiContainer>, HashSet<RecipeTransferRect>> guiMap = new ConcurrentHashMap<>();
|
||||
|
||||
public static void registerRectsToGuis(List<Class<? extends GuiContainer>> classes,
|
||||
List<RecipeTransferRect> rects) {
|
||||
@@ -430,9 +431,9 @@ public abstract class TemplateRecipeHandler implements ICraftingHandler, IUsageH
|
||||
RecipeTransferRectHandler.registerRectsToGuis(getRecipeTransferRectGuis(), transferRects);
|
||||
}
|
||||
|
||||
protected static ItemFilter getItemFilter() {
|
||||
public static ItemFilter getItemFilter() {
|
||||
return new AllMultiItemFilter(
|
||||
item -> !ItemInfo.hiddenItems.contains(item),
|
||||
item -> !ItemInfo.isHidden(item),
|
||||
PresetsList.getItemFilter(),
|
||||
GuiRecipe.searchField != null ? GuiRecipe.searchField.getFilter() : null);
|
||||
}
|
||||
@@ -594,7 +595,7 @@ public abstract class TemplateRecipeHandler implements ICraftingHandler, IUsageH
|
||||
// available
|
||||
// This will ideally have been pre-cached elsewhere and will be a NOOP
|
||||
findFuelsOnce();
|
||||
return getClass().newInstance();
|
||||
return getClass().getConstructor().newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -767,20 +768,31 @@ public abstract class TemplateRecipeHandler implements ICraftingHandler, IUsageH
|
||||
}
|
||||
|
||||
private void shiftPermutationToRender(PositionedStack pStack, ItemStack stack, int scroll, ItemFilter filter) {
|
||||
if (!pStack.containsWithNBT(stack)) return;
|
||||
|
||||
for (int index = 0; index < pStack.items.length; index++) {
|
||||
if (NEIServerUtils.areStacksSameTypeCraftingWithNBT(pStack.items[index], stack)) {
|
||||
ArrayList<Integer> filtered = getFilteredIngredientAlternatives(pStack, filter);
|
||||
final List<Integer> filtered = getFilteredIngredientAlternatives(pStack, filter);
|
||||
int index = 0;
|
||||
|
||||
if (filtered.isEmpty()) {
|
||||
pStack.setPermutationToRender((int) ((pStack.items.length + scroll + index) % pStack.items.length));
|
||||
} else {
|
||||
pStack.setPermutationToRender(
|
||||
filtered.get((int) ((filtered.size() + scroll + index) % filtered.size())));
|
||||
if (filtered.isEmpty()) {
|
||||
|
||||
for (int i = 0; i < pStack.items.length; i++) {
|
||||
if (NEIServerUtils.areStacksSameTypeCraftingWithNBT(pStack.items[i], stack)) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
pStack.setPermutationToRender((int) ((pStack.items.length - scroll + index) % pStack.items.length));
|
||||
} else {
|
||||
|
||||
for (int i = 0; i < filtered.size(); i++) {
|
||||
if (NEIServerUtils.areStacksSameTypeCraftingWithNBT(pStack.items[filtered.get(i)], stack)) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pStack.setPermutationToRender(filtered.get((int) ((filtered.size() - scroll + index) % filtered.size())));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,22 +11,27 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import codechicken.nei.api.IStackStringifyHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
|
||||
public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
|
||||
|
||||
protected static Class<?> GTDisplayFluid = null;
|
||||
protected static Class<?> itemFluidDisplay = null;
|
||||
protected static Method getFluidDisplayStack = null;
|
||||
protected static Method getFluidFromDisplayStack = null;
|
||||
public static boolean replaceAE2FCFluidDrop = false;
|
||||
|
||||
static {
|
||||
try {
|
||||
final Class<?> gtUtility = Class.forName("gregtech.api.util.GT_Utility");
|
||||
final ClassLoader loader = GTFluidStackStringifyHandler.class.getClassLoader();
|
||||
final Class<?> gtUtility = ReflectionHelper
|
||||
.getClass(loader, "gregtech.api.util.GTUtility", "gregtech.api.util.GT_Utility");
|
||||
|
||||
GTDisplayFluid = Class.forName("gregtech.common.items.GT_FluidDisplayItem");
|
||||
itemFluidDisplay = ReflectionHelper.getClass(
|
||||
loader,
|
||||
"gregtech.common.items.ItemFluidDisplay",
|
||||
"gregtech.common.items.GT_FluidDisplayItem");
|
||||
getFluidFromDisplayStack = gtUtility.getMethod("getFluidFromDisplayStack", ItemStack.class);
|
||||
getFluidDisplayStack = gtUtility.getMethod("getFluidDisplayStack", FluidStack.class, boolean.class);
|
||||
|
||||
} catch (Exception ignored) {
|
||||
/* Do nothing */
|
||||
}
|
||||
@@ -72,7 +77,7 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
|
||||
final Item item = stack.getItem();
|
||||
|
||||
try {
|
||||
if (getFluidFromDisplayStack != null && GTDisplayFluid != null && GTDisplayFluid.isInstance(item)) {
|
||||
if (getFluidFromDisplayStack != null && itemFluidDisplay != null && itemFluidDisplay.isInstance(item)) {
|
||||
final Object obj = getFluidFromDisplayStack.invoke(null, stack);
|
||||
|
||||
if (obj != null) {
|
||||
|
||||
@@ -1,50 +1,19 @@
|
||||
package codechicken.nei.search;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import codechicken.nei.ItemList;
|
||||
import codechicken.nei.ItemStackMap;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
|
||||
public class TooltipFilter implements ItemFilter {
|
||||
|
||||
// lookup optimisation
|
||||
private static final ConcurrentHashMap<ItemStackKey, String> itemSearchNames = new ConcurrentHashMap<>();
|
||||
|
||||
private static class ItemStackKey {
|
||||
|
||||
public final ItemStack stack;
|
||||
|
||||
public ItemStackKey(ItemStack stack) {
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (this.stack == null) return 1;
|
||||
int hashCode = 1;
|
||||
hashCode = 31 * hashCode + stack.stackSize;
|
||||
hashCode = 31 * hashCode + Item.getIdFromItem(stack.getItem());
|
||||
hashCode = 31 * hashCode + stack.getItemDamage();
|
||||
hashCode = 31 * hashCode + (!stack.hasTagCompound() ? 0 : stack.getTagCompound().hashCode());
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) return true;
|
||||
if (!(o instanceof ItemStackKey)) return false;
|
||||
return ItemStack.areItemStacksEqual(this.stack, ((ItemStackKey) o).stack);
|
||||
}
|
||||
}
|
||||
private static final ItemStackMap<String> itemSearchNames = new ItemStackMap<>();
|
||||
|
||||
private final Pattern pattern;
|
||||
|
||||
@@ -58,30 +27,39 @@ public class TooltipFilter implements ItemFilter {
|
||||
}
|
||||
|
||||
public static void populateSearchMap() {
|
||||
/* Create a snapshot of the current keys in the cache */
|
||||
HashSet<ItemStackKey> oldItems = new HashSet<>(itemSearchNames.keySet());
|
||||
|
||||
for (ItemStack stack : ItemList.items) {
|
||||
oldItems.remove(new ItemStackKey(stack));
|
||||
}
|
||||
|
||||
itemSearchNames.keySet().removeAll(oldItems);
|
||||
itemSearchNames.clear();
|
||||
new Thread(
|
||||
() -> ItemList.items.parallelStream().forEach(TooltipFilter::getSearchTooltip),
|
||||
"NEI populate Tooltip Filter").start();
|
||||
}
|
||||
|
||||
protected static String getSearchTooltip(ItemStack stack) {
|
||||
return itemSearchNames.computeIfAbsent(new ItemStackKey(stack), key -> getTooltip(key.stack));
|
||||
String tooltip = itemSearchNames.get(stack);
|
||||
|
||||
if (tooltip == null) {
|
||||
tooltip = getTooltip(stack.copy());
|
||||
|
||||
synchronized (itemSearchNames) {
|
||||
itemSearchNames.put(stack, tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
private static String getTooltip(ItemStack itemstack) {
|
||||
final List<String> list = GuiContainerManager.itemDisplayNameMultiline(itemstack, null, true);
|
||||
final StringJoiner sb = new StringJoiner("\n");
|
||||
final int size = list.size();
|
||||
|
||||
for (int i = 1; i < size; i++) {
|
||||
sb.add(list.get(i));
|
||||
}
|
||||
try {
|
||||
List<String> namelist = itemstack.getTooltip(NEIClientUtils.mc().thePlayer, false);
|
||||
|
||||
return EnumChatFormatting.getTextWithoutFormattingCodes(sb.toString());
|
||||
if (namelist.size() > 1) {
|
||||
return EnumChatFormatting
|
||||
.getTextWithoutFormattingCodes(String.join("\n", namelist.subList(1, namelist.size())));
|
||||
}
|
||||
|
||||
} catch (Throwable ignored) {}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
package codechicken.nei.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.IntPredicate;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import codechicken.nei.ItemList.AllMultiItemFilter;
|
||||
import codechicken.nei.ItemList.AnyMultiItemFilter;
|
||||
import codechicken.nei.ItemList.NegatedItemFilter;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
import cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
|
||||
/**
|
||||
* @formatter:off
|
||||
*
|
||||
* parts:
|
||||
* modname:itemid - identify
|
||||
* $orename - ore dictionary
|
||||
* tag.color=red - tag
|
||||
* 0 or 0-12 - damage
|
||||
*
|
||||
* modifiers:
|
||||
* ! - logical not. exclude items that match the following expression (!minecraft:portal)
|
||||
* r/.../ - standard java regex (r/^m\w{6}ft$/ = minecraft)
|
||||
* , - logical or in token (minecraft:potion 16384-16462,!16386)
|
||||
* | - logical or multi-item search (wrench|hammer)
|
||||
*
|
||||
*
|
||||
* example: minecraft:potion 16384-16462,!16386 | $oreiron | tag.color=red
|
||||
*/
|
||||
public class ItemStackFilterParser {
|
||||
|
||||
private ItemStackFilterParser() {}
|
||||
|
||||
public static ItemFilter parse(String filterText) {
|
||||
final List<ItemFilter> searchTokens = new ArrayList<>();
|
||||
filterText = filterText.trim();
|
||||
|
||||
if (!filterText.isEmpty()) {
|
||||
for (String part : filterText.split("\\s*\\|\\s*")) {
|
||||
AllMultiItemFilter filter = parsePart(part);
|
||||
if (!filter.filters.isEmpty()) {
|
||||
searchTokens.add(filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (searchTokens.isEmpty()) {
|
||||
return null;
|
||||
} else if (searchTokens.size() == 1) {
|
||||
return searchTokens.get(0);
|
||||
} else {
|
||||
return new AnyMultiItemFilter(searchTokens);
|
||||
}
|
||||
}
|
||||
|
||||
private static AllMultiItemFilter parsePart(String part) {
|
||||
final AllMultiItemFilter searchTokens = new AllMultiItemFilter();
|
||||
|
||||
for (String token : part.split("\\s+")) {
|
||||
ItemFilter ruleFilter = parseRules(token);
|
||||
|
||||
if (ruleFilter != null) {
|
||||
searchTokens.filters.add(ruleFilter);
|
||||
}
|
||||
}
|
||||
|
||||
return searchTokens;
|
||||
}
|
||||
|
||||
protected static ItemFilter parseRules(String token) {
|
||||
final AnyMultiItemFilter orFilter = new AnyMultiItemFilter();
|
||||
final AnyMultiItemFilter orNotFilter = new AnyMultiItemFilter();
|
||||
final AllMultiItemFilter ruleFilter = new AllMultiItemFilter();
|
||||
|
||||
for (String rule : token.split(",")) {
|
||||
boolean ignore = rule.startsWith("!");
|
||||
ItemFilter filter = null;
|
||||
|
||||
if (ignore) {
|
||||
rule = rule.substring(1);
|
||||
}
|
||||
|
||||
if (rule.startsWith("$")) {
|
||||
filter = getOreDictFilter(rule.substring(1));
|
||||
} else if (rule.startsWith("tag.")) {
|
||||
filter = getTagFilter(rule.substring(4));
|
||||
} else if (Pattern.matches("^\\d+(-\\d+)?$", rule)) {
|
||||
filter = getDamageFilter(rule);
|
||||
} else {
|
||||
filter = getStringIdentifierFilter(rule);
|
||||
}
|
||||
|
||||
if (filter == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ignore) {
|
||||
orNotFilter.filters.add(filter);
|
||||
} else {
|
||||
orFilter.filters.add(filter);
|
||||
}
|
||||
}
|
||||
|
||||
if (!orFilter.filters.isEmpty()) {
|
||||
ruleFilter.filters.add(orFilter);
|
||||
}
|
||||
|
||||
if (!orNotFilter.filters.isEmpty()) {
|
||||
ruleFilter.filters.add(new NegatedItemFilter(orNotFilter));
|
||||
}
|
||||
|
||||
return ruleFilter.filters.isEmpty() ? null : ruleFilter;
|
||||
}
|
||||
|
||||
protected static Predicate<String> getMatcher(String searchText) {
|
||||
|
||||
if (searchText.length() >= 3 && searchText.startsWith("r/") && searchText.endsWith("/")) {
|
||||
|
||||
try {
|
||||
Pattern pattern = Pattern.compile(
|
||||
searchText.substring(2, searchText.length() - 1),
|
||||
Pattern.MULTILINE | Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE);
|
||||
return value -> pattern.matcher(value).find();
|
||||
} catch (PatternSyntaxException ignored) {}
|
||||
|
||||
} else if (!searchText.isEmpty()) {
|
||||
final String lowerCase = searchText.toLowerCase();
|
||||
return value -> value.toLowerCase().contains(lowerCase);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected static ItemFilter getOreDictFilter(String rule) {
|
||||
final Predicate<String> matcher = getMatcher(rule);
|
||||
|
||||
if (matcher == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return stack -> IntStream.of(OreDictionary.getOreIDs(stack))
|
||||
.anyMatch(id -> matcher.test(OreDictionary.getOreName(id)));
|
||||
}
|
||||
|
||||
protected static ItemFilter getTagFilter(String rule) {
|
||||
final String[] parts = rule.split("=", 2);
|
||||
final String[] path = parts[0].split("\\.");
|
||||
final Predicate<String> value = getMatcher(parts[1]);
|
||||
|
||||
return stack -> {
|
||||
Object tag = stack.getTagCompound();
|
||||
|
||||
for (int i = 0; i < path.length && tag != null; i++) {
|
||||
if (tag instanceof NBTTagCompound) {
|
||||
tag = ((NBTTagCompound) tag).getTag(path[i]);
|
||||
} else if (tag instanceof NBTTagList) {
|
||||
tag = ((NBTTagList) tag).tagList.get(Integer.parseInt(path[i]));
|
||||
} else {
|
||||
tag = null;
|
||||
}
|
||||
}
|
||||
|
||||
return tag == null ? value == null : value != null && value.test(tag.toString());
|
||||
};
|
||||
}
|
||||
|
||||
protected static ItemFilter getDamageFilter(String rule) {
|
||||
final String[] range = rule.split("-");
|
||||
final IntPredicate matcher;
|
||||
|
||||
if (range.length == 1) {
|
||||
final int damage = Integer.parseInt(range[0]);
|
||||
matcher = dmg -> dmg == damage;
|
||||
} else {
|
||||
final int damageStart = Integer.parseInt(range[0]);
|
||||
final int damageEnd = Integer.parseInt(range[1]);
|
||||
matcher = dmg -> dmg >= damageStart && dmg <= damageEnd;
|
||||
}
|
||||
|
||||
return stack -> matcher.test(stack.getItemDamage());
|
||||
}
|
||||
|
||||
protected static ItemFilter getStringIdentifierFilter(String rule) {
|
||||
final FMLControlledNamespacedRegistry<Item> iItemRegistry = GameData.getItemRegistry();
|
||||
final Predicate<String> matcher = getMatcher(rule);
|
||||
|
||||
return stack -> {
|
||||
String name = iItemRegistry.getNameForObject(stack.getItem());
|
||||
return name != null && !name.isEmpty() && matcher.test(name);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package codechicken.nei.util;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
@@ -34,8 +32,7 @@ public class NBTHelper {
|
||||
private static boolean matchTagCompound(NBTTagCompound template, NBTTagCompound target) {
|
||||
if (template.tagMap.size() > target.tagMap.size()) return false;
|
||||
|
||||
// noinspection unchecked
|
||||
for (String key : (Set<String>) template.func_150296_c()) {
|
||||
for (String key : template.func_150296_c()) {
|
||||
if (!matchTag(template.getTag(key), target.getTag(key))) return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package codechicken.nei.util;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -216,8 +217,9 @@ public class NBTJson {
|
||||
if (obj.has("__custom_type")) {
|
||||
try {
|
||||
final String className = obj.get("__custom_type").getAsString();
|
||||
return (NBTBase) Class.forName(className).newInstance();
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException th) {}
|
||||
return (NBTBase) Class.forName(className).getConstructor().newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException
|
||||
| SecurityException | ClassNotFoundException th) {}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -31,7 +31,7 @@ public class TextHistory {
|
||||
}
|
||||
|
||||
public Optional<String> get(Direction direction, String currentText) {
|
||||
if (direction == direction.NEXT) {
|
||||
if (direction == Direction.NEXT) {
|
||||
return getNext(currentText);
|
||||
} else {
|
||||
return getPrevious(currentText);
|
||||
|
||||
@@ -7,13 +7,6 @@ ILOAD 4
|
||||
PUTSTATIC codechicken/nei/ItemMobSpawner.placedZ:I
|
||||
RETURN
|
||||
|
||||
list d_spawnerWorld
|
||||
ACONST_NULL
|
||||
|
||||
list spawnerWorld
|
||||
ALOAD 0
|
||||
INVOKEVIRTUAL net/minecraft/tileentity/MobSpawnerBaseLogic.func_98271_a()Lnet/minecraft/world/World;
|
||||
|
||||
list n_commaFix
|
||||
LDC *
|
||||
INVOKEVIRTUAL java/lang/StringBuilder.append (Ljava/lang/String;)Ljava/lang/StringBuilder;
|
||||
|
||||
@@ -2,19 +2,26 @@
|
||||
#
|
||||
# One line - one group
|
||||
# Item added in first valid group
|
||||
# | - logical or. multi-item search (wrench|hammer)
|
||||
# $ - search by ore dictionary ($ore)
|
||||
# ! - logical not. exclude items that match the following expression (-@minecraft)
|
||||
# r/.../ - standard java regex (@r/m\w{6}ft/ = @minecraft)
|
||||
# 0 - damage filter
|
||||
# 0-12 - damage range filter
|
||||
# , - logical or in token
|
||||
#
|
||||
#
|
||||
# parts:
|
||||
# modname:itemid - identify
|
||||
# $orename - ore dictionary
|
||||
# tag.color=red - tag
|
||||
# 0 or 0-12 - damage
|
||||
#
|
||||
# modifiers:
|
||||
# ! - logical not. exclude items that match the following expression (!minecraft:portal)
|
||||
# r/.../ - standard java regex (r/^m\w{6}ft$/ = minecraft)
|
||||
# , - logical or in token (minecraft:potion 16384-16462,!16386)
|
||||
# | - logical or multi-item search (wrench|hammer)
|
||||
#
|
||||
# example: minecraft:potion 16384-16462,!16386 | $oreiron | tag.color=red
|
||||
#
|
||||
minecraft:spawn_egg
|
||||
minecraft:mob_spawner
|
||||
minecraft:record_
|
||||
#splash
|
||||
minecraft:potion >16000
|
||||
#lingering
|
||||
minecraft:potion >8000 <9000
|
||||
#splash potion
|
||||
minecraft:potion 16000-17000
|
||||
#lingering potion
|
||||
minecraft:potion 8000-9000
|
||||
@@ -1,5 +1,5 @@
|
||||
# Each line in this file should either be a comment (line starts with '#'), or a prefix of a fully-qualified class name
|
||||
# (that includes the package name) for a Minecraft GUI Container screen.
|
||||
# If you delete this file, it will be regenerated with the default enable autofocus list.
|
||||
net.minecraft.client.gui.inventory.GuiInventory
|
||||
net.minecraft.client.gui.
|
||||
makamys.satchels.gui.GuiSatchelsInventory
|
||||
+2
-1
@@ -53,4 +53,5 @@ miscutils:particleIon,Damage
|
||||
miscutils:personalHealingDevice
|
||||
tectech:item.em.debugContainer,tag.symbols
|
||||
tinkersdefense:Heater Shield,tag.InfiTool
|
||||
tinkersdefense:Round Shield,tag.InfiTool
|
||||
tinkersdefense:Round Shield,tag.InfiTool
|
||||
miscutils:itemCustomMetaCover.miscutils.GtMachineCasings,Damage
|
||||
@@ -0,0 +1,24 @@
|
||||
# Hidden Items Filters
|
||||
#
|
||||
# parts:
|
||||
# modname:itemid - identify
|
||||
# $orename - ore dictionary
|
||||
# tag.color=red - tag
|
||||
# 0 or 0-12 - damage
|
||||
#
|
||||
# modifiers:
|
||||
# ! - logical not. exclude items that match the following expression (!minecraft:portal)
|
||||
# r/.../ - standard java regex (r/^m\w{6}ft$/ = minecraft)
|
||||
# , - logical or in token (minecraft:potion 16384-16462,!16386)
|
||||
# | - logical or multi-item search (wrench|hammer)
|
||||
#
|
||||
# example: minecraft:potion 16384-16462,!16386 | $oreiron | tag.color=red
|
||||
#
|
||||
minecraft:portal
|
||||
minecraft:end_portal
|
||||
minecraft:fire
|
||||
minecraft:lava
|
||||
minecraft:mob_spawner
|
||||
minecraft:anvil !0
|
||||
minecraft:flowing_water
|
||||
minecraft:flowing_lava
|
||||
@@ -822,6 +822,7 @@ gt.recipe.largeboilerfakefuels,gregtech:gt.blockmachines:1022,,gregtech,TRUE,gre
|
||||
gt.recipe.largeboilerfakefuels,gregtech:gt.blockmachines:1023,,gregtech,TRUE,gregapi_post,,,,,
|
||||
gt.recipe.vacuumfreezer,gregtech:gt.blockmachines:1002,,gregtech,TRUE,gregapi_post,,,,,
|
||||
smelting,gregtech:gt.blockmachines:1003,,gregtech,TRUE,gregapi_post,,,,,
|
||||
smelting,gregtech:gt.blockmachines:15412,,gregtech,TRUE,gregapi_post,,,,,
|
||||
gt.recipe.dieselgeneratorfuel,gregtech:gt.blockmachines:1110,,gregtech,TRUE,gregapi_post,,,,,
|
||||
gt.recipe.dieselgeneratorfuel,gregtech:gt.blockmachines:1111,,gregtech,TRUE,gregapi_post,,,,,
|
||||
gt.recipe.dieselgeneratorfuel,gregtech:gt.blockmachines:1112,,gregtech,TRUE,gregapi_post,,,,,
|
||||
|
||||
|
@@ -88,9 +88,9 @@ nei.options.inventory.widgetsenabled.false=NEI zakázáno
|
||||
nei.options.inventory.cheatmode.0=Mód receptů
|
||||
nei.options.inventory.cheatmode.1=Užitný mód
|
||||
nei.options.inventory.cheatmode.2=Cheatovací mód
|
||||
nei.options.inventory.profileRecipes=Profilové recepty
|
||||
nei.options.inventory.profileRecipes.true=Povoleny
|
||||
nei.options.inventory.profileRecipes.false=Nepovoleny
|
||||
nei.options.inventory.guirecipe.profile=Profilové recepty
|
||||
nei.options.inventory.guirecipe.profile.true=Povoleny
|
||||
nei.options.inventory.guirecipe.profile.false=Nepovoleny
|
||||
nei.options.inventory.itemsort=Řazení panelu předmětů
|
||||
nei.options.inventory.itemIDs=IDčka předmětů
|
||||
nei.options.inventory.itemIDs.0=Skryté
|
||||
|
||||
@@ -92,9 +92,9 @@ nei.options.inventory.widgetsenabled.false=NEI Deaktiviert
|
||||
nei.options.inventory.cheatmode.0=Rezeptmodus
|
||||
nei.options.inventory.cheatmode.1=Mehrzweckmodus
|
||||
nei.options.inventory.cheatmode.2=Cheat-Modus
|
||||
nei.options.inventory.profileRecipes=Profil-Rezepte
|
||||
nei.options.inventory.profileRecipes.true=Wahr
|
||||
nei.options.inventory.profileRecipes.false=Falsch
|
||||
nei.options.inventory.guirecipe.profile=Profil-Rezepte
|
||||
nei.options.inventory.guirecipe.profile.true=Wahr
|
||||
nei.options.inventory.guirecipe.profile.false=Falsch
|
||||
nei.options.inventory.itemsort=Item-Panel-Sortierung
|
||||
nei.options.inventory.itemIDs=Item-IDs
|
||||
nei.options.inventory.itemIDs.0=Versteckt
|
||||
@@ -104,6 +104,26 @@ nei.options.inventory.search.patternMode=Suchmodus
|
||||
nei.options.inventory.search.patternMode.0=Gewöhnlich
|
||||
nei.options.inventory.search.patternMode.1=Erweitert
|
||||
nei.options.inventory.search.patternMode.2=Regex
|
||||
nei.options.inventory.search.modNameSearchMode=Modname Suchmodus
|
||||
nei.options.inventory.search.modNameSearchMode.0=Immer
|
||||
nei.options.inventory.search.modNameSearchMode.1=Präfix: %s
|
||||
nei.options.inventory.search.modNameSearchMode.2=Nie
|
||||
nei.options.inventory.search.tooltipSearchMode=Tooltip Suchmodus
|
||||
nei.options.inventory.search.tooltipSearchMode.0=Immer
|
||||
nei.options.inventory.search.tooltipSearchMode.1=Präfix: %s
|
||||
nei.options.inventory.search.tooltipSearchMode.2=Nie
|
||||
nei.options.inventory.search.identifierSearchMode=Identifikator Suchmodus
|
||||
nei.options.inventory.search.identifierSearchMode.0=Immer
|
||||
nei.options.inventory.search.identifierSearchMode.1=Präfix: %s
|
||||
nei.options.inventory.search.identifierSearchMode.2=Nie
|
||||
nei.options.inventory.search.oreDictSearchMode=OreDict Suchmodus
|
||||
nei.options.inventory.search.oreDictSearchMode.0=Immer
|
||||
nei.options.inventory.search.oreDictSearchMode.1=Präfix: %s
|
||||
nei.options.inventory.search.oreDictSearchMode.2=Nie
|
||||
nei.options.inventory.search.subsetsSearchMode=Item-SubSet Suchmodus
|
||||
nei.options.inventory.search.subsetsSearchMode.0=Immer
|
||||
nei.options.inventory.search.subsetsSearchMode.1=Präfix: %s
|
||||
nei.options.inventory.search.subsetsSearchMode.2=Nie
|
||||
nei.options.inventory.utilities=Nützliches
|
||||
nei.options.inventory.utilities.tip=Wähle Inhalte für den Mehrzweckmodus
|
||||
nei.options.inventory.utilities.time=Zeit
|
||||
|
||||
@@ -3,17 +3,39 @@ nei.save=Save
|
||||
|
||||
# PC/Linux Control Key
|
||||
nei.key.ctrl=CTRL
|
||||
nei.key.shift=SHIFT
|
||||
nei.key.alt=ALT
|
||||
# Mac Command Key
|
||||
nei.key.ctrl.mac=CMD
|
||||
nei.showHotkeys=Hold %s for hotkeys
|
||||
|
||||
nei.bookmark.toggle=Bookmarks
|
||||
nei.bookmark.toggle.tip=Toggle visibility of the Bookmark Panel
|
||||
nei.bookmark.viewmode.toggle.tip=Toggle Bookmark View Mode
|
||||
nei.bookmark.pullBookmarkedItems.tip=Pull all bookmarked items from storage to inventory
|
||||
|
||||
nei.bookmark.group=Bookmarks Group
|
||||
nei.bookmark.group.include_group=Create/Include Group
|
||||
nei.bookmark.group.include_group.key=LMB + Drag
|
||||
nei.bookmark.group.exclude_group=Remove/Exclude Group
|
||||
nei.bookmark.group.exclude_group.key=RMB + Drag
|
||||
nei.bookmark.group.toggle_mode=Toggle Group Mode
|
||||
nei.bookmark.group.toggle_mode.key=Left Click
|
||||
nei.bookmark.group.toggle_crafting_chain=Toggle Crafting Chain
|
||||
nei.bookmark.group.toggle_crafting_chain.key=Right Click
|
||||
nei.bookmark.group.sorting=Sorting
|
||||
nei.bookmark.group.sorting.key=SHIFT + LMB + Drag
|
||||
nei.bookmark.group.remove_recipe=Remove Group
|
||||
nei.bookmark.group.pull_items=Pull all Items
|
||||
nei.bookmark.group.pull_items_ingredients=Pull all Ingredients
|
||||
nei.bookmark.crafting_chain=Crafting Chain
|
||||
nei.bookmark.crafting_chain.input=Ingredients
|
||||
nei.bookmark.crafting_chain.output=Results
|
||||
nei.bookmark.crafting_chain.remainder=Remainders
|
||||
|
||||
nei.itempanel.quantity.default=One stack
|
||||
nei.itempanel.loading=Loading Item List...
|
||||
nei.itempanel.collapsed.button.tip=Toggle Groups
|
||||
nei.itempanel.deleteItem=Delete Item
|
||||
nei.itempanel.collapsed.button.tip=Collapse/Expand All Collapsible Items
|
||||
nei.itempanel.collapsed.hint.expand=Alt-Click to expand (%d items)
|
||||
nei.itempanel.collapsed.hint.collapse=Alt-Click to collapse (%d items)
|
||||
|
||||
@@ -113,6 +135,7 @@ nei.options.keys.gui.next_machine=Next Machine
|
||||
nei.options.keys.gui.prev_machine=Prev Machine
|
||||
nei.options.keys.gui.search=Focus Search Bar
|
||||
nei.options.keys.gui.bookmark=Add Bookmark
|
||||
nei.options.keys.gui.remove_recipe=Remove Group from Bookmarks
|
||||
nei.options.keys.gui.bookmark_recipe=Add Bookmark with Recipe
|
||||
nei.options.keys.gui.bookmark_count=Add Bookmark with Count
|
||||
nei.options.keys.gui.bookmark_pull_items=Pull all Bookmarked Items
|
||||
@@ -127,6 +150,10 @@ nei.options.keys.gui.getnextsearch=Next Search
|
||||
nei.options.keys.gui.next_tooltip=Next Tooltip
|
||||
nei.options.keys.gui.copy_name=Copy Item Name
|
||||
nei.options.keys.gui.copy_oredict=Copy Item OreDictionary
|
||||
nei.options.keys.gui.itemzoom_toggle=Toggle Item Zoom
|
||||
nei.options.keys.gui.itemzoom_hold=Hold to Display Item Zoom
|
||||
nei.options.keys.gui.itemzoom_zoom_in=Item Zoom In
|
||||
nei.options.keys.gui.itemzoom_zoom_out=Item Zoom Out
|
||||
nei.options.keys.world=World
|
||||
nei.options.keys.world.chunkoverlay=Chunk Boundary Overlay
|
||||
nei.options.keys.world.moboverlay=Mob Spawn Overlay
|
||||
@@ -141,42 +168,47 @@ nei.options.keys.world.creative=Gamemode
|
||||
nei.options.keys.world.creative.tip=Cycle Gamemode
|
||||
|
||||
nei.options.inventory=Inventory
|
||||
nei.options.inventory.worldSpecificBookmarks=World Specific Bookmarks
|
||||
nei.options.inventory.worldSpecificBookmarks.true=Yes
|
||||
nei.options.inventory.worldSpecificBookmarks.false=No
|
||||
nei.options.inventory.worldSpecificPresets=World Specific Presets
|
||||
nei.options.inventory.worldSpecificPresets.true=Yes
|
||||
nei.options.inventory.worldSpecificPresets.false=No
|
||||
nei.options.inventory.bookmarksEnabled=Bookmarks Panel Visibility
|
||||
nei.options.inventory.bookmarksEnabled.true=Visible
|
||||
nei.options.inventory.bookmarksEnabled.false=Hidden
|
||||
nei.options.inventory.jei_style_tabs=JEI Style Tabs
|
||||
nei.options.inventory.jei_style_tabs.true=Yes
|
||||
nei.options.inventory.jei_style_tabs.false=No [Weirdo]
|
||||
nei.options.inventory.itemPresenceOverlay=Item Overlay on ?-Hover
|
||||
nei.options.inventory.itemPresenceOverlay.0=None
|
||||
nei.options.inventory.itemPresenceOverlay.1=Icon
|
||||
nei.options.inventory.itemPresenceOverlay.2=Background
|
||||
nei.options.inventory.slotHighlightPresent=Highlight Present Item
|
||||
nei.options.inventory.slotHighlightPresent.true=Yes
|
||||
nei.options.inventory.slotHighlightPresent.false=No
|
||||
nei.options.inventory.jei_style_recipe_catalyst=JEI Style Recipe Catalysts
|
||||
nei.options.inventory.jei_style_recipe_catalyst.true=Yes
|
||||
nei.options.inventory.jei_style_recipe_catalyst.false=No
|
||||
nei.options.inventory.saveCurrentRecipeInBookmarksEnabled=Save Current Recipe in Bookmarks
|
||||
nei.options.inventory.saveCurrentRecipeInBookmarksEnabled.true=Enabled
|
||||
nei.options.inventory.saveCurrentRecipeInBookmarksEnabled.false=Disabled
|
||||
nei.options.inventory.recipeTooltipsMode=Show recipe tooltips in Bookmarks
|
||||
nei.options.inventory.recipeTooltipsMode.0=None
|
||||
nei.options.inventory.recipeTooltipsMode.1=In Horizontal View
|
||||
nei.options.inventory.recipeTooltipsMode.2=In Vertical View
|
||||
nei.options.inventory.recipeTooltipsMode.3=Always
|
||||
nei.options.inventory.bookmarksAnimationEnabled=REI Style Animation in Bookmarks
|
||||
nei.options.inventory.bookmarksAnimationEnabled.true=Yes
|
||||
nei.options.inventory.bookmarksAnimationEnabled.false=No
|
||||
nei.options.inventory.showRecipeMarker=Show Recipe Marker
|
||||
nei.options.inventory.showRecipeMarker.true=Yes
|
||||
nei.options.inventory.showRecipeMarker.false=No
|
||||
nei.options.inventory.bookmarks=Bookmarks Panel
|
||||
nei.options.inventory.bookmarks.enabled=Bookmarks Panel Visibility
|
||||
nei.options.inventory.bookmarks.enabled.true=Visible
|
||||
nei.options.inventory.bookmarks.enabled.false=Hidden
|
||||
nei.options.inventory.bookmarks.animation=REI Style Animation in Bookmarks
|
||||
nei.options.inventory.bookmarks.animation.true=Yes
|
||||
nei.options.inventory.bookmarks.animation.false=No
|
||||
nei.options.inventory.bookmarks.craftingChainDir=Crafting Chain Info Direction
|
||||
nei.options.inventory.bookmarks.craftingChainDir.0=Input First
|
||||
nei.options.inventory.bookmarks.craftingChainDir.1=Output First
|
||||
nei.options.inventory.bookmarks.recipeTooltipsMode=Show recipe tooltips in Bookmarks
|
||||
nei.options.inventory.bookmarks.recipeTooltipsMode.0=None
|
||||
nei.options.inventory.bookmarks.recipeTooltipsMode.1=In Horizontal View
|
||||
nei.options.inventory.bookmarks.recipeTooltipsMode.2=In Vertical View
|
||||
nei.options.inventory.bookmarks.recipeTooltipsMode.3=Always
|
||||
nei.options.inventory.bookmarks.showRecipeMarker=Show Recipe Marker
|
||||
nei.options.inventory.bookmarks.showRecipeMarker.true=Yes
|
||||
nei.options.inventory.bookmarks.showRecipeMarker.false=No
|
||||
nei.options.inventory.bookmarks.ignorePotionOverlap=Ignore overlap with potion effect HUD
|
||||
nei.options.inventory.bookmarks.ignorePotionOverlap.true=Yes
|
||||
nei.options.inventory.bookmarks.ignorePotionOverlap.false=No
|
||||
nei.options.inventory.bookmarks.worldSpecific=World Specific Bookmarks
|
||||
nei.options.inventory.bookmarks.worldSpecific.true=Yes
|
||||
nei.options.inventory.bookmarks.worldSpecific.false=No
|
||||
nei.options.inventory.guirecipe=Recipes GUI
|
||||
nei.options.inventory.guirecipe.jeiStyleTabs=JEI Style Tabs
|
||||
nei.options.inventory.guirecipe.jeiStyleTabs.true=Yes
|
||||
nei.options.inventory.guirecipe.jeiStyleTabs.false=No [Weirdo]
|
||||
nei.options.inventory.guirecipe.itemPresenceOverlay=Item Overlay on ?-Hover
|
||||
nei.options.inventory.guirecipe.itemPresenceOverlay.0=None
|
||||
nei.options.inventory.guirecipe.itemPresenceOverlay.1=Icon
|
||||
nei.options.inventory.guirecipe.itemPresenceOverlay.2=Background
|
||||
nei.options.inventory.guirecipe.slotHighlightPresent=Highlight Present Item
|
||||
nei.options.inventory.guirecipe.slotHighlightPresent.true=Yes
|
||||
nei.options.inventory.guirecipe.slotHighlightPresent.false=No
|
||||
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst=JEI Style Recipe Catalysts
|
||||
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.true=Yes
|
||||
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.false=No
|
||||
nei.options.inventory.guirecipe.cycledIngredientsTooltip=Cycled Ingredients Tooltip
|
||||
nei.options.inventory.guirecipe.cycledIngredientsTooltip.true=Show
|
||||
nei.options.inventory.guirecipe.cycledIngredientsTooltip.false=Hide
|
||||
nei.options.inventory.showItemQuantityWidget=Show Item Quantity Widget
|
||||
nei.options.inventory.showItemQuantityWidget.true=Yes
|
||||
nei.options.inventory.showItemQuantityWidget.false=No
|
||||
@@ -185,8 +217,9 @@ nei.options.inventory.search.widgetPosition=Widget Position
|
||||
nei.options.inventory.search.widgetPosition.true=Center
|
||||
nei.options.inventory.search.widgetPosition.false=Right
|
||||
nei.options.inventory.search.widgetAutofocus=Autofocus
|
||||
nei.options.inventory.search.widgetAutofocus.true=Yes
|
||||
nei.options.inventory.search.widgetAutofocus.false=No
|
||||
nei.options.inventory.search.widgetAutofocus.0=No
|
||||
nei.options.inventory.search.widgetAutofocus.1=Yes
|
||||
nei.options.inventory.search.widgetAutofocus.2=Extended
|
||||
nei.options.inventory.search.patternMode=Search Mode
|
||||
nei.options.inventory.search.patternMode.0=Plain
|
||||
nei.options.inventory.search.patternMode.1=Extended
|
||||
@@ -194,6 +227,9 @@ nei.options.inventory.search.patternMode.2=Regex
|
||||
nei.options.inventory.search.quoteDropItemName=Quote Drop Item Name
|
||||
nei.options.inventory.search.quoteDropItemName.true=Yes
|
||||
nei.options.inventory.search.quoteDropItemName.false=No
|
||||
nei.options.inventory.search.format=Search Format
|
||||
nei.options.inventory.search.format.true=Old Format
|
||||
nei.options.inventory.search.format.false=Extended
|
||||
nei.options.inventory.search.modNameSearchMode=Mod Name Search
|
||||
nei.options.inventory.search.modNameSearchMode.0=Always
|
||||
nei.options.inventory.search.modNameSearchMode.1=Prefix: %s
|
||||
@@ -214,32 +250,26 @@ nei.options.inventory.search.subsetsSearchMode=Item Subsets Search
|
||||
nei.options.inventory.search.subsetsSearchMode.0=Always
|
||||
nei.options.inventory.search.subsetsSearchMode.1=Prefix: %s
|
||||
nei.options.inventory.search.subsetsSearchMode.2=Never
|
||||
nei.options.inventory.firstInvCloseClosesInSearch=First Inventory Close Closes in Search
|
||||
nei.options.inventory.firstInvCloseClosesInSearch.true=Yes
|
||||
nei.options.inventory.firstInvCloseClosesInSearch.false=No
|
||||
nei.options.inventory.creative_tab_style=Creative or JEI tab style
|
||||
nei.options.inventory.creative_tab_style.true=Creative
|
||||
nei.options.inventory.creative_tab_style.false=JEI
|
||||
nei.options.inventory.ignore_potion_overlap=Ignore overlap with potion effect HUD
|
||||
nei.options.inventory.ignore_potion_overlap.true=Yes
|
||||
nei.options.inventory.ignore_potion_overlap.false=No
|
||||
nei.options.inventory.guirecipe.creativeTabStyle=Creative or JEI tab style
|
||||
nei.options.inventory.guirecipe.creativeTabStyle.true=Creative
|
||||
nei.options.inventory.guirecipe.creativeTabStyle.false=JEI
|
||||
nei.options.inventory.optimize_gui_overlap_computation=Optimize computation for GUI overlap
|
||||
nei.options.inventory.optimize_gui_overlap_computation.true=Yes
|
||||
nei.options.inventory.optimize_gui_overlap_computation.false=No
|
||||
nei.options.inventory.jei_style_cycled_ingredients=JEI styled cycled ingredients
|
||||
nei.options.inventory.jei_style_cycled_ingredients.true=Yes
|
||||
nei.options.inventory.jei_style_cycled_ingredients.false=No
|
||||
nei.options.inventory.shift_overlay_recipe=Require holding shift to move items when overlaying recipe
|
||||
nei.options.inventory.shift_overlay_recipe.true=Yes
|
||||
nei.options.inventory.shift_overlay_recipe.false=No
|
||||
nei.options.inventory.guirecipe.jeiStyleCycledIngredients=JEI styled cycled ingredients
|
||||
nei.options.inventory.guirecipe.jeiStyleCycledIngredients.true=Yes
|
||||
nei.options.inventory.guirecipe.jeiStyleCycledIngredients.false=No
|
||||
nei.options.inventory.guirecipe.shiftOverlayRecipe=Require holding shift to move items when overlaying recipe
|
||||
nei.options.inventory.guirecipe.shiftOverlayRecipe.true=Yes
|
||||
nei.options.inventory.guirecipe.shiftOverlayRecipe.false=No
|
||||
nei.options.inventory.widgetsenabled.true=NEI Enabled
|
||||
nei.options.inventory.widgetsenabled.false=NEI Disabled
|
||||
nei.options.inventory.cheatmode.0=Recipe Mode
|
||||
nei.options.inventory.cheatmode.1=Utility Mode
|
||||
nei.options.inventory.cheatmode.2=Cheat Mode
|
||||
nei.options.inventory.profileRecipes=Profile Recipes
|
||||
nei.options.inventory.profileRecipes.true=True
|
||||
nei.options.inventory.profileRecipes.false=False
|
||||
nei.options.inventory.guirecipe.profile=Profile Recipes
|
||||
nei.options.inventory.guirecipe.profile.true=True
|
||||
nei.options.inventory.guirecipe.profile.false=False
|
||||
nei.options.inventory.itemsort=Item Panel Sorting
|
||||
nei.options.inventory.itemIDs=Item IDs
|
||||
nei.options.inventory.itemIDs.0=Hidden
|
||||
@@ -274,6 +304,9 @@ nei.options.inventory.collapsibleItems=Collapsible Items
|
||||
nei.options.inventory.collapsibleItems.enabled=Collapsible Items
|
||||
nei.options.inventory.collapsibleItems.enabled.true=Enabled
|
||||
nei.options.inventory.collapsibleItems.enabled.false=Disabled
|
||||
nei.options.inventory.collapsibleItems.customName=Show Custom Group Name
|
||||
nei.options.inventory.collapsibleItems.customName.true=Yes
|
||||
nei.options.inventory.collapsibleItems.customName.false=No
|
||||
nei.options.inventory.collapsibleItems.expandedColor=Expanded Color
|
||||
nei.options.inventory.collapsibleItems.collapsedColor=Collapsed Color
|
||||
nei.options.inventory.collapsibleItems.reloadLabel=Reload
|
||||
@@ -287,6 +320,27 @@ nei.options.inventory.history.useRows=Rows
|
||||
nei.options.inventory.history.splittingMode=Splitting Mode
|
||||
nei.options.inventory.history.splittingMode.0=Background
|
||||
nei.options.inventory.history.splittingMode.1=Dotted Line
|
||||
nei.options.inventory.itemzoom=Item Zoom Panel
|
||||
nei.options.inventory.itemzoom.enabled=Item Zoom Panel Visibility
|
||||
nei.options.inventory.itemzoom.enabled.true=Enabled
|
||||
nei.options.inventory.itemzoom.enabled.false=Disabled
|
||||
nei.options.inventory.itemzoom.neiOnly=NEI Overlays Only
|
||||
nei.options.inventory.itemzoom.neiOnly.true=Enabled
|
||||
nei.options.inventory.itemzoom.neiOnly.false=Disabled
|
||||
nei.options.inventory.itemzoom.neiOnly.tip=Zoom items only from the JEI ingredient and bookmark list overlays.
|
||||
nei.options.inventory.itemzoom.onlySolid=Show Only Solid Items
|
||||
nei.options.inventory.itemzoom.onlySolid.true=Enabled
|
||||
nei.options.inventory.itemzoom.onlySolid.false=Disabled
|
||||
nei.options.inventory.itemzoom.helpText=Display Help Text
|
||||
nei.options.inventory.itemzoom.helpText.true=Enabled
|
||||
nei.options.inventory.itemzoom.helpText.false=Disabled
|
||||
nei.options.inventory.itemzoom.helpText.tip=Display name "Item Zoom" and the hotkey to toggle this mod below the zoomed item.
|
||||
nei.options.inventory.itemzoom.zoom=Zoom Amount
|
||||
nei.options.inventory.itemzoom.zoom.tip=Set lower amount to make the item zoom less.
|
||||
nei.options.inventory.itemzoom.showName=Display Name
|
||||
nei.options.inventory.itemzoom.showName.true=Show
|
||||
nei.options.inventory.itemzoom.showName.false=Hide
|
||||
nei.options.inventory.itemzoom.nameColor=Display Name Color
|
||||
|
||||
nei.options.command=Commands
|
||||
nei.options.command.creative=Gamemode
|
||||
@@ -366,6 +420,17 @@ nei.recipe.profiler.crafting=Crafting Profiling
|
||||
nei.recipe.profiler.usage=Usage Profiling
|
||||
nei.recipe.concurrent.usage=Concurrent Usage - Total
|
||||
nei.recipe.concurrent.crafting=Concurrent Crafting - Total
|
||||
nei.recipe.accepts=Accepts following
|
||||
|
||||
nei.recipe.overlay=Recipe Overlay
|
||||
nei.recipe.overlay.missing=Missing following
|
||||
nei.recipe.overlay.mismatch=Mismatch Crafting Grid
|
||||
nei.recipe.overlay.fillCraftingGrid=Fill Crafting Grid
|
||||
nei.recipe.overlay.fillCraftingGrid.key=SHIFT + Click
|
||||
nei.recipe.overlay.bookmark=Save to Bookmark
|
||||
nei.recipe.overlay.bookmarkRecipe=Save with Recipe
|
||||
nei.recipe.overlay.bookmarkAmount=Save with Amount
|
||||
nei.recipe.overlay.bookmarkRecipeAndAmount=Save with Recipe & Amount
|
||||
|
||||
nei.itemsort.minecraft=Minecraft
|
||||
nei.itemsort.minecraft.tip=Sorts items from vanilla minecraft first
|
||||
@@ -405,6 +470,7 @@ nei.subsets.Items.Weapons.Swords=Swords
|
||||
nei.subsets.Mod=Mod
|
||||
|
||||
nei.presets.new=New Preset
|
||||
nei.presets.toggle=Toggle Presets
|
||||
nei.presets.create=Create Preset
|
||||
nei.presets.update=Update Preset
|
||||
nei.presets.enabled=Enabled
|
||||
@@ -416,8 +482,10 @@ nei.presets.mode.hide=Hide
|
||||
nei.presets.mode.hide.char=H
|
||||
nei.presets.mode.hide.tip=Hide items in panel
|
||||
nei.presets.mode.remove=Remove
|
||||
nei.presets.mode.remove.tip=Hide items in panel and it recipes
|
||||
nei.presets.mode.remove.tip=Hide items in panel and their recipes
|
||||
nei.presets.mode.remove.char=R
|
||||
nei.presets.mode.group=Group
|
||||
nei.presets.mode.group.tip=Create custom collapsible items group
|
||||
nei.presets.mode.group.char=G
|
||||
|
||||
nei.itemzoom.toggle=Use %s to toggle Item Zoom
|
||||
@@ -91,9 +91,9 @@ nei.options.inventory.widgetsenabled.false=NEI keelatud
|
||||
nei.options.inventory.cheatmode.0=Retsepti mood
|
||||
nei.options.inventory.cheatmode.1=Utiliidi mood
|
||||
nei.options.inventory.cheatmode.2=Petmis mood
|
||||
nei.options.inventory.profileRecipes=Profileeri retsepte
|
||||
nei.options.inventory.profileRecipes.true=Tõene
|
||||
nei.options.inventory.profileRecipes.false=Väär
|
||||
nei.options.inventory.guirecipe.profile=Profileeri retsepte
|
||||
nei.options.inventory.guirecipe.profile.true=Tõene
|
||||
nei.options.inventory.guirecipe.profile.false=Väär
|
||||
nei.options.inventory.itemsort=Item Panel Sorting
|
||||
nei.options.inventory.itemIDs=Asja ID-d
|
||||
nei.options.inventory.itemIDs.0=Peidetud
|
||||
|
||||
@@ -89,9 +89,9 @@ nei.options.inventory.widgetsenabled.false=NEI désactivé
|
||||
nei.options.inventory.cheatmode.0=Mode recette
|
||||
nei.options.inventory.cheatmode.1=Mode utilitaire
|
||||
nei.options.inventory.cheatmode.2=Mode triche
|
||||
nei.options.inventory.profileRecipes=Profil Recettes
|
||||
nei.options.inventory.profileRecipes.true=Vrai
|
||||
nei.options.inventory.profileRecipes.false=Faux
|
||||
nei.options.inventory.guirecipe.profile=Profil Recettes
|
||||
nei.options.inventory.guirecipe.profile.true=Vrai
|
||||
nei.options.inventory.guirecipe.profile.false=Faux
|
||||
nei.options.inventory.itemsort=Tri du panneau d'élément
|
||||
nei.options.inventory.itemIDs=Objet IDs
|
||||
nei.options.inventory.itemIDs.0=Cachés
|
||||
|
||||
@@ -92,9 +92,9 @@ nei.options.inventory.widgetsenabled.false=NEI Disattivato
|
||||
nei.options.inventory.cheatmode.0=Modalità ricette
|
||||
nei.options.inventory.cheatmode.1=Modalità utilità
|
||||
nei.options.inventory.cheatmode.2=Modalità cheat
|
||||
nei.options.inventory.profileRecipes=Ricerca profilo
|
||||
nei.options.inventory.profileRecipes.true=Vero
|
||||
nei.options.inventory.profileRecipes.false=Falso
|
||||
nei.options.inventory.guirecipe.profile=Ricerca profilo
|
||||
nei.options.inventory.guirecipe.profile.true=Vero
|
||||
nei.options.inventory.guirecipe.profile.false=Falso
|
||||
nei.options.inventory.itemsort=Pannello ordine degli oggetti
|
||||
nei.options.inventory.itemIDs=ID degli oggetti
|
||||
nei.options.inventory.itemIDs.0=Nascosti
|
||||
|
||||
@@ -87,9 +87,9 @@ nei.options.inventory.widgetsenabled.false=NEI 비활성화
|
||||
nei.options.inventory.cheatmode.0=레시피모드
|
||||
nei.options.inventory.cheatmode.1=유틸리티모드
|
||||
nei.options.inventory.cheatmode.2=치트모드
|
||||
nei.options.inventory.profileRecipes=프로파일 레시피
|
||||
nei.options.inventory.profileRecipes.true=설정
|
||||
nei.options.inventory.profileRecipes.false=비설정
|
||||
nei.options.inventory.guirecipe.profile=프로파일 레시피
|
||||
nei.options.inventory.guirecipe.profile.true=설정
|
||||
nei.options.inventory.guirecipe.profile.false=비설정
|
||||
nei.options.inventory.itemsort=아이템 정렬
|
||||
nei.options.inventory.itemIDs=아이템 ID
|
||||
nei.options.inventory.itemIDs.0= 숨기기
|
||||
|
||||
@@ -89,9 +89,9 @@ nei.options.inventory.cheatmode.0=Tryb recept
|
||||
nei.options.inventory.cheatmode.1=Tryb użytku
|
||||
nei.options.inventory.cheatmode.2=Tryb oszukiwania
|
||||
|
||||
nei.options.inventory.profileRecipes=Profiluj recepty
|
||||
nei.options.inventory.profileRecipes.true=Tak
|
||||
nei.options.inventory.profileRecipes.false=Nie
|
||||
nei.options.inventory.guirecipe.profile=Profiluj recepty
|
||||
nei.options.inventory.guirecipe.profile.true=Tak
|
||||
nei.options.inventory.guirecipe.profile.false=Nie
|
||||
nei.options.inventory.itemsort=Sortowanie paelu przedmiotów
|
||||
nei.options.inventory.itemIDs=ID przedmiotów
|
||||
nei.options.inventory.itemIDs.0=Ukryte
|
||||
|
||||
@@ -90,8 +90,8 @@ nei.options.inventory.cheatmode.1=Modo Utilidade
|
||||
nei.options.inventory.cheatmode.2=Modo Cheat
|
||||
|
||||
nei.options.inventory.profileRecAtivaripes=Perfilar Receitas
|
||||
nei.options.inventory.profileRecipes.true=Verdadeiro
|
||||
nei.options.inventory.profileRecipes.false=Falso
|
||||
nei.options.inventory.guirecipe.profile.true=Verdadeiro
|
||||
nei.options.inventory.guirecipe.profile.false=Falso
|
||||
nei.options.inventory.itemsort=Ordenamento do Painel de Itens
|
||||
nei.options.inventory.itemIDs=IDs de Itens
|
||||
nei.options.inventory.itemIDs.0=Escondido
|
||||
|
||||
@@ -190,9 +190,6 @@ nei.options.inventory.bookmarks.ignorePotionOverlap.false=Нет
|
||||
nei.options.inventory.bookmarks.worldSpecific=Закладки для конкретного мира
|
||||
nei.options.inventory.bookmarks.worldSpecific.true=Да
|
||||
nei.options.inventory.bookmarks.worldSpecific.false=Нет
|
||||
nei.options.inventory.worldSpecificPresets=Пресеты для конкретного мира
|
||||
nei.options.inventory.worldSpecificPresets.true=Да
|
||||
nei.options.inventory.worldSpecificPresets.false=Нет
|
||||
nei.options.inventory.guirecipe=Интерфейс рецептов
|
||||
nei.options.inventory.guirecipe.jeiStyleTabs=Вкладки в стиле JEI
|
||||
nei.options.inventory.guirecipe.jeiStyleTabs.true=Да
|
||||
|
||||
@@ -89,9 +89,9 @@ nei.options.inventory.cheatmode.0=Mód Receptov
|
||||
nei.options.inventory.cheatmode.1=Úžitkový mód
|
||||
nei.options.inventory.cheatmode.2=Čítovací mód
|
||||
|
||||
nei.options.inventory.profileRecipes=Profilovanie receptov
|
||||
nei.options.inventory.profileRecipes.true=Áno
|
||||
nei.options.inventory.profileRecipes.false=Nie
|
||||
nei.options.inventory.guirecipe.profile=Profilovanie receptov
|
||||
nei.options.inventory.guirecipe.profile.true=Áno
|
||||
nei.options.inventory.guirecipe.profile.false=Nie
|
||||
nei.options.inventory.itemsort=Zoradenie itemov
|
||||
nei.options.inventory.itemIDs=ID itemov
|
||||
nei.options.inventory.itemIDs.0=Skryté
|
||||
|
||||
@@ -89,9 +89,9 @@ nei.options.inventory.cheatmode.0=Tarif modu
|
||||
nei.options.inventory.cheatmode.1=Yardımcı mod
|
||||
nei.options.inventory.cheatmode.2=Hileli mod
|
||||
|
||||
nei.options.inventory.profileRecipes=Profil tarifleri
|
||||
nei.options.inventory.profileRecipes.true=Yazı
|
||||
nei.options.inventory.profileRecipes.false=Şekil
|
||||
nei.options.inventory.guirecipe.profile=Profil tarifleri
|
||||
nei.options.inventory.guirecipe.profile.true=Yazı
|
||||
nei.options.inventory.guirecipe.profile.false=Şekil
|
||||
nei.options.inventory.itemsort=Item Panel Sıralaması
|
||||
nei.options.inventory.itemIDs=Item IDleri
|
||||
nei.options.inventory.itemIDs.0=Gizli
|
||||
|
||||
@@ -128,47 +128,41 @@ nei.options.keys.world.creative=游戏模式
|
||||
nei.options.keys.world.creative.tip=循环游戏模式
|
||||
|
||||
nei.options.inventory=物品栏
|
||||
nei.options.inventory.worldSpecificBookmarks=书签存储位置
|
||||
nei.options.inventory.worldSpecificBookmarks.true=存档内
|
||||
nei.options.inventory.worldSpecificBookmarks.false=全局
|
||||
nei.options.inventory.worldSpecificPresets=预设存储位置
|
||||
nei.options.inventory.worldSpecificPresets.true=存档内
|
||||
nei.options.inventory.worldSpecificPresets.false=全局
|
||||
nei.options.inventory.bookmarksEnabled=显示/隐藏书签页
|
||||
nei.options.inventory.bookmarksEnabled.true=显示
|
||||
nei.options.inventory.bookmarksEnabled.false=隐藏
|
||||
nei.options.inventory.jei_style_tabs=JEI标签页
|
||||
nei.options.inventory.jei_style_tabs.true=是
|
||||
nei.options.inventory.jei_style_tabs.false=否 [不会吧]
|
||||
nei.options.inventory.jei_style_recipe_catalyst=JEI风格可执行合成表机器显示[测试中]
|
||||
nei.options.inventory.jei_style_recipe_catalyst.true=是
|
||||
nei.options.inventory.jei_style_recipe_catalyst.false=否
|
||||
nei.options.inventory.saveCurrentRecipeInBookmarksEnabled=保存书签中的当前合成表
|
||||
nei.options.inventory.saveCurrentRecipeInBookmarksEnabled.true=启用
|
||||
nei.options.inventory.saveCurrentRecipeInBookmarksEnabled.false=禁用
|
||||
nei.options.inventory.bookmarksAnimationEnabled=REI风格书签动画
|
||||
nei.options.inventory.bookmarksAnimationEnabled.true=是
|
||||
nei.options.inventory.bookmarksAnimationEnabled.false=否
|
||||
nei.options.inventory.showRecipeMarker=在书签栏显示合成产物标记
|
||||
nei.options.inventory.showRecipeMarker.true=是
|
||||
nei.options.inventory.showRecipeMarker.false=否
|
||||
nei.options.inventory.bookmarks.worldSpecific=书签存储位置
|
||||
nei.options.inventory.bookmarks.worldSpecific.true=存档内
|
||||
nei.options.inventory.bookmarks.worldSpecific.false=全局
|
||||
nei.options.inventory.bookmarks.enabled=显示/隐藏书签页
|
||||
nei.options.inventory.bookmarks.enabled.true=显示
|
||||
nei.options.inventory.bookmarks.enabled.false=隐藏
|
||||
nei.options.inventory.guirecipe.jeiStyleTabs=JEI标签页
|
||||
nei.options.inventory.guirecipe.jeiStyleTabs.true=是
|
||||
nei.options.inventory.guirecipe.jeiStyleTabs.false=否 [不会吧]
|
||||
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst=JEI风格可执行合成表机器显示[测试中]
|
||||
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.true=是
|
||||
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.false=否
|
||||
nei.options.inventory.bookmarks.animation=REI风格书签动画
|
||||
nei.options.inventory.bookmarks.animation.true=是
|
||||
nei.options.inventory.bookmarks.animation.false=否
|
||||
nei.options.inventory.bookmarks.showRecipeMarker=在书签栏显示合成产物标记
|
||||
nei.options.inventory.bookmarks.showRecipeMarker.true=是
|
||||
nei.options.inventory.bookmarks.showRecipeMarker.false=否
|
||||
nei.options.inventory.showItemQuantityWidget=显示物品数量栏(右下角)
|
||||
nei.options.inventory.showItemQuantityWidget.true=是
|
||||
nei.options.inventory.showItemQuantityWidget.false=否
|
||||
nei.options.inventory.creative_tab_style=创造模式/JEI标签页
|
||||
nei.options.inventory.creative_tab_style.true=创造模式
|
||||
nei.options.inventory.creative_tab_style.false=JEI
|
||||
nei.options.inventory.ignore_potion_overlap=忽略书签与药水效果重叠
|
||||
nei.options.inventory.ignore_potion_overlap.true=忽略
|
||||
nei.options.inventory.ignore_potion_overlap.false=规避
|
||||
nei.options.inventory.guirecipe.creativeTabStyle=创造模式/JEI标签页
|
||||
nei.options.inventory.guirecipe.creativeTabStyle.true=创造模式
|
||||
nei.options.inventory.guirecipe.creativeTabStyle.false=JEI
|
||||
nei.options.inventory.bookmarks.ignorePotionOverlap=忽略书签与药水效果重叠
|
||||
nei.options.inventory.bookmarks.ignorePotionOverlap.true=忽略
|
||||
nei.options.inventory.bookmarks.ignorePotionOverlap.false=规避
|
||||
nei.options.inventory.widgetsenabled.true=激活NEI
|
||||
nei.options.inventory.widgetsenabled.false=禁用NEI
|
||||
nei.options.inventory.cheatmode.0=合成模式
|
||||
nei.options.inventory.cheatmode.1=实用模式
|
||||
nei.options.inventory.cheatmode.2=作弊模式
|
||||
nei.options.inventory.profileRecipes=合成查阅性能分析
|
||||
nei.options.inventory.profileRecipes.true=开启
|
||||
nei.options.inventory.profileRecipes.false=关闭
|
||||
nei.options.inventory.guirecipe.profile=合成查阅性能分析
|
||||
nei.options.inventory.guirecipe.profile.true=开启
|
||||
nei.options.inventory.guirecipe.profile.false=关闭
|
||||
nei.options.inventory.itemsort=物品面板排序方式
|
||||
nei.options.inventory.itemIDs=物品ID
|
||||
nei.options.inventory.itemIDs.0=隐藏
|
||||
|
||||
@@ -88,9 +88,9 @@ nei.options.inventory.cheatmode.0=合成模式
|
||||
nei.options.inventory.cheatmode.1=實用模式
|
||||
nei.options.inventory.cheatmode.2=作弊模式
|
||||
|
||||
nei.options.inventory.profileRecipes=合成查詢
|
||||
nei.options.inventory.profileRecipes.true=開啟
|
||||
nei.options.inventory.profileRecipes.false=關閉
|
||||
nei.options.inventory.guirecipe.profile=合成查詢
|
||||
nei.options.inventory.guirecipe.profile.true=開啟
|
||||
nei.options.inventory.guirecipe.profile.false=關閉
|
||||
nei.options.inventory.itemsort=物品面板排序方式
|
||||
nei.options.inventory.itemIDs=物品ID
|
||||
nei.options.inventory.itemIDs.0=隱藏
|
||||
|
||||
Reference in new issue
Block a user