Compare commits

..
28 Commits
Author SHA1 Message Date
Ruling-0 da55c3b12c Merge remote-tracking branch 'origin/master' into mu 2026-10-24 09:01:08 -05:00
Ruling-0 9f74331116 Merge remote-tracking branch 'origin/master' into mu 2026-10-12 11:27:47 -05:00
Ruling-0 cdac4cc4a8 Bump MaterialLib to 0.24.0-mu 2026-10-11 18:25:32 -05:00
Ruling-0 9958dd45ff Bump MaterialLib to 0.21.0-mu 2026-10-09 21:16:39 -05:00
Ruling-0 a25879aaad Bump MaterialLib to 0.20.0-mu 2026-10-09 19:03:07 -05:00
Ruling-0 d8c5870a91 Merge remote-tracking branch 'origin/master' into mu 2026-10-09 18:56:18 -05:00
Ruling-0 96260fe68b Bump MaterialLib to 0.19.0-mu 2026-10-06 15:02:21 -05:00
Ruling-0 f44536d2e8 Merge remote-tracking branch 'origin/master' into mu 2026-10-05 13:22:17 -05:00
Ruling-0 fa8342cfed Bump MaterialLib to 0.18.0-mu 2026-10-04 12:35:02 -05:00
Ruling-0 82ddc4da41 Bump MaterialLib to 0.17.0-mu 2026-10-04 12:16:02 -05:00
Ruling-0 3d1d2f79e5 Bump MaterialLib to 0.16.0-mu 2026-10-04 02:48:31 -05:00
Ruling-0 867651ecab Bump MaterialLib to 0.15.0-mu 2026-09-30 13:01:52 -05:00
Ruling-0 0674aae0ec Merge remote-tracking branch 'origin/master' into mu 2026-09-30 11:33:15 -05:00
Ruling-0 5277fd36f5 Bump MaterialLib to 0.14.0-mu 2026-09-30 11:03:30 -05:00
Ruling-0 b6b31eca33 Bump MaterialLib to 0.13.0-mu 2026-09-29 16:57:41 -05:00
Ruling-0 0dbeae9f68 Bump MaterialLib to 0.12.0-mu 2026-09-29 07:22:41 -05:00
Ruling-0 f0547b5ca6 Merge remote-tracking branch 'origin/master' into mu 2026-09-28 07:38:24 -05:00
Ruling-0 e7a252a0de Bump MaterialLib to 0.11.0-mu 2026-09-22 09:54:05 -05:00
Ruling-0 442118d2e4 Merge remote-tracking branch 'origin/master' into mu 2026-09-20 11:21:25 -05:00
Ruling-0 972d0e4f3c Merge remote-tracking branch 'origin/master' into mu 2026-09-17 16:25:45 -05:00
Ruling-0 bffef55cb8 Merge remote-tracking branch 'origin/master' into mu 2026-09-15 16:10:19 -05:00
Ruling-0 e1d19e0bfc Merge remote-tracking branch 'origin/master' into mu 2026-09-09 12:51:25 -05:00
Ruling-0 b0c5f6fcda Bump MaterialLib to 0.10.0-mu 2026-08-29 22:33:14 -05:00
Ruling-0 953638be05 Merge remote-tracking branch 'origin/master' into mu 2026-08-29 22:19:17 -05:00
Ruling-0 e53d728baf Doc and code style pass 2026-08-20 17:53:20 -05:00
Ruling-0 58b63671ce Clean up ml resolver docs 2026-08-17 21:27:08 -05:00
Ruling-0 a1631b0f58 Resolve MaterialLib ml references in stack config entries 2026-08-17 20:18:14 -05:00
Ruling-0 eafd9ff4a3 Add MaterialLib compileOnly dependency 2026-08-17 20:18:14 -05:00
30 changed files with 116 additions and 306 deletions

No files matched your search

