Compare commits

...
Author SHA1 Message Date
Dream Master b3a8d56077 Merge remote-tracking branch 'origin/hide-buttons' into dev 2025-07-29 14:42:40 +07:00
Dream Master 524a3957e1 Merge remote-tracking branch 'slprime/panel_positions' into dev 2025-07-29 14:42:36 +07:00
Dream Master aecc572403 Merge remote-tracking branch 'slprime/chain_custom_values' into dev 2025-07-29 14:42:31 +07:00
Ethryan 541f11a53b Merge branch 'master' into hide-buttons 2025-07-28 18:36:36 +02:00
slprime a0c5afdbd4 Change panel position algorithm 2025-07-26 11:46:04 +03:00
slprime 983e921f04 Add the ability to create a chain of items with zero 2025-07-26 11:07:06 +03:00
Dream Master ca30666d09 Merge remote-tracking branch 'slprime/favorite_hotkey' into dev 2025-07-26 12:20:14 +07:00
Dream Master 9252f27bb4 Merge remote-tracking branch 'slprime/hotkeys_option' into dev 2025-07-26 12:20:10 +07:00
Dream Master 56ebc13117 Merge branch 'master' into dev 2025-07-26 12:20:06 +07:00
slprime b207292894 Add Favorite Hotkey 2025-07-26 01:26:41 +03:00
slprime 4c58e88577 Add OPtion to Disable Hotkeys Tooltip 2025-07-26 00:07:46 +03:00
Dream Master 8c4cdd48fb Merge remote-tracking branch 'origin/hide-buttons' into dev 2025-07-24 18:57:36 +07:00
koolkrafter5 31efe27d0e Allow handlers to hide the favorite and overlay buttons via IMC 2025-07-24 01:20:44 -04:00
Dream Master f628095937 Merge remote-tracking branch 'slprime/custom_subsets' into dev 2025-07-17 22:31:57 +07:00
slprime b1178879c7 Presets: Custom Subsets Mode 2025-07-12 21:45:11 +03:00
22 changed files with 295 additions and 129 deletions

No files matched your search

