Compare commits

..
Author SHA1 Message Date
4f42175b56 Move shared button and scrollbar textures to UIWidgetTexture (#1158) (#1163)
Co-authored-by: slprime <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-11-24 22:07:53 +01:00
boubou19andslprime 292c68ef44 Rebuild recipe catalysts only when something changes (#1157) (#1162)
Co-authored-by: slprime <[email protected]>
2026-11-24 22:07:32 +01:00
2326460ac0 Clear bookmark group tooltip when pulling items or changing quantities (#1152) (#1161)
Co-authored-by: gorbit99 <[email protected]>
Co-authored-by: slprime <[email protected]>
2026-11-24 22:06:58 +01:00
boubou19andOrderedSet86 8731ae82f2 Less hacky fix for light opacity 0 blocks (#1124) (#1148)
Co-authored-by: OrderedSet86 <[email protected]>
2026-11-20 21:38:44 +01:00
boubou19andgorbit99 558449ca99 Change layout recalculation order (#1125) (#1147)
Co-authored-by: gorbit99 <[email protected]>
2026-11-20 21:34:18 +01:00
boubou19andslprime 7fc80371c7 Copy fluid registry name instead of the display item id (#1122) (#1145)
Co-authored-by: slprime <[email protected]>
2026-11-19 08:17:47 +01:00
f5f696abba Add NEI mob spawn overlay variants (#1111) (#1144)
Co-authored-by: OrderedSet86 <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Martin Robertz <[email protected]>
2026-11-19 08:15:31 +01:00
boubou19andslprime 277c32b9e6 Don't toggle handler info widget while typing in recipe search (#1121) (#1143)
Co-authored-by: slprime <[email protected]>
2026-11-19 08:13:15 +01:00
boubou19andslprime fbb0cdc81a Add recipe text search with ~ prefix (#1120) (#1142)
Co-authored-by: slprime <[email protected]>
2026-11-19 08:11:11 +01:00
boubou19andslprime 991e166e0a Speed up GUID cache and bookmark recipe lookups (#1119) (#1141)
Co-authored-by: slprime <[email protected]>
2026-11-19 08:08:48 +01:00
d298c0e827 Don't copy stack unless it changed (#1116) (#1140)
Co-authored-by: DarkShadow44 <[email protected]>
Co-authored-by: slprime <[email protected]>
2026-11-19 08:06:32 +01:00
boubou19andslprime da16b40f36 Optimize GUI overlap scan for item panels (#1118) (#1139)
Co-authored-by: slprime <[email protected]>
2026-11-19 08:02:56 +01:00
boubou19andslprime 651b59cba9 Fix WorldClient leak after leaving the world (#1115) (#1138)
Co-authored-by: slprime <[email protected]>
2026-11-19 08:00:50 +01:00
boubou19andslprime f922d7ef1e Make name optional in API.addCollapsibleGroup (#1114) (#1137)
Co-authored-by: slprime <[email protected]>
2026-11-19 07:57:05 +01:00
boubou19andslprime 52ad6f38a5 Add API.addCollapsibleGroup for registering collapsible item groups (#1113) (#1136)
Co-authored-by: slprime <[email protected]>
2026-11-19 07:52:58 +01:00
boubou19andslprime 8d118cb132 Rollback fluent setters in PositionedStack added in #1106 (#1110) (#1135)
Co-authored-by: slprime <[email protected]>
2026-11-19 07:50:30 +01:00
boubou19andslprime 2590eec44a Fix NPE in StackInfo.getItemStackWithMinimumDamage for unregistered items (#1109) (#1134)
Co-authored-by: slprime <[email protected]>
2026-11-19 07:48:46 +01:00
boubou19andslprime 81a92a28f5 Remove creative tab style option for recipe tabs (#1107) (#1133)
Co-authored-by: slprime <[email protected]>
2026-11-19 07:46:47 +01:00
boubou19andslprime 621ab621c7 Move RecipeTransferRectHandler out of TemplateRecipeHandler and tidy up PositionedStack (#1106) (#1132)
Co-authored-by: slprime <[email protected]>
2026-11-19 07:44:56 +01:00
boubou19andslprime 1aa4d56100 Add getResultStacks/getAuxiliaryStacks to IRecipeHandler (#1105) (#1131)
Co-authored-by: slprime <[email protected]>
2026-11-19 07:42:56 +01:00
boubou19andslprime dc35985ea0 Stop auto-creating NEI config files, add export buttons instead (#1104) (#1130)
Co-authored-by: slprime <[email protected]>
2026-11-19 07:40:46 +01:00
boubou19andslprime bb8632a012 Fix ConcurrentModificationException when iterating the crafting recipe list (#1103) (#1129)
Co-authored-by: slprime <[email protected]>
2026-11-19 07:38:03 +01:00
b361604422 Remove per-world config override (#1094) (#1128)
Co-authored-by: slprime <[email protected]>
Co-authored-by: Martin Robertz <[email protected]>
2026-11-19 07:35:55 +01:00
boubou19andslprime 02c97a05c3 Remove hardcoded vanilla block name overrides (#1102) (#1127)
Co-authored-by: slprime <[email protected]>
2026-11-19 07:33:11 +01:00
boubou19andArmisael5 d0785b5261 Add NEI Recipe Exporting (#1100) (#1126)
Co-authored-by: Armisael5 <[email protected]>
2026-11-19 07:31:13 +01:00
UltraProdigy 52ae4b2bd4 ci: run build and test on release branches 2026-11-09 01:11:41 -05:00
slprime acacd13bd9 Fix autocraft crash when started from the recipe screen (#1108) 2026-11-06 00:31:19 +02:00
11 changed files with 88 additions and 117 deletions

No files matched your search

@@ -18,6 +18,7 @@ import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.ItemsGrid.ItemsGridSlot;
import codechicken.nei.ItemsGrid.MouseContext;
import codechicken.nei.NEIClientUtils.Alignment;
import codechicken.nei.recipe.AutoCraftingManager;
import codechicken.nei.recipe.GuiCraftingRecipe;
import codechicken.nei.recipe.GuiRecipe;
import codechicken.nei.recipe.ICraftingHandler;
@@ -267,7 +268,7 @@ public class ItemCraftablesPanel
if (firstGui != null && !ItemCraftablesPanel.guiBlacklist.contains(firstGui.getClass().getName())) {
final boolean showOnlyFavorites = NEIClientConfig
.getBooleanSetting("inventory.craftables.favoritesOnly");
final ItemStackAmount inv = ItemStackAmount.of(firstGui);
final ItemStackAmount inv = AutoCraftingManager.getInventoryItems(firstGui);
if (this.lastGuiContainer != firstGui
|| showOnlyFavorites && this.lastFavoritesCount != FavoriteRecipes.size()
@@ -316,7 +317,7 @@ public class ItemCraftablesPanel
final Map<ItemStack, RecipeId> availableRecipes = new HashMap<>();
if (!availableHandlers.isEmpty()) {
final Map<Item, List<ItemStack>> invByItem = snapshot.inventory.groupByItem();
final Map<Item, List<ItemStack>> invByItem = indexInventoryByItem(snapshot.inventory.values());
if (snapshot.showOnlyFavorites) {
for (IRecipeHandler handler : availableHandlers) {
@@ -348,6 +349,16 @@ public class ItemCraftablesPanel
return availableHandlers;
}
private static Map<Item, List<ItemStack>> indexInventoryByItem(List<ItemStack> invStacks) {
final Map<Item, List<ItemStack>> index = new HashMap<>();
for (ItemStack stack : invStacks) {
index.computeIfAbsent(stack.getItem(), i -> new ArrayList<>()).add(stack);
}
return index;
}
private void collectHandlerCandidates(IRecipeHandler handler, Map<Item, List<ItemStack>> invByItem,
List<RecipeCandidate> candidates) {
IntStream.range(0, handler.numRecipes()).parallel().forEach(recipeIndex -> {
@@ -437,8 +448,36 @@ public class ItemCraftablesPanel
return availableRecipes;
}
private static boolean existsIngredients(List<PositionedStack> ingredients, Map<Item, List<ItemStack>> invByItem) {
return !ingredients.isEmpty() && NEIClientUtils.countMissingIngredients(ingredients, invByItem, 1) == 0;
private boolean existsIngredients(List<PositionedStack> ingredients, Map<Item, List<ItemStack>> invByItem) {
final Map<ItemStack, Integer> usedItems = new HashMap<>();
for (PositionedStack pStack : ingredients) {
ItemStack used = null;
for (ItemStack permutation : pStack.items) {
final List<ItemStack> candidates = invByItem.get(permutation.getItem());
if (candidates == null) continue;
for (ItemStack is : candidates) {
if (usedItems.getOrDefault(is, is.stackSize) >= pStack.item.stackSize
&& NEIServerUtils.areStacksSameTypeCrafting(permutation, is)) {
used = is;
break;
}
}
if (used != null) break;
}
if (used != null) {
usedItems.put(used, usedItems.getOrDefault(used, used.stackSize) - pStack.item.stackSize);
} else {
return false;
}
}
return !usedItems.isEmpty();
}
}
@@ -1,17 +1,12 @@
package codechicken.nei;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Slot;
import net.minecraft.inventory.SlotCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -101,16 +96,6 @@ public class ItemStackAmount {
return list;
}
public Map<Item, List<ItemStack>> groupByItem() {
final Map<Item, List<ItemStack>> groups = new HashMap<>();
for (ItemStack stack : values()) {
groups.computeIfAbsent(stack.getItem(), i -> new ArrayList<>()).add(stack);
}
return groups;
}
public int size() {
return this.itemMap.size();
}
@@ -155,16 +140,4 @@ public class ItemStackAmount {
return result;
}
public static ItemStackAmount of(GuiContainer gui) {
final ItemStackAmount result = new ItemStackAmount();
for (Slot slot : gui.inventorySlots.inventorySlots) {
if (slot.getHasStack() && !(slot instanceof SlotCrafting) && slot.canTakeStack(gui.mc.thePlayer)) {
result.add(slot.getStack());
}
}
return result;
}
}
+17 -36
View File
@@ -5,7 +5,6 @@ import java.util.LinkedList;
import java.util.Map;
import java.util.StringJoiner;
import java.util.function.BooleanSupplier;
import java.util.function.Supplier;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
@@ -31,9 +30,7 @@ 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 final int NO_INPUT_EVENT = Integer.MIN_VALUE;
private static int currentEvent = NO_INPUT_EVENT;
private static int clickedButton = -1;
static {
// Aliases for legacy keybinds
@@ -73,22 +70,16 @@ public class KeyManager {
public static boolean isKeyDown(String ident) {
final KeyBinding binding = getKeyBinding(ident);
if (binding == null) {
return false;
}
final int keyCode = binding.getKeyCode();
if (currentEvent != NO_INPUT_EVENT) {
return keyCode == currentEvent;
}
if (binding != null) {
final int keyCode = binding.getKeyCode();
if (keyCode < 0) {
final int button = keyCode + 100;
return Mouse.isButtonDown(button);
}
if (keyCode > Keyboard.KEY_NONE && keyCode < Keyboard.KEYBOARD_SIZE) {
return Keyboard.isKeyDown(keyCode);
if (keyCode < 0) {
final int button = keyCode + 100;
return Mouse.isButtonDown(button) || button == clickedButton;
} else if (keyCode > Keyboard.KEY_NONE && keyCode < Keyboard.KEYBOARD_SIZE) {
return Keyboard.isKeyDown(keyCode);
}
}
return false;
@@ -106,23 +97,6 @@ public class KeyManager {
return false;
}
private static <T> T withEvent(int code, Supplier<T> handler) {
final int previous = currentEvent;
currentEvent = code;
try {
return handler.get();
} finally {
currentEvent = previous;
}
}
public static void handleKeyEvent(int keyCode, Runnable handler) {
withEvent(keyCode, () -> {
handler.run();
return null;
});
}
/**
* 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
@@ -135,7 +109,14 @@ public class KeyManager {
return false;
}
return withEvent(button - 100, handler::getAsBoolean);
final int previous = clickedButton;
clickedButton = button;
try {
return handler.getAsBoolean();
} finally {
clickedButton = previous;
}
}
public static boolean isHashDown(String ident) {
@@ -538,40 +538,6 @@ public class NEIClientUtils extends NEIServerUtils {
return null;
}
public static int countMissingIngredients(List<PositionedStack> ingredients, Map<Item, List<ItemStack>> index,
int limit) {
Map<ItemStack, Integer> usedItems = new HashMap<>();
int missing = 0;
for (PositionedStack pStack : ingredients) {
ItemStack used = null;
for (ItemStack permutation : pStack.items) {
final List<ItemStack> candidates = index.get(permutation.getItem());
if (candidates == null) continue;
for (ItemStack is : candidates) {
if (usedItems.getOrDefault(is, is.stackSize) >= pStack.item.stackSize
&& NEIServerUtils.areStacksSameTypeCrafting(permutation, is)) {
used = is;
break;
}
}
if (used != null) break;
}
if (used != null) {
usedItems.put(used, usedItems.getOrDefault(used, used.stackSize) - pStack.item.stackSize);
} else if (++missing >= limit) {
return missing;
}
}
return missing;
}
public static boolean altKey() {
return Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU);
}
@@ -21,7 +21,6 @@ import codechicken.nei.BookmarkContainerInfo;
import codechicken.nei.FavoriteRecipes;
import codechicken.nei.ItemPanels;
import codechicken.nei.ItemQuantityField;
import codechicken.nei.ItemStackAmount;
import codechicken.nei.KeyManager;
import codechicken.nei.LayoutManager;
import codechicken.nei.NEIClientConfig;
@@ -718,7 +717,7 @@ public abstract class ShortcutInputHandler {
private static void autocraftingIgnoreInventory(RecipeChainMath math) {
final GuiContainer guiContainer = NEIClientUtils.getGuiContainer();
final List<ItemStack> playerInventory = ItemStackAmount.of(guiContainer).values();
final List<ItemStack> playerInventory = AutoCraftingManager.getInventoryItems(guiContainer).values();
final RecipeId rootRecipeId = math.createMasterRoot();
for (int i = 0; i < math.recipeIngredients.size(); i++) {
@@ -36,7 +36,6 @@ import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.ItemStackAmount;
import codechicken.nei.KeyManager;
import codechicken.nei.LRUCache;
import codechicken.nei.NEICPH;
@@ -61,6 +60,7 @@ 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;
import codechicken.nei.recipe.GuiOverlayButton;
import codechicken.nei.recipe.GuiRecipe;
@@ -284,8 +284,10 @@ public class GuiCraftingTree extends GuiContainer implements INEIGuiHandler, IGu
final GuiContainer firstGui = getFirstScreen();
if (firstGui != null) {
for (ItemStack stack : ItemStackAmount.of(firstGui).values()) {
this.math.initialItems.add(BookmarkItem.of(-1, stack));
for (ItemStack stack : AutoCraftingManager.getInventoryItems(firstGui).values()) {
if (stack != null) {
this.math.initialItems.add(BookmarkItem.of(-1, stack));
}
}
}
}
@@ -524,7 +524,7 @@ class StatsPanel extends ScrollContainer {
public ItemStack getStackMouseOver(int mouseX, int mouseY) {
final Widget widget = getWidgetUnderMouse(mouseX, mouseY);
return widget instanceof ItemStatsSlot slot ? slot.getStack() : null;
return widget instanceof ItemStatsSlot slot && slot.recipeId == null ? slot.getStack() : null;
}
public void setHighlight(SearchResult searchResult) {
@@ -640,7 +640,7 @@ public class GuiContainerManager {
tooltip = handler.handleTooltip(window, mousex, mousey, tooltip);
}
ItemStack stack = tooltip.isEmpty() ? getStackMouseOver(window) : null;
ItemStack stack = getStackMouseOver(window);
boolean showTooltip = shouldShowTooltip(window);
if (tooltip.isEmpty() && showTooltip) { // mouseover tip, not holding an item
font = getFontRenderer(stack);
@@ -937,11 +937,9 @@ public class GuiContainerManager {
}
public void keyTyped(char c, int k) {
KeyManager.handleKeyEvent(k, () -> {
if (firstKeyTyped(c, k)) return;
if (firstKeyTyped(c, k)) return;
callKeyTyped(window, c, k);
});
callKeyTyped(window, c, k);
}
private static void callKeyTyped(GuiContainer window, char c, int k) {
@@ -32,7 +32,7 @@ public class AutoCraftingManager {
public void execute() {
final GuiContainer guiContainer = NEIClientUtils.getGuiContainer();
final ItemStack[] layout = snapshotLayout(guiContainer);
final List<BookmarkItem> initialItems = prepareInitialItems(math, ItemStackAmount.of(guiContainer));
final List<BookmarkItem> initialItems = prepareInitialItems(math, getInventoryItems(guiContainer));
boolean processed = false;
boolean changed = false;
@@ -43,7 +43,7 @@ public class AutoCraftingManager {
changed = false;
RecipeChainIterator iterator = new RecipeChainIterator(math, initialItems);
iterator.updateInventory(ItemStackAmount.of(guiContainer));
iterator.updateInventory(getInventoryItems(guiContainer));
while (iterator.hasNext() && !interrupted(guiContainer)) {
final Map<RecipeId, Long> recipes = iterator.next();
@@ -69,7 +69,7 @@ public class AutoCraftingManager {
if (craft) {
changed = true;
processed = true;
iterator.updateInventory(ItemStackAmount.of(guiContainer));
iterator.updateInventory(getInventoryItems(guiContainer));
}
}
@@ -138,6 +138,18 @@ public class AutoCraftingManager {
return AutoCraftingManager.math != null && !task.interrupted();
}
public static ItemStackAmount getInventoryItems(GuiContainer guiContainer) {
final ItemStackAmount inventory = new ItemStackAmount();
for (Slot slot : guiContainer.inventorySlots.inventorySlots) {
if (slot.getHasStack() && !(slot instanceof SlotCrafting) && slot.canTakeStack(guiContainer.mc.thePlayer)) {
inventory.add(slot.getStack());
}
}
return inventory;
}
private static ItemStack[] snapshotLayout(GuiContainer guiContainer) {
final List<Slot> slots = guiContainer.inventorySlots.inventorySlots;
final ItemStack[] layout = new ItemStack[slots.size()];
@@ -271,7 +271,7 @@ public class RecipeItemsTooltipLineHandler extends CompositeTooltipLineHandler {
}
if (screen instanceof GuiContainer container) {
return ItemStackAmount.of(container);
return AutoCraftingManager.getInventoryItems(container);
}
return new ItemStackAmount();
@@ -27,6 +27,7 @@ import codechicken.nei.NEIClientUtils;
import codechicken.nei.bookmark.BookmarkItem;
import codechicken.nei.drawable.DrawableResource;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.recipe.AutoCraftingManager;
import codechicken.nei.recipe.GuiRecipe;
import codechicken.nei.recipe.GuiRecipeTab;
import codechicken.nei.recipe.HandlerInfo;
@@ -136,7 +137,7 @@ public class RecipeChainTooltipLineHandler extends CompositeTooltipLineHandler {
final GuiContainer currentGui = NEIClientUtils.getGuiContainer();
if (this.lastShiftKey && currentGui != null && !(currentGui instanceof GuiRecipe<?>)) {
inventory.putAll(ItemStackAmount.of(currentGui));
inventory.putAll(AutoCraftingManager.getInventoryItems(currentGui));
}
if (!this.outputRecipes.isEmpty()) {