+1
View File
@@ -12,6 +12,7 @@ dependencies {
compileOnly('maven.modrinth:forge-essentials:7.5.1')
compileOnly('com.cardinalstar.cubicchunks:CubicChunks1710:v0.1.14-alpha:dev')
compileOnly('com.ruling_0:MaterialLib:0.24.0-mu:dev')
antlr('org.antlr:antlr4:4.13.2')
shadowImplementation('org.antlr:antlr4-runtime:4.13.2')
+1
View File
@@ -1,6 +1,7 @@
// Add any additional repositories for your dependencies here
repositories {
mavenLocal()
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
@@ -219,11 +219,6 @@ public class ItemZoom extends Widget implements IContainerInputHandler {
@Override
public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyID) {
return false;
}
@Override
public boolean onHotkeyPressed(GuiContainer gui) {
if (KeyManager.isHashDown("itemzoom.toggle", NEIClientUtils.SHIFT_HASH)) {
NEIClientConfig.getSetting("inventory.itemzoom.enabled")
+4 -46
View File
@@ -4,7 +4,6 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.StringJoiner;
import java.util.function.BooleanSupplier;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
@@ -30,7 +29,6 @@ public class KeyManager {
private static final Map<String, KeyBinding> keyBindings = new HashMap<>();
private static final Map<String, String> keyAliases = new HashMap<>();
private static volatile boolean pendingOptionsReload = false;
private static int clickedButton = -1;
static {
// Aliases for legacy keybinds
@@ -75,8 +73,7 @@ public class KeyManager {
final int keyCode = binding.getKeyCode();
if (keyCode < 0) {
final int button = keyCode + 100;
return Mouse.isButtonDown(button) || button == clickedButton;
return Mouse.isButtonDown(keyCode + 100);
} else if (keyCode > Keyboard.KEY_NONE && keyCode < Keyboard.KEYBOARD_SIZE) {
return Keyboard.isKeyDown(keyCode);
}
@@ -85,40 +82,6 @@ public class KeyManager {
return false;
}
/**
* Whether any NEI key binding is assigned to the given mouse button.
*/
public static boolean isMouseBound(int button) {
for (KeyBinding binding : keyBindings.values()) {
if (binding.getKeyCode() == button - 100) {
return true;
}
}
return false;
}
/**
* Runs a hotkey handler for a click of the given mouse button if the button is bound to any NEI key binding. The
* button is reported as down by {@link #isKeyDown} for the duration of the call, because the LWJGL button state can
* already be released when a quick click is processed.
*
* @return true if the click was consumed by the handler
*/
public static boolean handleMouseHotkey(int button, BooleanSupplier handler) {
if (!isMouseBound(button)) {
return false;
}
final int previous = clickedButton;
clickedButton = button;
try {
return handler.getAsBoolean();
} finally {
clickedButton = previous;
}
}
public static boolean isHashDown(String ident) {
return isHashDown(ident, 0);
}
@@ -144,23 +107,18 @@ public class KeyManager {
public static String getKeyName(String ident, int meta) {
final int keyCode = getKeyCode(ident);
return keyCode == Keyboard.KEY_NONE ? null : NEIKeyboardUtils.getKeyName(keyCode, meta);
return keyCode == Keyboard.KEY_NONE ? null : NEIKeyboardUtils.getKeyName(keyCode + meta);
}
public static String getKeyName(String ident, int meta, int mouseBind) {
final int keyCode = getKeyCode(ident);
return keyCode == Keyboard.KEY_NONE && mouseBind == NEIMouseUtils.MOUSE_BTN_NONE ? null
: getKeyName(keyCode, meta, mouseBind);
: getKeyName(keyCode + meta, mouseBind);
}
public static String getKeyName(int keyBind, int mouseBind) {
final int keyCode = NEIKeyboardUtils.unhash(keyBind);
return getKeyName(keyCode, keyBind - keyCode, mouseBind);
}
private static String getKeyName(int keyCode, int hash, int mouseBind) {
StringJoiner keyText = new StringJoiner(" + ");
String keyHash = keyCode == Keyboard.KEY_NONE && hash == 0 ? "" : NEIKeyboardUtils.getKeyName(keyCode, hash);
String keyHash = keyBind == Keyboard.KEY_NONE ? "" : NEIKeyboardUtils.getKeyName(keyBind);
String mouseHash = mouseBind == NEIMouseUtils.MOUSE_BTN_NONE ? "" : NEIMouseUtils.getKeyName(mouseBind);
if (!keyHash.isEmpty()) {
@@ -220,20 +220,6 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
@Override
public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyID) {
if (isEnabled() && !isHidden()) {
for (Widget widget : controlWidgets) {
if (inputFocused == null) {
widget.lastKeyTyped(keyID, keyChar);
}
}
}
return false;
}
@Override
public boolean onHotkeyPressed(GuiContainer gui) {
if (KeyManager.isKeyDown("gui.hide")) {
toggleBooleanSetting("inventory.hidden");
return true;
@@ -248,12 +234,8 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
return true;
}
if (isEnabled() && !isHidden() && inputFocused == null) {
for (Widget widget : controlWidgets) {
if (widget.onHotkeyPressed()) {
return true;
}
}
if (isEnabled() && !isHidden()) {
for (Widget widget : controlWidgets) if (inputFocused == null) widget.lastKeyTyped(keyID, keyChar);
}
return false;
@@ -14,11 +14,13 @@ import com.google.common.eventbus.Subscribe;
import codechicken.core.CommonUtils;
import codechicken.core.launch.CodeChickenCorePlugin;
import codechicken.nei.api.API;
import codechicken.nei.api.IConfigureNEI;
import codechicken.nei.asm.NEICorePlugin;
import codechicken.nei.config.IMCHandler;
import codechicken.nei.guihook.HideousLinkedList;
import codechicken.nei.recipe.GuiRecipeTab;
import codechicken.nei.recipe.stackinfo.MaterialLibStackStringifyHandler;
import cpw.mods.fml.client.FMLFileResourcePack;
import cpw.mods.fml.client.FMLFolderResourcePack;
import cpw.mods.fml.common.DummyModContainer;
@@ -114,6 +116,10 @@ public class NEIModContainer extends DummyModContainer {
IMCForNEI.IMCSender();
}
ServerHandler.load();
if (Loader.isModLoaded("materiallib")) {
API.registerStackStringifyHandler(new MaterialLibStackStringifyHandler());
}
}
@Subscribe
@@ -305,7 +305,7 @@ public abstract class PanelWidget<T extends ItemsGrid<? extends ItemsGridSlot, ?
}
@Override
public boolean onHotkeyPressed() {
public boolean handleKeyPress(int keyID, char keyChar) {
final Point mouse = GuiDraw.getMousePosition();
if (!contains(mouse.x, mouse.y)) return false;
@@ -23,11 +23,6 @@ public class PopupInputHandler implements IContainerInputHandler {
@Override
public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyID) {
return false;
}
@Override
public boolean onHotkeyPressed(GuiContainer gui) {
if (KeyManager.isHashDown("gui.enchant") && canPerformAction("enchant")) {
NEICPH.sendOpenEnchantmentWindow();
@@ -48,19 +48,15 @@ public abstract class RecipeSearchField extends TextField implements ItemFilterP
}
@Override
public boolean onHotkeyPressed() {
public void lastKeyTyped(int keyID, char keyChar) {
if (focused() && KeyManager.isKeyDown("gui.getprevioussearch")) {
handleNavigateHistory(TextHistory.Direction.PREVIOUS);
return true;
}
if (focused() && KeyManager.isKeyDown("gui.getnextsearch")) {
handleNavigateHistory(TextHistory.Direction.NEXT);
return true;
}
return false;
}
@Override
@@ -227,24 +227,18 @@ public class SearchField extends TextField implements ItemFilterProvider {
}
@Override
public boolean onHotkeyPressed() {
public void lastKeyTyped(int keyID, char keyChar) {
if (isVisible() && KeyManager.isHashDown("gui.search")) {
setFocus(true);
return true;
}
if (focused() && KeyManager.isKeyDown("gui.getprevioussearch")) {
handleNavigateHistory(TextHistory.Direction.PREVIOUS);
return true;
}
if (focused() && KeyManager.isKeyDown("gui.getnextsearch")) {
handleNavigateHistory(TextHistory.Direction.NEXT);
return true;
}
return false;
}
@Override
@@ -9,6 +9,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -541,14 +542,22 @@ public class SubsetWidget extends Button implements ItemFilterProvider {
return;
}
final AtomicInteger resolved = new AtomicInteger();
final AtomicInteger invalid = new AtomicInteger();
Stream.of(dir.listFiles()).filter(file -> !file.isDirectory()).forEach(file -> {
ClientHandler.loadSettingsFile(
"subsets/" + file.getName(),
lines -> parseFile(file.getName(), lines.collect(Collectors.toList())));
lines -> parseFile(file.getName(), lines.collect(Collectors.toList()), resolved, invalid));
});
if (resolved.get() + invalid.get() > 0) {
NEIClientConfig.logger.info("Resolved {} MaterialLib entries ({} invalid)", resolved.get(), invalid.get());
}
}
private static void parseFile(String resource, List<String> itemStrings) {
private static void parseFile(String resource, List<String> itemStrings, AtomicInteger resolved,
AtomicInteger invalid) {
final JsonParser parser = new JsonParser();
final int dotIndex = resource.lastIndexOf('.');
final String subsetNamespace = dotIndex > 0 ? resource.substring(0, dotIndex) : resource;
@@ -578,7 +587,13 @@ public class SubsetWidget extends Button implements ItemFilterProvider {
final NBTBase nbt = NBTJson.toNbt(parser.parse(itemStr));
if (nbt instanceof NBTTagCompound tag) {
((ItemStackSet) processedTag.filter).add(StackInfo.loadFromNBT(tag));
final ItemStack stack = StackInfo.loadFromNBT(tag);
if (tag.getString("strId").startsWith(StackInfo.MATERIALLIB_PREFIX)) {
(stack != null ? resolved : invalid).incrementAndGet();
}
((ItemStackSet) processedTag.filter).add(stack);
} else {
throw new IllegalArgumentException(
"Expected NBTTagCompound but got " + nbt.getClass().getSimpleName());
@@ -29,10 +29,6 @@ public abstract class Widget {
public void lastKeyTyped(int keyID, char keyChar) {}
public boolean onHotkeyPressed() {
return false;
}
public boolean handleClickExt(int mx, int my, int button) {
return false;
}
@@ -162,19 +162,6 @@ public class WidgetContainer extends Widget {
}
@Override
public boolean onHotkeyPressed() {
for (int index = this.widgets.size() - 1; index >= 0; index--) {
final Widget widget = this.widgets.get(index);
if (widget.onHotkeyPressed()) {
return true;
}
}
return false;
}
@Override
public boolean isFocused() {
return this.isFocused;
@@ -58,7 +58,6 @@ import codechicken.nei.drawable.DrawableResource;
import codechicken.nei.guihook.IContainerTooltipHandler;
import codechicken.nei.guihook.IGuiClientSide;
import codechicken.nei.guihook.IGuiHandleMouseWheel;
import codechicken.nei.guihook.IGuiHotkeyListener;
import codechicken.nei.recipe.AcceptsFollowingTooltipLineHandler;
import codechicken.nei.recipe.AutoCraftingManager;
import codechicken.nei.recipe.GuiCraftingRecipe;
@@ -78,7 +77,7 @@ import codechicken.nei.util.SlotInaccessible;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
public class GuiCraftingTree extends GuiContainer implements INEIGuiHandler, IGuiClientSide, IGuiHandleMouseWheel,
IGuiHotkeyListener, IContainerTooltipHandler, IGuiContainerOverlay {
IContainerTooltipHandler, IGuiContainerOverlay {
public static class EventHandler {
@@ -912,12 +911,6 @@ public class GuiCraftingTree extends GuiContainer implements INEIGuiHandler, IGu
return;
}
super.keyTyped(typedChar, keyCode);
}
@Override
public boolean onHotkeyPressed() {
if (this.statsPanelVisible && KeyManager.isKeyDown("recipe.recipe")) {
final Point2D mouse = getMousePosition();
final Widget widget = this.statsPanel.getWidgetUnderMouse((int) mouse.getX(), (int) mouse.getY());
@@ -925,11 +918,11 @@ public class GuiCraftingTree extends GuiContainer implements INEIGuiHandler, IGu
if (widget != null && widget instanceof StatsPanel.ItemStatsSlot itemStatsSlot
&& itemStatsSlot.recipeId != null) {
GuiCraftingRecipe.openRecipeGui("recipeId", itemStatsSlot.recipeId.getResult(), itemStatsSlot.recipeId);
return true;
return;
}
}
return false;
super.keyTyped(typedChar, keyCode);
}
private String getHandlerTitle(String handlerName) {
@@ -79,24 +79,19 @@ public class RightPanel extends GuiWidget {
}
@Override
public boolean onHotkeyPressed() {
public void lastKeyTyped(int keyID, char keyChar) {
if (!focused() && KeyManager.isHashDown("gui.search")) {
setFocus(true);
return true;
}
if (focused() && KeyManager.isKeyDown("gui.getprevioussearch")) {
handleNavigateHistory(TextHistory.Direction.PREVIOUS);
return true;
}
if (focused() && KeyManager.isKeyDown("gui.getnextsearch")) {
handleNavigateHistory(TextHistory.Direction.NEXT);
return true;
}
return false;
}
@Override
@@ -449,7 +449,6 @@ public class GuiContainerManager {
}
private int clickHandled = 0;
private int hotkeyHandled = 0;
public final List<IContainerTooltipHandler> instanceTooltipHandlers;
public GuiContainerManager(GuiContainer screen) {
@@ -484,7 +483,6 @@ public class GuiContainerManager {
public void load() {
clickHandled = 0;
hotkeyHandled = 0;
for (IContainerObjectHandler objectHandler : objectHandlers) objectHandler.load(window);
}
@@ -504,46 +502,6 @@ public class GuiContainerManager {
for (IContainerInputHandler inputhander : inputHandlers)
if (inputhander.lastKeyTyped(window, keyChar, keyID)) return true;
return onHotkeyPressed();
}
public boolean onHotkeyPressed() {
if (window instanceof IGuiHotkeyListener && ((IGuiHotkeyListener) window).onHotkeyPressed()) {
return true;
}
for (IContainerInputHandler inputhander : inputHandlers) {
if (inputhander.onHotkeyPressed(window)) {
return true;
}
}
return window instanceof IGuiHotkeyListener && ((IGuiHotkeyListener) window).onScreenHotkeyPressed();
}
public boolean handleMouseHotkey() {
final int button = Mouse.getEventButton();
if (button < 0) {
return false;
}
if (!Mouse.getEventButtonState()) {
// the press has been consumed, so the release must not reach the screen either
if ((hotkeyHandled & 1 << button) == 0) {
return false;
}
hotkeyHandled &= ~(1 << button);
return true;
}
if (KeyManager.handleMouseHotkey(button, this::onHotkeyPressed)) {
hotkeyHandled |= 1 << button;
return true;
}
return false;
}
@@ -36,18 +36,6 @@ public interface IContainerInputHandler {
*/
public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyID);
/**
* Called when a key or a mouse button is pressed and the event has not been handled by the first pass. Use this for
* key bindings that work globally and check them with {@link codechicken.nei.KeyManager#isKeyDown}, so they work
* the same for keyboard keys and mouse buttons.
*
* @param gui An instance of the currentscreen
* @return true to terminate further processing of this event.
*/
default boolean onHotkeyPressed(GuiContainer gui) {
return false;
}
/**
* Called when the mouse is clicked in the gui
*
@@ -1,27 +0,0 @@
package codechicken.nei.guihook;
/**
* Interface for GuiContainers to receive NEI compatible hotkey events from both keyboard keys and mouse buttons
*/
public interface IGuiHotkeyListener {
/**
* Called before the input handlers when a key or a mouse button is pressed, check key bindings with
* {@link codechicken.nei.KeyManager#isKeyDown}
*
* @return true to terminate further processing of this event.
*/
default boolean onHotkeyPressed() {
return false;
}
/**
* Called after the input handlers for screen-wide hotkeys that do not depend on the hovered object, so they never
* take priority over more specific actions
*
* @return true to terminate further processing of this event.
*/
default boolean onScreenHotkeyPressed() {
return false;
}
}
@@ -122,25 +122,18 @@ public class GuiFavoriteButton extends GuiRecipeButton {
return Recipe.of(this.handlerRef);
}
@Override
public void lastKeyTyped(char keyChar, int keyID) {}
@Override
public boolean onHotkeyPressed() {
public void lastKeyTyped(char keyChar, int keyID) {
if (KeyManager.isKeyDown("bookmark.add") && NEIClientUtils.shiftKey()) {
saveRecipeInBookmark();
return true;
}
if (KeyManager.isKeyDown("bookmark.open_crafting_tree") && NEIClientUtils.shiftKey()
&& saveRecipeInBookmark()) {
final int groupId = ItemPanels.bookmarkPanel.getGrid().getNextGroupId() - 1;
GuiCraftingTree.openCraftingTreeGui(ItemPanels.bookmarkPanel.getGrid(), groupId);
return true;
}
return false;
}
@Override
@@ -346,21 +346,14 @@ public class GuiOverlayButton extends GuiRecipeButton {
}
@Override
public void lastKeyTyped(char keyChar, int keyID) {}
@Override
public boolean onHotkeyPressed() {
public void lastKeyTyped(char keyChar, int keyID) {
if (KeyManager.isKeyDown("bookmark.add") && NEIClientUtils.shiftKey()) {
saveRecipeInBookmark();
return true;
}
if (KeyManager.isKeyDown("bookmark.chat_link") && NEIClientUtils.controlKey() && NEIClientUtils.shiftKey()) {
sendRecipeChatLink();
return true;
}
return false;
}
public void saveRecipeInBookmark() {
@@ -51,7 +51,6 @@ import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.guihook.IContainerTooltipHandler;
import codechicken.nei.guihook.IGuiClientSide;
import codechicken.nei.guihook.IGuiHandleMouseWheel;
import codechicken.nei.guihook.IGuiHotkeyListener;
import codechicken.nei.recipe.Recipe.RecipeId;
import codechicken.nei.recipe.widget.RecipeWidget;
import codechicken.nei.scroll.ScrollBar;
@@ -63,7 +62,7 @@ import codechicken.nei.util.EmptyContainer;
import codechicken.nei.util.SlotInaccessible;
public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer implements IGuiContainerOverlay,
IGuiClientSide, IGuiHandleMouseWheel, IGuiHotkeyListener, IContainerTooltipHandler, INEIGuiHandler {
IGuiClientSide, IGuiHandleMouseWheel, IContainerTooltipHandler, INEIGuiHandler {
private static final int BORDER_PADDING = 5;
private static final int TRANSPARENCY_BORDER = 4;
@@ -698,7 +697,6 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
if (GuiRecipe.searchField.isVisible() && GuiRecipe.searchField.focused()) {
GuiRecipe.searchField.lastKeyTyped(i, c);
GuiRecipe.searchField.onHotkeyPressed();
return;
}
@@ -723,24 +721,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
if (i == mc.gameSettings.keyBindInventory.getKeyCode()) {
this.mc.displayGuiScreen(getFirstScreenGeneral());
NEICPH.sendRequestContainer();
}
}
@Override
public boolean onHotkeyPressed() {
if (GuiRecipe.searchField.isVisible() && GuiRecipe.searchField.onHotkeyPressed()
|| this.recipeCatalyst.isShowWidget() && this.recipeCatalyst.onHotkeyPressed()
|| this.container.onHotkeyPressed()) {
return true;
}
return false;
}
@Override
public boolean onScreenHotkeyPressed() {
if (KeyManager.isKeyDown("recipe.back")) {
} else if (KeyManager.isKeyDown("recipe.back")) {
this.mc.displayGuiScreen(this.prevGui);
} else if (KeyManager.isKeyDown("recipe.prev_machine")) {
prevType();
@@ -750,11 +731,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
prevPage();
} else if (KeyManager.isKeyDown("recipe.next_recipe")) {
nextPage();
} else {
return false;
}
return true;
}
@Override
@@ -64,10 +64,6 @@ public abstract class GuiRecipeButton extends GuiNEIButton {
public abstract void lastKeyTyped(char keyChar, int keyID);
public boolean onHotkeyPressed() {
return false;
}
public abstract void drawItemOverlay();
public void update() {
@@ -29,11 +29,6 @@ public class RecipeItemInputHandler implements IContainerInputHandler, IContaine
@Override
public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyCode) {
return false;
}
@Override
public boolean onHotkeyPressed(GuiContainer gui) {
return ShortcutInputHandler.handleKeyEvent(GuiContainerManager.getStackMouseOver(gui));
}
@@ -28,6 +28,10 @@ import codechicken.nei.util.NBTHelper;
public class StackInfo {
/// Prefix of the MaterialLib reference form `ml:<MaterialName>:<shapeToken>`, which config entries carry in
/// place of an id and metadata.
public static final String MATERIALLIB_PREFIX = "ml:";
private static final FluidStack NULL_FLUID = new FluidStack(FluidRegistry.WATER, 0);
public static final List<IStackStringifyHandler> stackStringifyHandlers = new ArrayList<>();
private static final Map<String, HashMap<String, String[]>> guidfilters = new HashMap<>();
@@ -287,11 +287,6 @@ public abstract class TemplateRecipeHandler implements ICraftingHandler, IUsageH
@Override
public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyCode) {
return false;
}
@Override
public boolean onHotkeyPressed(GuiContainer gui) {
if (!canHandle(gui)) return false;
if (KeyManager.isKeyDown("recipe.recipe")) {
@@ -512,11 +512,6 @@ public class DebugHandlerWidget extends Widget implements IContainerTooltipHandl
return false;
}
@Override
public boolean onHotkeyPressed() {
return this.record != null && this.container.onHotkeyPressed();
}
@Override
public void onGuiClick(int mx, int my) {
if (this.record != null) {
@@ -0,0 +1,43 @@
package codechicken.nei.recipe.stackinfo;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import com.ruling_0.materiallib.api.StackResolver;
import codechicken.nei.api.IStackStringifyHandler;
import codechicken.nei.recipe.StackInfo;
/// Resolves config entries written in the MaterialLib reference form `ml:<MaterialName>:<shapeToken>` (see
/// [StackInfo#MATERIALLIB_PREFIX]) through [StackResolver], so an entry keeps naming the same item across sessions
/// that renumber item metadata. The resolved stack carries the metadata MaterialLib currently assigns, ignoring any
/// `Damage` on the entry. Entries in any other form are left to the other handlers.
///
/// Registered only behind a `Loader.isModLoaded("materiallib")` gate, so this class never classloads without
/// MaterialLib present.
public class MaterialLibStackStringifyHandler implements IStackStringifyHandler {
@Override
public ItemStack convertNBTToItemStack(NBTTagCompound nbtTag) {
final String strId = nbtTag.getString("strId");
if (!strId.startsWith(StackInfo.MATERIALLIB_PREFIX)) {
return null;
}
final String[] parts = strId.split(":");
if (parts.length != 3) {
return null;
}
final ItemStack stack = StackResolver.getStack(parts[1], parts[2], nbtTag.getInteger("Count"));
if (stack != null && nbtTag.hasKey("tag")) {
stack.setTagCompound((NBTTagCompound) nbtTag.getCompoundTag("tag").copy());
}
return stack;
}
}
@@ -456,6 +456,25 @@ public class RecipeWidget extends Widget {
}
}
@Override
public boolean handleKeyPress(int keyID, char keyChar) {
if (NEIClientConfig.favoritesEnabled()
&& KeyManager.isHashDown("bookmark.favorite_item", NEIClientUtils.SHIFT_HASH)) {
final Point mouse = GuiDraw.getMousePosition();
final PositionedStack hovered = getCyclingStackMouseOver(mouse.x, mouse.y);
if (hovered != null && getPermutations(hovered).size() > 1) {
FavoriteRecipes.toggleFavoriteItem(hovered.item);
setPaused(false);
return true;
}
}
return false;
}
@Override
public void lastKeyTyped(int keyID, char keyChar) {
final Point mouse = GuiDraw.getMousePosition();
@@ -471,27 +490,6 @@ public class RecipeWidget extends Widget {
}
@Override
public boolean onHotkeyPressed() {
final Point mouse = GuiDraw.getMousePosition();
if (NEIClientConfig.favoritesEnabled()
&& KeyManager.isHashDown("bookmark.favorite_item", NEIClientUtils.SHIFT_HASH)) {
final PositionedStack hovered = getCyclingStackMouseOver(mouse.x, mouse.y);
if (hovered != null && getPermutations(hovered).size() > 1) {
FavoriteRecipes.toggleFavoriteItem(hovered.item);
setPaused(false);
return true;
}
}
return forEachButtons(
button -> button.contains(mouse.x, mouse.y) && button.onHotkeyPressed() ? true : null,
false);
}
@Override
public boolean handleClick(int mouseX, int mouseY, int button) {
@@ -56,24 +56,18 @@ public class NEIKeyboardUtils {
return keyText.toString();
}
/**
* Mouse buttons are negative key codes, so the hash can not be packed into them and is passed separately.
*/
public static String getKeyName(int keyCode, int hash) {
if (hash == 0 && keyHashMap.containsKey(keyCode)) {
hash = keyHashMap.get(keyCode);
keyCode = Keyboard.CHAR_NONE;
}
final StringJoiner keyText = new StringJoiner(" + ");
final String hashText = getHashName(hash);
public static String getKeyName(int keyBind) {
keyBind = keyHashMap.getOrDefault(keyBind, keyBind);
StringJoiner keyText = new StringJoiner(" + ");
String hashText = getHashName(keyBind);
int keyID = unhash(keyBind);
if (!hashText.isEmpty()) {
keyText.add(hashText);
}
if (keyCode != Keyboard.CHAR_NONE || hashText.isEmpty()) {
keyText.add(keyCode < 0 ? NEIMouseUtils.getKeyName(keyCode + 100) : Keyboard.getKeyName(keyCode));
if (keyID != Keyboard.CHAR_NONE || hashText.isEmpty()) {
keyText.add(keyID < 0 ? NEIMouseUtils.getKeyName(keyID + 100) : Keyboard.getKeyName(keyID));
}
return keyText.toString();
@@ -121,12 +121,6 @@ RETURN
list m_handleMouseInput
ALOAD 0
GETFIELD net/minecraft/client/gui/inventory/GuiContainer.manager : Lcodechicken/nei/guihook/GuiContainerManager;
INVOKEVIRTUAL codechicken/nei/guihook/GuiContainerManager.handleMouseHotkey ()Z
IFEQ LCONT
RETURN
LCONT
ALOAD 0
INVOKESPECIAL net/minecraft/client/gui/GuiScreen.func_146274_d ()V
ALOAD 0
GETFIELD net/minecraft/client/gui/inventory/GuiContainer.manager : Lcodechicken/nei/guihook/GuiContainerManager;