@@ -305,18 +305,20 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
final RecipeId recipeId = slot.getRecipeId();
final BookmarkGroup group = slot.getGroup();
if (recipeId == null || !removeFullRecipe) {
this.grid.removeRecipe(slot.itemIndex, removeFullRecipe);
if (group.crafting != null && group.collapsed) {
if (!removeFullRecipe) {
return true;
}
this.grid.removeGroup(groupId);
return true;
}
if (group.crafting != null && group.collapsed && removeFullRecipe) {
this.grid.removeGroup(groupId);
return true;
} else if (group.crafting != null) {
if (recipeId != null && group.crafting != null) {
Set<RecipeId> recipes = group.crafting.recipeRelations.getOrDefault(recipeId, Collections.emptySet());
if (removeFullRecipe && recipes.isEmpty()) {
if (recipes.isEmpty()) {
for (Map.Entry<RecipeId, Set<RecipeId>> entry : group.crafting.recipeRelations.entrySet()) {
if (entry.getValue().contains(recipeId)) {
recipes = entry.getValue();
@@ -326,8 +328,12 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
}
if (!recipes.isEmpty()) {
boolean removed = false;
if (!removeFullRecipe) {
return true;
}
boolean removed = false;
for (RecipeId relRecipeId : recipes) {
removed = this.grid.removeRecipe(relRecipeId, groupId) || removed;
}
@@ -336,6 +342,11 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
}
}
if (recipeId == null || !removeFullRecipe) {
this.grid.removeRecipe(slot.itemIndex, removeFullRecipe);
return true;
}
return this.grid.removeRecipe(recipeId, groupId);
}
@@ -435,7 +446,7 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
protected int resizeHeader(GuiContainer gui) {
final LayoutStyleMinecraft layout = (LayoutStyleMinecraft) LayoutManager.getLayoutStyle();
final int rows = (int) Math.ceil((double) layout.buttonCount / layout.numButtons);
final int diff = rows * 19 + getMarginTop(gui) - y;
final int diff = rows * 19 + PADDING - y;
if (diff > 0) {
y += diff;
@@ -493,24 +504,31 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
}
}
protected String getPositioningSettingName() {
return "world.panels.bookmarks";
}
public Rectangle4i calculateBounds() {
final GuiContainer gui = NEIClientUtils.getGuiContainer();
final int width = (gui.width - gui.xSize) / 2 - PADDING * 2;
final Rectangle4i bounds = new Rectangle4i(
PADDING,
PADDING,
(gui.width - 176) / 2 - PADDING * 2,
gui.height - PADDING * 2);
public int getMarginLeft(GuiContainer gui) {
return PADDING;
}
int paddingLeft = (int) Math
.ceil(bounds.w * NEIClientConfig.getSetting("world.panels.bookmarks.left").getIntValue() / 100000.0);
int paddingTop = (int) Math
.ceil(bounds.h * NEIClientConfig.getSetting("world.panels.bookmarks.top").getIntValue() / 100000.0);
int paddingRight = (int) Math
.ceil(bounds.w * NEIClientConfig.getSetting("world.panels.bookmarks.right").getIntValue() / 100000.0);
int paddingBottom = (int) Math
.ceil(bounds.h * NEIClientConfig.getSetting("world.panels.bookmarks.bottom").getIntValue() / 100000.0);
public int getMarginTop(GuiContainer gui) {
return PADDING;
}
bounds.h = Math.max(ItemsGrid.SLOT_SIZE, bounds.h - paddingTop - paddingBottom);
bounds.y = bounds.y + Math.min(paddingTop, bounds.h - ItemsGrid.SLOT_SIZE);
public int getWidth(GuiContainer gui) {
return gui.width - (gui.xSize + gui.width) / 2 - PADDING * 2;
}
bounds.w = Math.max(ItemsGrid.SLOT_SIZE, Math.min(bounds.w - paddingLeft - paddingRight, width - paddingLeft));
bounds.x = bounds.x + Math.min(paddingLeft, bounds.w - ItemsGrid.SLOT_SIZE);
public int getHeight(GuiContainer gui) {
return gui.height - getMarginTop(gui) - PADDING;
return bounds;
}
protected ItemStack getDraggedStackWithQuantity(ItemStack itemStack) {
+22 -14
View File
@@ -8,6 +8,7 @@ import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import codechicken.lib.gui.GuiDraw;
import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.ItemsPanelGrid.ItemsPanelGridSlot;
import codechicken.nei.util.NEIMouseUtils;
@@ -108,24 +109,31 @@ public class ItemPanel extends PanelWidget<ItemsPanelGrid> {
return String.format("%d/%d", getPage(), Math.max(1, getNumPages()));
}
protected String getPositioningSettingName() {
return "world.panels.items";
}
public Rectangle4i calculateBounds() {
final GuiContainer gui = NEIClientUtils.getGuiContainer();
final int width = (gui.width - gui.xSize) / 2 - PADDING * 2;
final Rectangle4i bounds = new Rectangle4i(
(gui.width + gui.xSize) / 2 + PADDING,
PADDING,
(gui.width - 176) / 2 - PADDING * 2,
gui.height - PADDING * 2);
public int getMarginLeft(GuiContainer gui) {
return (gui.width + gui.xSize) / 2 + PADDING;
}
int paddingLeft = (int) Math
.ceil(bounds.w * NEIClientConfig.getSetting("world.panels.items.left").getIntValue() / 100000.0);
int paddingTop = (int) Math
.ceil(bounds.h * NEIClientConfig.getSetting("world.panels.items.top").getIntValue() / 100000.0);
int paddingRight = (int) Math
.ceil(bounds.w * NEIClientConfig.getSetting("world.panels.items.right").getIntValue() / 100000.0);
int paddingBottom = (int) Math
.ceil(bounds.h * NEIClientConfig.getSetting("world.panels.items.bottom").getIntValue() / 100000.0);
public int getMarginTop(GuiContainer gui) {
return PADDING;
}
bounds.h = Math.max(ItemsGrid.SLOT_SIZE, bounds.h - paddingTop - paddingBottom);
bounds.y = bounds.y + Math.min(paddingTop, bounds.h - ItemsGrid.SLOT_SIZE);
public int getWidth(GuiContainer gui) {
return gui.width - (gui.xSize + gui.width) / 2 - PADDING * 2;
}
bounds.w = Math.max(ItemsGrid.SLOT_SIZE, Math.min(bounds.w - paddingLeft - paddingRight, width - paddingRight));
bounds.x = bounds.x + Math.max(0, width - bounds.w - paddingRight);
public int getHeight(GuiContainer gui) {
return gui.height - getMarginTop(gui) - PADDING;
return bounds;
}
@Override
@@ -4,6 +4,8 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map.Entry;
import org.lwjgl.input.Keyboard;
/**
* Good old down/held/up keystate tracker
*/
@@ -26,7 +28,7 @@ public class KeyManager {
public static void tickKeyStates() {
for (Entry<String, KeyState> entry : keyStates.entrySet()) {
final boolean down = NEIClientConfig.isKeyHashDown(entry.getKey());
final boolean down = Keyboard.isKeyDown(NEIClientConfig.getKeyBinding(entry.getKey()));
final KeyState state = entry.getValue();
if (down) {
@@ -52,7 +52,7 @@ public class LayoutStyleMinecraft extends LayoutStyle {
public void layout(GuiContainer gui, VisiblityData visiblity) {
reset();
leftSize = ItemPanels.bookmarkPanel.getWidth(gui);
leftSize = (gui.width - gui.xSize) / 2 - 4;
numButtons = Math.max(leftSize / 20, 1);
LayoutManager.delete.state = 0x4;
@@ -390,6 +390,8 @@ public class NEIClientConfig {
});
tag.getTag("inventory.hotkeysHelpText").getBooleanValue(true);
API.addOption(new OptionToggleButton("inventory.hotkeysHelpText", true));
tag.getTag("inventory.showHotkeys").getBooleanValue(true);
API.addOption(new OptionToggleButton("inventory.showHotkeys", true));
tag.getTag("loadPluginsInParallel").getBooleanValue(true);
tag.getTag("itemLoadingTimeout").getIntValue(500);
@@ -743,6 +745,7 @@ public class NEIClientConfig {
API.addHashBind("gui.hide", Keyboard.KEY_O);
API.addHashBind("gui.search", Keyboard.KEY_F);
API.addKeyBind("gui.bookmark", Keyboard.KEY_A);
API.addHashBind("gui.favorite", Keyboard.KEY_F + NEIClientUtils.SHIFT_HASH);
API.addHashBind("gui.remove_recipe", Keyboard.KEY_A + NEIClientUtils.SHIFT_HASH);
API.addKeyBind("gui.bookmark_pull_items", Keyboard.KEY_V);
API.addKeyBind("gui.overlay", Keyboard.KEY_S);
@@ -857,7 +860,7 @@ public class NEIClientConfig {
final int hash = getKeyBinding(string);
if (hash != Keyboard.CHAR_NONE && Keyboard.getEventKeyState()) {
return KeyManager.keyStates.containsKey(string) ? hash == Keyboard.getEventKey()
return KeyManager.keyStates.containsKey(string) ? Keyboard.isKeyDown(hash)
: hash == NEIClientUtils.getKeyHash();
}
+6 -35
View File
@@ -84,44 +84,15 @@ public abstract class PanelWidget<T extends ItemsGrid<? extends ItemsGridSlot, ?
public abstract String getLabelText();
protected abstract String getPositioningSettingName();
public abstract int getMarginLeft(GuiContainer gui);
public abstract int getMarginTop(GuiContainer gui);
public abstract int getWidth(GuiContainer gui);
public abstract int getHeight(GuiContainer gui);
public abstract Rectangle4i calculateBounds();
public void resize(GuiContainer gui) {
final Rectangle4i margin = new Rectangle4i(
getMarginLeft(gui),
getMarginTop(gui),
getWidth(gui),
getHeight(gui));
final Rectangle4i bounds = calculateBounds();
final String settingName = getPositioningSettingName();
int paddingLeft = (int) Math
.ceil(margin.w * NEIClientConfig.getSetting(settingName + ".left").getIntValue() / 100000.0);
int paddingTop = (int) Math
.ceil(margin.h * NEIClientConfig.getSetting(settingName + ".top").getIntValue() / 100000.0);
int paddingRight = (int) Math
.ceil(margin.w * NEIClientConfig.getSetting(settingName + ".right").getIntValue() / 100000.0);
int paddingBottom = (int) Math
.ceil(margin.h * NEIClientConfig.getSetting(settingName + ".bottom").getIntValue() / 100000.0);
int deltaHeight = Math.min(0, margin.h - paddingTop - paddingBottom - ItemsGrid.SLOT_SIZE) / 2;
paddingLeft = Math.min(paddingLeft, Math.max(0, margin.w - paddingRight - ItemsGrid.SLOT_SIZE));
paddingRight = Math.min(paddingRight, Math.max(0, margin.w - paddingLeft - ItemsGrid.SLOT_SIZE));
paddingTop = Math.min(margin.h - ItemsGrid.SLOT_SIZE, Math.max(0, paddingTop + deltaHeight));
paddingBottom = Math.min(margin.h - paddingTop - ItemsGrid.SLOT_SIZE, Math.max(0, paddingBottom - deltaHeight));
x = margin.x + paddingLeft;
y = margin.y + paddingTop;
w = margin.w - paddingLeft - paddingRight;
h = margin.h - paddingTop - paddingBottom;
x = bounds.x;
y = bounds.y;
w = bounds.w;
h = bounds.h;
final int header = resizeHeader(gui);
final int footer = resizeFooter(gui);
@@ -21,6 +21,7 @@ import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSyntaxException;
import codechicken.core.CommonUtils;
import codechicken.nei.SubsetWidget.SubsetTag;
import codechicken.nei.api.API;
import codechicken.nei.api.IRecipeFilter;
import codechicken.nei.api.IRecipeFilter.IRecipeFilterProvider;
@@ -33,6 +34,7 @@ import codechicken.nei.util.NBTJson;
public class PresetsList {
public enum PresetMode {
SUBSET,
HIDE,
REMOVE,
GROUP;
@@ -216,6 +218,8 @@ public class PresetsList {
if (!preset.items.isEmpty()) {
presets.add(preset);
}
updateSubsets();
}
public static void savePresets() {
@@ -241,9 +245,24 @@ public class PresetsList {
recipeFilter.cache = null;
itemFilter.cache = null;
updateSubsets();
CollapsibleItems.saveStates();
CollapsibleItems.load();
LayoutManager.markItemsDirty();
}
private static void updateSubsets() {
SubsetWidget.removeTag("Presets");
for (Preset preset : PresetsList.presets) {
if (preset.enabled && preset.mode == PresetMode.SUBSET) {
SubsetWidget.addTag(
new SubsetTag(
"Presets." + preset.name,
stack -> preset.items.contains(Preset.getIdentifier(stack))));
}
}
}
}
@@ -415,6 +415,17 @@ public class SubsetWidget extends Button implements ItemFilterProvider, IContain
}
}
public static void removeTag(String path) {
updateState.stop();
synchronized (tags) {
tags.keySet().removeIf(
parentpath -> parentpath.equals(path.toLowerCase())
|| parentpath.startsWith(path.toLowerCase() + "."));
updateHiddenItems();
}
}
public static boolean isHidden(ItemStack item) {
try {
if (hiddenReadLock.tryLock(5, TimeUnit.SECONDS)) {
@@ -24,10 +24,12 @@ import codechicken.nei.NEIClientConfig;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.SearchField;
import codechicken.nei.bookmark.BookmarkGrid;
import codechicken.nei.bookmark.BookmarkGroup;
import codechicken.nei.bookmark.BookmarkItem;
import codechicken.nei.bookmark.BookmarksGridSlot;
import codechicken.nei.recipe.AutoCraftingManager;
import codechicken.nei.recipe.GuiCraftingRecipe;
import codechicken.nei.recipe.GuiFavoriteButton;
import codechicken.nei.recipe.GuiRecipe;
import codechicken.nei.recipe.GuiUsageRecipe;
import codechicken.nei.recipe.Recipe;
@@ -112,6 +114,10 @@ public abstract class ShortcutInputHandler {
return GuiUsageRecipe.openRecipeGui("item", stackover);
}
if (NEIClientConfig.isKeyHashDown("gui.favorite")) {
return saveFavoriteTree(stackover);
}
if (NEIClientConfig.isKeyHashDown("gui.bookmark")) {
return saveRecipeInBookmark(stackover, NEIClientUtils.shiftKey(), NEIClientUtils.controlKey());
}
@@ -247,6 +253,25 @@ public abstract class ShortcutInputHandler {
return false;
}
private static boolean saveFavoriteTree(ItemStack stackover) {
final Point mouse = GuiDraw.getMousePosition();
if (ItemPanels.itemPanel.contains(mouse.x, mouse.y)
|| ItemPanels.itemPanel.historyPanel.contains(mouse.x, mouse.y)) {
final RecipeHandlerRef handlerRef = RecipeHandlerRef.of(FavoriteRecipes.getFavorite(stackover));
if (handlerRef != null) {
final GuiFavoriteButton button = new GuiFavoriteButton(handlerRef, 0, 0);
button.saveRecipeInBookmark();
return true;
}
return true;
}
return false;
}
private static boolean saveRecipeInBookmark(ItemStack stackover, boolean saveIngredients, boolean saveStackSize) {
final Point mousePos = GuiDraw.getMousePosition();
@@ -378,15 +403,56 @@ public abstract class ShortcutInputHandler {
final RecipeId recipeId = getHotkeyRecipeId(gui, mousex, mousey, stack, slot);
if (slot != null) {
hotkeys.put(
NEIClientConfig.getKeyName("gui.bookmark"),
NEIClientUtils.translate(slot.isIngredient() ? "bookmark.remove_item" : "bookmark.remove_recipe"));
final BookmarkGroup group = slot.getGroup();
if (slot.isIngredient()) {
if (group.crafting != null && group.collapsed) {
hotkeys.put(
NEIClientConfig.getKeyName("gui.bookmark", NEIClientUtils.SHIFT_HASH),
NEIClientUtils.translate("bookmark.remove_recipe"));
}
NEIClientUtils.translate("bookmark.group.remove_recipe"));
} else if (slot.getRecipeId() == null) {
hotkeys.put(
NEIClientConfig.getKeyName("gui.bookmark"),
NEIClientUtils.translate("bookmark.remove_item"));
} else if (group.crafting != null && group.crafting.recipeRelations.entrySet().stream().anyMatch(
entry -> entry.getKey().equals(slot.getRecipeId())
|| entry.getValue().contains(slot.getRecipeId()))) {
hotkeys.put(
NEIClientConfig.getKeyName("gui.bookmark", NEIClientUtils.SHIFT_HASH),
NEIClientUtils.translate("bookmark.remove_recipe"));
} else {
hotkeys.put(
NEIClientConfig.getKeyName("gui.bookmark", NEIClientUtils.SHIFT_HASH),
NEIClientUtils.translate("bookmark.remove_recipe"));
if (slot.isIngredient()) {
hotkeys.put(
NEIClientConfig.getKeyName("gui.bookmark"),
NEIClientUtils.translate("bookmark.remove_item"));
hotkeys.put(
NEIClientConfig.getKeyName("gui.bookmark", NEIClientUtils.SHIFT_HASH),
NEIClientUtils.translate("bookmark.remove_recipe"));
} else {
final BookmarkItem item = slot.getBookmarkItem();
if (ItemPanels.bookmarkPanel.getGrid().createChainItems(groupId).values().stream()
.noneMatch(
m -> !m.isIngredient && !m.equals(item) && item.equalsRecipe(m))) {
hotkeys.put(
NEIClientConfig.getKeyName("gui.bookmark"),
NEIClientUtils.translate("bookmark.remove_recipe"));
} else {
hotkeys.put(
NEIClientConfig.getKeyName("gui.bookmark"),
NEIClientUtils.translate("bookmark.remove_item"));
hotkeys.put(
NEIClientConfig.getKeyName("gui.bookmark", NEIClientUtils.SHIFT_HASH),
NEIClientUtils.translate("bookmark.remove_recipe"));
}
}
}
if (BookmarkContainerInfo.getBookmarkContainerHandler(gui) != null) {
hotkeys.put(
@@ -412,6 +478,13 @@ public abstract class ShortcutInputHandler {
NEIClientUtils.translate("bookmark.add_item_with_recipe"));
}
if ((ItemPanels.itemPanel.contains(mousex, mousey)
|| ItemPanels.itemPanel.historyPanel.contains(mousex, mousey)) && FavoriteRecipes.contains(stack)) {
hotkeys.put(
NEIClientConfig.getKeyName("gui.favorite"),
NEIClientUtils.translate("recipe.favorite.bookmark_recipe"));
}
}
hotkeys.put(NEIClientConfig.getKeyName("gui.recipe"), NEIClientUtils.translate("itempanel.open_crafting"));
@@ -904,7 +904,7 @@ public class BookmarkGrid extends ItemsGrid<BookmarksGridSlot, BookmarkGrid.Book
if (item.recipeId != null && removeFullRecipe) {
removeRecipe(item.recipeId, item.groupId);
} else {
} else if (itemIndex >= 0) {
this.bookmarkItems.remove(itemIndex);
onItemsChanged();
}
@@ -1116,16 +1116,16 @@ public class BookmarkGrid extends ItemsGrid<BookmarksGridSlot, BookmarkGrid.Book
if (item.factor > 0
&& outputRecipes.stream().anyMatch(recipeId -> item.equalsRecipe(recipeId, targetGroupId))) {
final long multiplier = recipeMultipliers.getOrDefault(item.recipeId, (long) Integer.MAX_VALUE);
final boolean isOutputRecipe = group.crafting != null
&& !group.crafting.recipeInMiddle.contains(item.recipeId);
final boolean recipeInMiddle = group.crafting != null
&& group.crafting.recipeInMiddle.contains(item.recipeId);
recipeMultipliers.put(
item.recipeId,
Math.min(
shiftMultiplier(
Math.max(isOutputRecipe ? 1 : 0, item.getMultiplier()),
Math.max(recipeInMiddle ? 1 : 0, item.getMultiplier()),
shift,
isOutputRecipe ? 1 : 0),
recipeInMiddle ? 1 : 0),
multiplier));
items.add(item);
}
@@ -1148,16 +1148,16 @@ public class BookmarkGrid extends ItemsGrid<BookmarksGridSlot, BookmarkGrid.Book
} else if (targetItem.recipeId != null) {
final RecipeId recipeId = this.gridGenerator.itemToRecipe
.getOrDefault(targetItemIndex, targetItem.recipeId);
final boolean isOutputRecipe = group.crafting != null && !group.crafting.recipeInMiddle.contains(recipeId);
final boolean recipeInMiddle = group.crafting != null && group.crafting.recipeInMiddle.contains(recipeId);
long multiplier = Integer.MAX_VALUE;
for (BookmarkItem item : this.bookmarkItems) {
if (item.equalsRecipe(recipeId, targetItem.groupId) && item.factor > 0) {
multiplier = Math.min(
shiftMultiplier(
Math.max(isOutputRecipe ? 1 : 0, item.getMultiplier()),
Math.max(recipeInMiddle ? 1 : 0, item.getMultiplier()),
shift,
isOutputRecipe ? 1 : 0),
recipeInMiddle ? 1 : 0),
multiplier);
}
}
@@ -179,9 +179,10 @@ public class RecipeChainDetails {
if (itemIndex >= 0 && this.calculatedItems.containsKey(itemIndex)) {
final BookmarkItem item = entry.getValue();
if (this.recipeInMiddle.contains(item.recipeId)) {
this.calculatedItems.get(itemIndex).setRealAmount(item.amount);
this.calculatedItems.get(itemIndex)
.setRealAmount(Math.max(0, item.factor * (item.getMultiplier() - 1)));
} else {
this.calculatedItems.get(itemIndex).setRealAmount(Math.max(item.factor, item.amount));
this.calculatedItems.get(itemIndex).setRealAmount(item.amount);
}
}
}
@@ -160,8 +160,8 @@ public class GuiPanelSettings extends GuiScreenWidget {
}
protected void drawItems() {
final int columns = w / ItemsGrid.SLOT_SIZE;
final int rows = (h - (PANEL_SIZE + 2) * 2) / ItemsGrid.SLOT_SIZE;
final int columns = (w - 2) / ItemsGrid.SLOT_SIZE;
final int rows = (h - (PANEL_SIZE + 2) * 2 - 2) / ItemsGrid.SLOT_SIZE;
final int paddingLeft = (w % ItemsGrid.SLOT_SIZE) / 2;
final List<ItemStack> items = ItemPanels.itemPanel.getItems();
if (items.isEmpty()) return;
@@ -64,7 +64,7 @@ public class IMCHandler {
final boolean requiresMod = tag.getBoolean("modRequired");
final String excludedModId = tag.hasKey("excludedModId") ? tag.getString("excludedModId") : null;
if (handler.equals("") || modName.equals("") || modId.equals("")) {
if (handler.isEmpty() || modName.isEmpty() || modId.isEmpty()) {
NEIClientConfig.logger.warn("Missing relevant information to registerHandlerInfo!");
return;
}
@@ -74,7 +74,7 @@ public class IMCHandler {
HandlerInfo info = new HandlerInfo(handler, modName, modId, requiresMod, excludedModId);
final String imageResource = tag.hasKey("imageResource") ? tag.getString("imageResource") : null;
if (imageResource != null && !imageResource.equals("")) {
if (imageResource != null && !imageResource.isEmpty()) {
info.setImage(
imageResource,
tag.getInteger("imageX"),
@@ -84,7 +84,7 @@ public class IMCHandler {
}
if (!info.hasImageOrItem()) {
final String itemName = tag.getString("itemName");
if (itemName != null && !itemName.equals("")) {
if (itemName != null && !itemName.isEmpty()) {
info.setItem(itemName, tag.hasKey("nbtInfo") ? tag.getString("nbtInfo") : null);
}
}
@@ -103,6 +103,10 @@ public class IMCHandler {
NEIClientConfig.logger.info("Error setting handler dimensions for " + handler);
}
// true if not set to false
info.setShowFavoritesButton(!tag.hasKey("showFavoritesButton") || tag.getBoolean("showFavoritesButton"));
info.setShowOverlayButton(!tag.hasKey("showOverlayButton") || tag.getBoolean("showOverlayButton"));
GuiRecipeTab.handlerAdderFromIMC.remove(handler);
GuiRecipeTab.handlerAdderFromIMC.put(handler, info);
}
@@ -207,6 +207,10 @@ public class GuiPresetList extends GuiOptionPane {
modeName = EnumChatFormatting.GOLD + NEIClientUtils.translate("presets.mode.hide.char")
+ EnumChatFormatting.RESET;
break;
case SUBSET:
modeName = EnumChatFormatting.DARK_PURPLE + NEIClientUtils.translate("presets.mode.subset.char")
+ EnumChatFormatting.RESET;
break;
case REMOVE:
modeName = EnumChatFormatting.RED + NEIClientUtils.translate("presets.mode.remove.char")
+ EnumChatFormatting.RESET;
@@ -86,6 +86,7 @@ public class LeftPanel extends GuiWidget {
protected Label modeLabel = new Label(NEIClientUtils.translate("presets.mode"), false);
protected CheckboxButton modeHide;
protected CheckboxButton modeSubset;
protected CheckboxButton modeRemove;
protected CheckboxButton modeGroup;
@@ -114,6 +115,19 @@ public class LeftPanel extends GuiWidget {
}
};
modeSubset = new CheckboxButton(NEIClientUtils.translate("presets.mode.subset")) {
@Override
public boolean isChecked() {
return preset.mode == PresetMode.SUBSET;
}
@Override
protected void onChange() {
preset.mode = this.checked ? PresetMode.SUBSET : null;
}
};
modeRemove = new CheckboxButton(NEIClientUtils.translate("presets.mode.remove")) {
@Override
@@ -164,6 +178,10 @@ public class LeftPanel extends GuiWidget {
modeHide.handleClick(x, y, button);
}
if (modeSubset.contains(x, y)) {
modeSubset.handleClick(x, y, button);
}
if (modeRemove.contains(x, y)) {
modeRemove.handleClick(x, y, button);
}
@@ -248,7 +266,7 @@ public class LeftPanel extends GuiWidget {
@Override
public void update() {
int CHECKBOX_WIDTH = (this.width - 12) / 3;
int CHECKBOX_WIDTH = (this.width - 12) / 4;
nameLabel.x = this.x + 2;
nameLabel.y = this.y + 4;
nameLabel.w = this.width;
@@ -269,12 +287,13 @@ public class LeftPanel extends GuiWidget {
modeLabel.w = this.width;
modeLabel.h = 10;
modeHide.w = modeRemove.w = modeGroup.w = CHECKBOX_WIDTH;
modeHide.h = modeRemove.h = modeGroup.h = INPUT_HEIGHT;
modeHide.y = modeRemove.y = modeGroup.y = modeLabel.y + modeLabel.h;
modeHide.w = modeSubset.w = modeRemove.w = modeGroup.w = CHECKBOX_WIDTH;
modeHide.h = modeSubset.h = modeRemove.h = modeGroup.h = INPUT_HEIGHT;
modeHide.y = modeSubset.y = modeRemove.y = modeGroup.y = modeLabel.y + modeLabel.h;
modeHide.x = this.x + 1;
modeRemove.x = modeHide.x + modeHide.w + 6;
modeSubset.x = modeHide.x + modeHide.w + 6;
modeRemove.x = modeSubset.x + modeSubset.w + 6;
modeGroup.x = modeRemove.x + modeRemove.w + 6;
grid.setGridSize(
@@ -292,6 +311,7 @@ public class LeftPanel extends GuiWidget {
modeLabel.draw(mousex, mousey);
modeHide.draw(mousex, mousey);
modeSubset.draw(mousex, mousey);
modeRemove.draw(mousex, mousey);
modeGroup.draw(mousex, mousey);
@@ -326,6 +346,8 @@ public class LeftPanel extends GuiWidget {
} else if (modeHide.contains(mousex, mousey)) {
tooltip.add(NEIClientUtils.translate("presets.mode.hide.tip"));
} else if (modeSubset.contains(mousex, mousey)) {
tooltip.add(NEIClientUtils.translate("presets.mode.subset.tip"));
} else if (modeRemove.contains(mousex, mousey)) {
tooltip.add(NEIClientUtils.translate("presets.mode.remove.tip"));
} else if (modeGroup.contains(mousex, mousey)) {
@@ -592,7 +592,7 @@ public class GuiContainerManager {
if (!tooltip.isEmpty()) tooltip.set(0, tooltip.get(0) + GuiDraw.TOOLTIP_LINESPACE); // add space after 'title'
if (showTooltip) {
if (showTooltip && NEIClientConfig.getBooleanSetting("inventory.showHotkeys")) {
List<String> hotkeystips = collectHotkeyTips(mousex, mousey);
if (!hotkeystips.isEmpty()) {
@@ -119,7 +119,7 @@ public class GuiFavoriteButton extends GuiRecipeButton {
public void lastKeyTyped(GuiRecipe<?> gui, char keyChar, int keyID) {
if (NEIClientConfig.isKeyHashDown("gui.bookmark") && NEIClientUtils.shiftKey()) {
ItemPanels.bookmarkPanel.addGroup(getRecipesTree(getRecipe()), BookmarkViewMode.TODO_LIST, true);
saveRecipeInBookmark();
}
}
@@ -180,6 +180,10 @@ public class GuiFavoriteButton extends GuiRecipeButton {
return true;
}
public void saveRecipeInBookmark() {
ItemPanels.bookmarkPanel.addGroup(getRecipesTree(getRecipe()), BookmarkViewMode.TODO_LIST, true);
}
private List<Recipe> getRecipesTree(Recipe mainRecipe) {
int depth = NEIClientConfig.getIntSetting("inventory.favorites.depth");
final ItemStackSet items = new ItemStackSet();
@@ -462,8 +462,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
if (!cacheKey.equals(this.recipePageCacheKey)) {
this.recipePageCacheKey = cacheKey;
for (int refIndex = 0; refIndex < indices.size(); refIndex++) {
final int recipeIndex = indices.get(refIndex);
for (final int recipeIndex : indices) {
for (PositionedStack pStack : handler.original.getIngredientStacks(recipeIndex)) {
pStack.setPermutationToRender(pStack.getFilteredPermutations().get(0));
}
@@ -472,7 +471,8 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
final int xOffset = (limitToOneRecipe ? 0 : guiLeft) + xSize - BORDER_PADDING;
final int yOffset = (limitToOneRecipe ? -BUTTON_HEIGHT : guiTop - 18) + getRefIndexPosition(0).y;
final int height = handlerInfo.getHeight() - yShift;
final boolean showFavorites = NEIClientConfig.favoritesEnabled();
final boolean showFavorites = NEIClientConfig.favoritesEnabled() && handlerInfo.getShowFavoritesButton();
final boolean showOverlay = handlerInfo.getShowOverlayButton();
final UpdateRecipeButtonsEvent.Pre preEvent = new UpdateRecipeButtonsEvent.Pre(
this,
xOffset,
@@ -484,7 +484,6 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
if (MinecraftForge.EVENT_BUS.post(preEvent)) {
buttons = preEvent.buttonList;
} else {
for (int refIndex = 0; refIndex < indices.size(); refIndex++) {
final int recipeIndex = indices.get(refIndex);
@@ -493,20 +492,19 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
continue;
}
GuiRecipeButton button = new GuiOverlayButton(
firstGui,
RecipeHandlerRef.of(handler.original, recipeIndex),
xOffset - GuiRecipeButton.BUTTON_WIDTH,
yOffset + height * (refIndex + 1));
buttons.add(button);
if (showFavorites) {
int x = xOffset - GuiRecipeButton.BUTTON_WIDTH;
int y = yOffset + height * (refIndex + 1);
if (showOverlay) {
buttons.add(
new GuiFavoriteButton(
new GuiOverlayButton(
firstGui,
RecipeHandlerRef.of(handler.original, recipeIndex),
button.xPosition,
button.yPosition - button.height - 1));
x,
y));
y -= GuiRecipeButton.BUTTON_HEIGHT + 1;
}
if (showFavorites) {
buttons.add(new GuiFavoriteButton(RecipeHandlerRef.of(handler.original, recipeIndex), x, y));
}
}
@@ -522,6 +520,10 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
buttons.removeIf(GuiFavoriteButton.class::isInstance);
}
if (!showOverlay) {
buttons.removeIf(GuiOverlayButton.class::isInstance);
}
/** compatibility with old format */
this.overlayButtons = buttons.stream().filter(GuiOverlayButton.class::isInstance)
.toArray(GuiOverlayButton[]::new);
@@ -28,6 +28,8 @@ public class HandlerInfo {
private int height = DEFAULT_HEIGHT;
private int width = DEFAULT_WIDTH;
private int maxRecipesPerPage = DEFAULT_MAX_PER_PAGE;
private boolean showFavoritesButton = true;
private boolean showOverlayButton = true;
private ItemStack itemStack = null;
private DrawableResource image = null;
@@ -112,6 +114,22 @@ public class HandlerInfo {
this.yShift = yShift;
}
public boolean getShowFavoritesButton() {
return this.showFavoritesButton;
}
public void setShowFavoritesButton(boolean showFavoritesButton) {
this.showFavoritesButton = showFavoritesButton;
}
public boolean getShowOverlayButton() {
return this.showOverlayButton;
}
public void setShowOverlayButton(boolean showOverlayButton) {
this.showOverlayButton = showOverlayButton;
}
public static class Builder {
private final HandlerInfo info;
@@ -30,7 +30,7 @@ public class RecipeHandlerRef {
public static RecipeHandlerRef of(RecipeId recipeId) {
if (recipeId.getResult() != null && !recipeId.getIngredients().isEmpty()) {
if (recipeId != null && recipeId.getResult() != null && !recipeId.getIngredients().isEmpty()) {
return recipeRefCache.computeIfAbsent(recipeId, ri -> {
final List<ICraftingHandler> handlers = GuiCraftingRecipe
.getCraftingHandlers("recipeId", recipeId.getResult(), recipeId);
@@ -116,18 +116,18 @@ public class RecipeChainMath {
}
for (Map.Entry<RecipeId, Long> entry : multipliers.entrySet()) {
if (!this.outputRecipes.containsKey(entry.getKey()) && this.preferredItems.values().stream()
.noneMatch(resItem -> resItem.recipeId.equals(entry.getKey()))) {
this.outputRecipes.put(entry.getKey(), entry.getValue());
final RecipeId recipeId = entry.getKey();
final boolean isOutputRecipe = this.outputRecipes.containsKey(recipeId);
final boolean recipeInMiddle = this.preferredItems.values().stream()
.anyMatch(resItem -> resItem.recipeId.equals(recipeId));
if (!isOutputRecipe && !recipeInMiddle) {
this.outputRecipes.put(recipeId, entry.getValue());
} else if (isOutputRecipe && recipeInMiddle) {
this.outputRecipes.put(recipeId, Math.max(0, entry.getValue() - 1));
}
}
for (Map.Entry<RecipeId, Long> entry : this.outputRecipes.entrySet()) {
if (entry.getValue() == 0 && this.preferredItems.values().stream()
.noneMatch(prefItem -> prefItem.recipeId.equals(entry.getKey()))) {
entry.setValue(1L);
}
}
}
private void collectPreferredItems(RecipeId recipeId, Map<BookmarkItem, BookmarkItem> preferredItems,
@@ -242,6 +242,9 @@ nei.options.inventory.favorites.depth=Depth
nei.options.inventory.hotkeysHelpText=Show Hotkeys Help Text
nei.options.inventory.hotkeysHelpText.true=Yes
nei.options.inventory.hotkeysHelpText.false=No
nei.options.inventory.showHotkeys=Show Hotkeys
nei.options.inventory.showHotkeys.true=Yes
nei.options.inventory.showHotkeys.false=No
nei.options.inventory.guirecipe=Recipes GUI
nei.options.inventory.guirecipe.jeiStyleTabs=JEI Style Tabs
nei.options.inventory.guirecipe.jeiStyleTabs.true=Yes
@@ -572,6 +575,9 @@ nei.presets.mode=Mode
nei.presets.mode.hide=Hide
nei.presets.mode.hide.char=H
nei.presets.mode.hide.tip=Hide items in panel
nei.presets.mode.subset=Subset
nei.presets.mode.subset.char=S
nei.presets.mode.subset.tip=Create custom subsets
nei.presets.mode.remove=Remove
nei.presets.mode.remove.tip=Hide items in panel and their recipes
nei.presets.mode.remove.char=R