diff --git a/.gitignore b/.gitignore index b40db0506..d27c08be3 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,6 @@ out/ build/* /bin/ changelog.html + +.DS_Store +.vscode/ \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 4a9736a62..55b94a580 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,4 +5,4 @@ curse_project_id=238222 version_major=3 version_minor=14 -version_patch=8 +version_patch=9 diff --git a/src/main/java/mezz/jei/IngredientBookmarks.java b/src/main/java/mezz/jei/IngredientBookmarks.java new file mode 100644 index 000000000..15f92d976 --- /dev/null +++ b/src/main/java/mezz/jei/IngredientBookmarks.java @@ -0,0 +1,88 @@ +package mezz.jei; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; + +import mezz.jei.api.ingredients.IIngredientBookmarks; +import mezz.jei.api.ingredients.IIngredientHelper; +import mezz.jei.api.ingredients.IIngredientRegistry; +import mezz.jei.api.ingredients.IIngredientRenderer; +import mezz.jei.config.Config; +import mezz.jei.gui.ingredients.IIngredientListElement; +import mezz.jei.util.IngredientListElement; +import com.google.common.collect.ImmutableCollection; +import com.google.common.collect.ImmutableList; + +public class IngredientBookmarks implements IIngredientBookmarks { + private final IIngredientRegistry ingredientRegistry; + + // Using both cause linked list will retain order of insertion + private List bookmarkIds = new LinkedList(); + private HashMap bookmarkList = new HashMap(); + + public IngredientBookmarks(IIngredientRegistry ingredientRegistry) { + this.ingredientRegistry = ingredientRegistry; + + String[] bookmarks = Config.getBookmarks(); + + for (String uniqueId : bookmarks) { + bookmarkIds.add(uniqueId); + bookmarkList.put(uniqueId, findIngredientFromUniqueId(uniqueId)); + } + } + + @Override + public void toggleIngredientBookmark(V ingredient) { + IIngredientHelper ingredientHelper = ingredientRegistry.getIngredientHelper(ingredient); + String uniqueId = ingredientHelper.getUniqueId(ingredient); + + // System.out.println(ingredientHelper.getUniqueId(ingredient)); + if (bookmarkIds.contains(uniqueId)) { + bookmarkIds.remove(uniqueId); + bookmarkList.remove(uniqueId); + } else { + bookmarkIds.add(uniqueId); + bookmarkList.put(uniqueId, findIngredientFromUniqueId(uniqueId)); + } + Config.updateBookmarks(bookmarkIds.toArray(new String[bookmarkIds.size()])); + } + + private V findIngredientFromUniqueId(String uniqueId) { + ImmutableCollection classes = ingredientRegistry.getRegisteredIngredientClasses(); + for (Class clazz : classes) { + ImmutableList iList = ingredientRegistry.getIngredients(clazz); + IIngredientHelper iHelper = ingredientRegistry.getIngredientHelper(clazz); + for (V i : iList) { + if (iHelper.getUniqueId(i).equals(uniqueId)) { + return i; + } + } + } + return null; + } + + @Override + public List getIngredientList() { + List ingredientListElements = new LinkedList(); + + for (String uniqueId : bookmarkIds) { + Object ingredient = bookmarkList.get(uniqueId); + + IIngredientHelper ingredientHelper = ingredientRegistry.getIngredientHelper(ingredient); + IIngredientRenderer ingredientRenderer = ingredientRegistry.getIngredientRenderer(ingredient); + IngredientListElement ingredientListElement = IngredientListElement.create(ingredient, ingredientHelper, + ingredientRenderer); + if (ingredientListElement != null) { + ingredientListElements.add(ingredientListElement); + } + } + return ingredientListElements; + } + + @Override + public void clear() { + bookmarkIds.clear(); + bookmarkList.clear(); + } +} diff --git a/src/main/java/mezz/jei/JeiRuntime.java b/src/main/java/mezz/jei/JeiRuntime.java index c0767a755..267da142e 100644 --- a/src/main/java/mezz/jei/JeiRuntime.java +++ b/src/main/java/mezz/jei/JeiRuntime.java @@ -5,6 +5,7 @@ import mezz.jei.api.IJeiRuntime; import mezz.jei.api.gui.IAdvancedGuiHandler; +import mezz.jei.api.ingredients.IIngredientBookmarks; import mezz.jei.gui.ItemListOverlay; import mezz.jei.gui.recipes.RecipesGui; import net.minecraft.client.gui.GuiScreen; @@ -17,13 +18,15 @@ public class JeiRuntime implements IJeiRuntime { private final RecipesGui recipesGui; private final IngredientRegistry ingredientRegistry; private final List> advancedGuiHandlers; + private final IngredientBookmarks ingredientBookmarks; - public JeiRuntime(RecipeRegistry recipeRegistry, ItemListOverlay itemListOverlay, RecipesGui recipesGui, IngredientRegistry ingredientRegistry, List> advancedGuiHandlers) { + public JeiRuntime(RecipeRegistry recipeRegistry, ItemListOverlay itemListOverlay, RecipesGui recipesGui, IngredientRegistry ingredientRegistry, List> advancedGuiHandlers, IngredientBookmarks ingredientBookmarks) { this.recipeRegistry = recipeRegistry; this.itemListOverlay = itemListOverlay; this.recipesGui = recipesGui; this.ingredientRegistry = ingredientRegistry; this.advancedGuiHandlers = advancedGuiHandlers; + this.ingredientBookmarks = ingredientBookmarks; } public void close() { @@ -54,6 +57,10 @@ public IngredientRegistry getIngredientRegistry() { return ingredientRegistry; } + public IIngredientBookmarks getIngredientBookmarks() { + return ingredientBookmarks; + } + public List> getActiveAdvancedGuiHandlers(GuiScreen guiScreen) { List> activeAdvancedGuiHandler = new ArrayList>(); if (guiScreen instanceof GuiContainer) { diff --git a/src/main/java/mezz/jei/JeiStarter.java b/src/main/java/mezz/jei/JeiStarter.java index 71d39fbf9..ce84fd786 100644 --- a/src/main/java/mezz/jei/JeiStarter.java +++ b/src/main/java/mezz/jei/JeiStarter.java @@ -58,10 +58,11 @@ public void start(List plugins, boolean resourceReload) { Log.info("Building runtime..."); start_time = System.currentTimeMillis(); + IngredientBookmarks ingredientBookmarks = new IngredientBookmarks(ingredientRegistry); List> advancedGuiHandlers = modRegistry.getAdvancedGuiHandlers(); - ItemListOverlay itemListOverlay = new ItemListOverlay(itemFilter, advancedGuiHandlers, ingredientRegistry); + ItemListOverlay itemListOverlay = new ItemListOverlay(itemFilter, advancedGuiHandlers, ingredientRegistry, ingredientBookmarks); RecipesGui recipesGui = new RecipesGui(recipeRegistry); - JeiRuntime jeiRuntime = new JeiRuntime(recipeRegistry, itemListOverlay, recipesGui, ingredientRegistry, advancedGuiHandlers); + JeiRuntime jeiRuntime = new JeiRuntime(recipeRegistry, itemListOverlay, recipesGui, ingredientRegistry, advancedGuiHandlers, ingredientBookmarks); Internal.setRuntime(jeiRuntime); Log.info("Built runtime in {} ms", System.currentTimeMillis() - start_time); diff --git a/src/main/java/mezz/jei/api/ingredients/IIngredientBookmarks.java b/src/main/java/mezz/jei/api/ingredients/IIngredientBookmarks.java new file mode 100644 index 000000000..e2ee02be7 --- /dev/null +++ b/src/main/java/mezz/jei/api/ingredients/IIngredientBookmarks.java @@ -0,0 +1,16 @@ +package mezz.jei.api.ingredients; + +import java.util.List; + +import mezz.jei.gui.ingredients.IIngredientListElement; + +public interface IIngredientBookmarks { + /** + * Toggles visibility of ingredient in the bookmark list. + */ + void toggleIngredientBookmark(V ingredient); + + List getIngredientList(); + + void clear(); +} diff --git a/src/main/java/mezz/jei/config/Config.java b/src/main/java/mezz/jei/config/Config.java index 54683a4d5..beb923653 100644 --- a/src/main/java/mezz/jei/config/Config.java +++ b/src/main/java/mezz/jei/config/Config.java @@ -6,6 +6,8 @@ import java.util.Collections; import java.util.EnumSet; import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; import java.util.Locale; import java.util.Set; @@ -40,6 +42,8 @@ public class Config { private static LocalizedConfiguration itemBlacklistConfig; @Nullable private static LocalizedConfiguration searchColorsConfig; + @Nullable + private static LocalizedConfiguration bookmarksConfig; // advanced private static boolean debugModeEnabled = false; @@ -73,7 +77,11 @@ public class Config { // item blacklist private static final Set itemBlacklist = new HashSet(); - private static final String[] defaultItemBlacklist = new String[]{}; + private static final String[] defaultItemBlacklist = new String[] {}; + + // bookmarks + private static final String[] defaultBookmarks = new String[] {}; + private static String[] bookmarks; private Config() { @@ -226,6 +234,8 @@ public static void preInit(FMLPreInitializationEvent event) { final File itemBlacklistConfigFile = new File(jeiConfigurationDir, "itemBlacklist.cfg"); final File searchColorsConfigFile = new File(jeiConfigurationDir, "searchColors.cfg"); final File worldConfigFile = new File(jeiConfigurationDir, "worldSettings.cfg"); + final File bookmarksConfigFile = new File(jeiConfigurationDir, "bookmarks.cfg"); + worldConfig = new Configuration(worldConfigFile, "0.1.0"); { @@ -257,10 +267,12 @@ public static void preInit(FMLPreInitializationEvent event) { config = new LocalizedConfiguration(configKeyPrefix, configFile, "0.2.0"); itemBlacklistConfig = new LocalizedConfiguration(configKeyPrefix, itemBlacklistConfigFile, "0.1.0"); searchColorsConfig = new LocalizedConfiguration(configKeyPrefix, searchColorsConfigFile, "0.1.0"); + bookmarksConfig = new LocalizedConfiguration(configKeyPrefix, bookmarksConfigFile, "0.1.0"); syncConfig(); syncItemBlacklistConfig(); syncSearchColorsConfig(); + syncBookmarksConfig(); } public static boolean syncAllConfig() { @@ -315,7 +327,7 @@ private static boolean syncConfig() { searchCategory.remove("prefixRequiredForCreativeTabSearch"); searchCategory.remove("prefixRequiredForColorSearch"); - SearchMode[] searchModes = SearchMode.values(); + SearchMode[] searchModes = SearchMode.values(); modNameSearchMode = config.getEnum("modNameSearchMode", CATEGORY_SEARCH, defaultModNameSearchMode, searchModes); tooltipSearchMode = config.getEnum("tooltipSearchMode", CATEGORY_SEARCH, defaultTooltipSearchMode, searchModes); oreDictSearchMode = config.getEnum("oreDictSearchMode", CATEGORY_SEARCH, defaultOreDictSearchMode, searchModes); @@ -402,6 +414,42 @@ private static boolean syncItemBlacklistConfig() { return configChanged; } + private static boolean syncBookmarksConfig() { + if (bookmarksConfig == null) { + return false; + } + + bookmarksConfig.addCategory(CATEGORY_ADVANCED); + + bookmarks = bookmarksConfig.getStringList("bookmarks", CATEGORY_ADVANCED, defaultBookmarks); + + final boolean configChanged = bookmarksConfig.hasChanged(); + if (configChanged) { + bookmarksConfig.save(); + } + return configChanged; + } + + public static boolean updateBookmarks(String[] bookmarkIds) { + bookmarks = bookmarkIds; + if (bookmarksConfig == null) { + return false; + } + Property property = bookmarksConfig.get(CATEGORY_ADVANCED, "bookmarks", defaultBookmarks); + + property.set(bookmarks); + + boolean changed = bookmarksConfig.hasChanged(); + if (changed) { + bookmarksConfig.save(); + } + return changed; + } + + public static String[] getBookmarks() { + return bookmarks; + } + public static boolean syncWorldConfig() { if (worldConfig == null) { return false; diff --git a/src/main/java/mezz/jei/config/KeyBindings.java b/src/main/java/mezz/jei/config/KeyBindings.java index a3de57ec5..ede6b23ef 100644 --- a/src/main/java/mezz/jei/config/KeyBindings.java +++ b/src/main/java/mezz/jei/config/KeyBindings.java @@ -15,6 +15,7 @@ public class KeyBindings { public static final KeyBinding showUses = new KeyBinding("key.jei.showUses", KeyConflictContext.GUI, Keyboard.KEY_U, categoryName); public static final KeyBinding recipeBack = new KeyBinding("key.jei.recipeBack", KeyConflictContext.GUI, Keyboard.KEY_BACK, categoryName); public static final KeyBinding toggleCheatMode = new KeyBinding("key.jei.toggleCheatMode", KeyConflictContext.GUI, Keyboard.KEY_NONE, categoryName); + public static final KeyBinding toggleBookmark = new KeyBinding("key.jei.toggleBookmark", KeyConflictContext.GUI, Keyboard.KEY_A, categoryName); public static void init() { ClientRegistry.registerKeyBinding(toggleOverlay); @@ -23,5 +24,6 @@ public static void init() { ClientRegistry.registerKeyBinding(showUses); ClientRegistry.registerKeyBinding(recipeBack); ClientRegistry.registerKeyBinding(toggleCheatMode); + ClientRegistry.registerKeyBinding(toggleBookmark); } } diff --git a/src/main/java/mezz/jei/gui/ItemListOverlay.java b/src/main/java/mezz/jei/gui/ItemListOverlay.java index b12f7fee6..5bcf233fb 100644 --- a/src/main/java/mezz/jei/gui/ItemListOverlay.java +++ b/src/main/java/mezz/jei/gui/ItemListOverlay.java @@ -10,6 +10,7 @@ import mezz.jei.ItemFilter; import mezz.jei.api.IItemListOverlay; import mezz.jei.api.gui.IAdvancedGuiHandler; +import mezz.jei.api.ingredients.IIngredientBookmarks; import mezz.jei.api.ingredients.IIngredientRegistry; import mezz.jei.config.Config; import mezz.jei.util.Log; @@ -21,14 +22,16 @@ public class ItemListOverlay implements IItemListOverlay { private final List> advancedGuiHandlers; private final IIngredientRegistry ingredientRegistry; private final Set highlightedStacks = new HashSet(); + private final IIngredientBookmarks ingredientBookmarks; @Nullable private ItemListOverlayInternal internal; - public ItemListOverlay(ItemFilter itemFilter, List> advancedGuiHandlers, IIngredientRegistry ingredientRegistry) { + public ItemListOverlay(ItemFilter itemFilter, List> advancedGuiHandlers, IIngredientRegistry ingredientRegistry, IIngredientBookmarks ingredientBookmarks) { this.itemFilter = itemFilter; this.advancedGuiHandlers = advancedGuiHandlers; this.ingredientRegistry = ingredientRegistry; + this.ingredientBookmarks = ingredientBookmarks; } @Nullable @@ -132,4 +135,8 @@ public void close() { } internal = null; } + + public IIngredientBookmarks getIngredientBookmarks() { + return ingredientBookmarks; + } } diff --git a/src/main/java/mezz/jei/gui/ItemListOverlayInternal.java b/src/main/java/mezz/jei/gui/ItemListOverlayInternal.java index 13c6bc61f..821b1a6ca 100644 --- a/src/main/java/mezz/jei/gui/ItemListOverlayInternal.java +++ b/src/main/java/mezz/jei/gui/ItemListOverlayInternal.java @@ -67,6 +67,7 @@ public class ItemListOverlayInternal implements IShowsRecipeFocuses, IMouseHandl private final GuiButton nextButton; private final GuiButton backButton; private final GuiButton configButton; + private final GuiButton clearButton; private final IDrawable configButtonIcon; private final IDrawable configButtonCheatIcon; private final HoverChecker configButtonHoverChecker; @@ -77,6 +78,7 @@ public class ItemListOverlayInternal implements IShowsRecipeFocuses, IMouseHandl private int pageNumDisplayY; private final GuiIngredientFastList guiIngredientList; + private final GuiIngredientFastList guiBookmarks; @Nullable private GuiIngredientFast hovered = null; @@ -88,6 +90,7 @@ public class ItemListOverlayInternal implements IShowsRecipeFocuses, IMouseHandl public ItemListOverlayInternal(ItemListOverlay parent, IIngredientRegistry ingredientRegistry, GuiScreen guiScreen, GuiProperties guiProperties) { this.parent = parent; + this.guiBookmarks = new GuiIngredientFastList(ingredientRegistry); this.guiIngredientList = new GuiIngredientFastList(ingredientRegistry); this.guiProperties = guiProperties; @@ -111,10 +114,15 @@ public ItemListOverlayInternal(ItemListOverlay parent, IIngredientRegistry ingre final int itemButtonsHeight = rows * itemStackHeight; final int buttonStartY = buttonSize + (2 * borderPadding) + (yItemButtonSpace - itemButtonsHeight) / 2; + // this renders the items gui createItemButtons(guiIngredientList, guiAreas, leftEdge, buttonStartY, columns, rows); + // Alight with bottom of clear button + createItemButtons(guiBookmarks, guiAreas, 0, guiProperties.getGuiTop() + buttonSize, columns, rows); nextButton = new GuiButton(0, rightEdge - buttonSize, borderPadding, buttonSize, buttonSize, nextLabel); backButton = new GuiButton(1, leftEdge, borderPadding, buttonSize, buttonSize, backLabel); + // align with the top of inventory gui + clearButton = new GuiButton(3, 0, guiProperties.getGuiTop(), buttonSize * 3, buttonSize, "CLEAR"); final int searchFieldX; final int searchFieldY = guiProperties.getScreenHeight() - searchHeight - borderPadding - 2; @@ -236,6 +244,9 @@ public void updateLayout() { ImmutableList ingredientList = parent.getItemFilter().getIngredientList(); guiIngredientList.set(firstItemIndex, ingredientList); + List bookmarkList = parent.getIngredientBookmarks().getIngredientList(); + guiBookmarks.set(0, bookmarkList); + FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj; pageNumDisplayString = (getPageNum() + 1) + "/" + getPageCount(); @@ -292,6 +303,7 @@ public void drawScreen(Minecraft minecraft, int mouseX, int mouseY) { nextButton.drawButton(minecraft, mouseX, mouseY); backButton.drawButton(minecraft, mouseX, mouseY); configButton.drawButton(minecraft, mouseX, mouseY); + clearButton.drawButton(minecraft, mouseX, mouseY); IDrawable icon = Config.isCheatItemsEnabled() ? configButtonCheatIcon : configButtonIcon; icon.draw(minecraft, configButton.xPosition + 2, configButton.yPosition + 2); @@ -305,6 +317,12 @@ public void drawScreen(Minecraft minecraft, int mouseX, int mouseY) { hovered = guiIngredientList.render(minecraft, mouseOver, mouseX, mouseY); } + if (hovered == null) { + hovered = guiBookmarks.render(minecraft, isMouseOver(mouseX, mouseY), mouseX, mouseY); + } else { + guiBookmarks.render(minecraft, isMouseOver(mouseX, mouseY), mouseX, mouseY); + } + Set highlightedStacks = parent.getHighlightedStacks(); if (!highlightedStacks.isEmpty()) { StackHelper helper = Internal.getHelpers().getStackHelper(); @@ -316,6 +334,14 @@ public void drawScreen(Minecraft minecraft, int mouseX, int mouseY) { } } } + for (GuiIngredientFast guiItemStack : guiBookmarks.getAllGuiIngredients()) { + Object ingredient = guiItemStack.getIngredient(); + if (ingredient instanceof ItemStack) { + if (helper.containsStack(highlightedStacks, (ItemStack) ingredient) != null) { + guiItemStack.drawHighlight(); + } + } + } } if (hovered != null) { @@ -366,16 +392,24 @@ public void handleTick() { @Override public boolean isMouseOver(int mouseX, int mouseY) { - if (mouseX < guiProperties.getGuiLeft() + guiProperties.getGuiXSize()) { - return isSearchBarCentered(guiProperties) && - (searchField.isMouseOver(mouseX, mouseY) || configButtonHoverChecker.checkHover(mouseX, mouseY)); + // Clickable area is anywhere outside of the inventory screen. Should probably + // narrow this down, but I don't know how do detect other mods that might be + // using the screen. + if (mouseX > guiProperties.getGuiLeft() && mouseX < guiProperties.getGuiLeft() + guiProperties.getGuiXSize() + && mouseY > guiProperties.getGuiTop() && mouseY < guiProperties.getGuiTop() + guiProperties.getGuiYSize()) { + return false; } + // if (mouseX < guiProperties.getGuiLeft() + guiProperties.getGuiXSize()) { + // return isSearchBarCentered(guiProperties) && + // (searchField.isMouseOver(mouseX, mouseY) || + // configButtonHoverChecker.checkHover(mouseX, mouseY)); + // } - for (Rectangle guiArea : guiAreas) { - if (guiArea.contains(mouseX, mouseY)) { - return false; - } - } + // for (Rectangle guiArea : guiAreas) { + // if (guiArea.contains(mouseX, mouseY)) { + // return false; + // } + // } return true; } @@ -391,8 +425,15 @@ public IClickedIngredient getIngredientUnderMouse(int mouseX, int mouseY) { if (clicked != null) { setKeyboardFocus(false); clicked.setAllowsCheating(); + return clicked; } - return clicked; + clicked = guiBookmarks.getIngredientUnderMouse(mouseX, mouseY); + if (clicked != null) { + setKeyboardFocus(false); + clicked.setAllowsCheating(); + return clicked; + } + return null; } @Override @@ -465,6 +506,11 @@ private boolean handleMouseClickedButtons(int mouseX, int mouseY) { } } return true; + } else if (clearButton.mousePressed(minecraft, mouseX, mouseY)) { + clearButton.playPressSound(minecraft.getSoundHandler()); + parent.getIngredientBookmarks().clear(); + updateLayout(); + return true; } return false; } @@ -504,6 +550,7 @@ public boolean onKeyPressed(char typedChar, int keyCode) { return false; } + // Finds the right edge of the inventory screen private static int getItemButtonXSpace(GuiProperties guiProperties) { return guiProperties.getScreenWidth() - (guiProperties.getGuiLeft() + guiProperties.getGuiXSize() + (2 * borderPadding)); } @@ -512,6 +559,7 @@ private static int getItemButtonYSpace(GuiProperties guiProperties) { if (isSearchBarCentered(guiProperties)) { return guiProperties.getScreenHeight() - (buttonSize + (3 * borderPadding)); } + // finds the height of the list screen area minus the search and the buttons return guiProperties.getScreenHeight() - (buttonSize + searchHeight + 2 + (4 * borderPadding)); } @@ -577,6 +625,13 @@ public ImmutableList getVisibleStacks() { visibleStacks.add(itemStack); } } + for (GuiIngredientFast guiItemStack : guiBookmarks.getAllGuiIngredients()) { + Object ingredient = guiItemStack.getIngredient(); + if (ingredient instanceof ItemStack) { + ItemStack itemStack = (ItemStack) ingredient; + visibleStacks.add(itemStack); + } + } return visibleStacks.build(); } diff --git a/src/main/java/mezz/jei/input/InputHandler.java b/src/main/java/mezz/jei/input/InputHandler.java index 19d7d249b..845bd177d 100644 --- a/src/main/java/mezz/jei/input/InputHandler.java +++ b/src/main/java/mezz/jei/input/InputHandler.java @@ -6,6 +6,7 @@ import mezz.jei.JeiRuntime; import mezz.jei.RecipeRegistry; +import mezz.jei.api.ingredients.IIngredientBookmarks; import mezz.jei.api.ingredients.IIngredientHelper; import mezz.jei.api.ingredients.IIngredientRegistry; import mezz.jei.api.recipe.IFocus; @@ -25,6 +26,7 @@ import net.minecraft.item.ItemStack; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; +import net.minecraftforge.fluids.FluidStack; public class InputHandler { private final RecipeRegistry recipeRegistry; @@ -34,6 +36,7 @@ public class InputHandler { private final ItemListOverlayInternal itemListOverlayInternal; private final MouseHelper mouseHelper; private final List showsRecipeFocuses = new ArrayList(); + private final IIngredientBookmarks ingredientBookmarks; private boolean clickHandled = false; @@ -42,6 +45,7 @@ public InputHandler(JeiRuntime runtime, @Nullable ItemListOverlayInternal itemLi this.ingredientRegistry = runtime.getIngredientRegistry(); this.recipesGui = runtime.getRecipesGui(); this.itemListOverlayInternal = itemListOverlayInternal; + this.ingredientBookmarks = runtime.getIngredientBookmarks(); this.mouseHelper = new MouseHelper(); @@ -217,6 +221,7 @@ private boolean handleKeyDown(char typedChar, int eventKey) { if (!isContainerTextFieldFocused()) { final boolean showRecipe = KeyBindings.showRecipe.isActiveAndMatches(eventKey); final boolean showUses = KeyBindings.showUses.isActiveAndMatches(eventKey); + final boolean toggleBookmark = KeyBindings.toggleBookmark.isActiveAndMatches(eventKey); if (showRecipe || showUses) { IClickedIngredient clicked = getIngredientUnderMouseForKey(mouseHelper.getX(), mouseHelper.getY()); if (clicked != null) { @@ -226,6 +231,16 @@ private boolean handleKeyDown(char typedChar, int eventKey) { } } + if (toggleBookmark) { + // get the bookmarks list and add or remove the clicked ingredient + IClickedIngredient clicked = getIngredientUnderMouseForKey(mouseHelper.getX(), mouseHelper.getY()); + if (clicked != null) { + ingredientBookmarks.toggleIngredientBookmark(clicked.getValue()); + itemListOverlayInternal.updateLayout(); + return true; + } + } + if (itemListOverlayInternal != null && itemListOverlayInternal.onKeyPressed(typedChar, eventKey)) { return true; } diff --git a/src/main/resources/assets/jei/lang/ar_SA.lang b/src/main/resources/assets/jei/lang/ar_SA.lang index c4efdfc67..be8e81e16 100644 --- a/src/main/resources/assets/jei/lang/ar_SA.lang +++ b/src/main/resources/assets/jei/lang/ar_SA.lang @@ -27,6 +27,7 @@ key.jei.showRecipe=أظهر وصفات العناصر key.jei.showUses=أظهر فوائد العناصر key.jei.recipeBack=أظهر صفحة العناصر السابقة key.jei.toggleCheatMode=تبديل وضع غش العناصر +key.jei.toggleBookmark=تبديل الإشارة المرجعية # Config config.jei.default=الأصلي diff --git a/src/main/resources/assets/jei/lang/cs_CZ.lang b/src/main/resources/assets/jei/lang/cs_CZ.lang index 99f9e148c..076facad9 100644 --- a/src/main/resources/assets/jei/lang/cs_CZ.lang +++ b/src/main/resources/assets/jei/lang/cs_CZ.lang @@ -27,6 +27,7 @@ key.jei.showRecipe=Zobrazit recept key.jei.showUses=Zobrazit použití key.jei.recipeBack=Zobrazit předchozí stránku key.jei.toggleCheatMode=Ovládat s Cheat Módem +key.jei.toggleBookmark=Přepnout záložku # Config config.jei.default=Výchozí diff --git a/src/main/resources/assets/jei/lang/de_DE.lang b/src/main/resources/assets/jei/lang/de_DE.lang index 1608342d5..59708c1b7 100644 --- a/src/main/resources/assets/jei/lang/de_DE.lang +++ b/src/main/resources/assets/jei/lang/de_DE.lang @@ -31,6 +31,7 @@ key.jei.showRecipe=Zeige Rezept key.jei.showUses=Zeige Verwendung key.jei.recipeBack=Zeige vorherige Rezeptseite key.jei.toggleCheatMode=Item-Cheating (de-)aktivieren +key.jei.toggleBookmark=Lesezeichen (de-)aktivieren # Config config.jei.default=Standard diff --git a/src/main/resources/assets/jei/lang/el_GR.lang b/src/main/resources/assets/jei/lang/el_GR.lang index 1a7dbc750..541c3fff6 100644 --- a/src/main/resources/assets/jei/lang/el_GR.lang +++ b/src/main/resources/assets/jei/lang/el_GR.lang @@ -28,6 +28,7 @@ key.jei.showRecipe=Δείξε Συνταγή Αντικειμένου key.jei.showUses=Δείξε Χρήσεις Αντικειμένου key.jei.recipeBack=Δείξε Προηγούμενη Σελίδα Συνταγών key.jei.toggleCheatMode=Ενάλλαξε Λειτουργία Cheat Αντικειμένων +key.jei.toggleBookmark=Εναλλαγή Σελιδοδείκτη # Config config.jei.default=Αρχικό diff --git a/src/main/resources/assets/jei/lang/en_US.lang b/src/main/resources/assets/jei/lang/en_US.lang index 75790131d..c1c1e604a 100644 --- a/src/main/resources/assets/jei/lang/en_US.lang +++ b/src/main/resources/assets/jei/lang/en_US.lang @@ -31,6 +31,7 @@ key.jei.showRecipe=Show Item Recipe key.jei.showUses=Show Item Uses key.jei.recipeBack=Show Previous Recipe Page key.jei.toggleCheatMode=Toggle Item Cheating Mode +key.jei.toggleBookmark=Toggle Bookmark # Config config.jei.default=Default diff --git a/src/main/resources/assets/jei/lang/he_IL.lang b/src/main/resources/assets/jei/lang/he_IL.lang index 2e182dacf..660f6793a 100644 --- a/src/main/resources/assets/jei/lang/he_IL.lang +++ b/src/main/resources/assets/jei/lang/he_IL.lang @@ -28,6 +28,7 @@ key.jei.showRecipe=הצג מתכונים לחפצים key.jei.showUses=הצג שימוש של חפצים key.jei.recipeBack=הצג עמוד חפצים קודם key.jei.toggleCheatMode=הפעל.הפסק מצב רמאות חפצים +key.jei.toggleBookmark=הפעל/הפסק סימניה # Config config.jei.default=ברירת מחדל diff --git a/src/main/resources/assets/jei/lang/it_IT.lang b/src/main/resources/assets/jei/lang/it_IT.lang index 4dd698f43..ececaa2b9 100644 --- a/src/main/resources/assets/jei/lang/it_IT.lang +++ b/src/main/resources/assets/jei/lang/it_IT.lang @@ -27,6 +27,7 @@ key.jei.showRecipe=Mostra la ricetta dell'item key.jei.showUses=Mostra gli usi dell'item key.jei.recipeBack=Torna alla ricetta precedente key.jei.toggleCheatMode=(Dis)attiva la modalita' cheat +key.jei.toggleBookmark=(Dis)attiva segnalibro # Config config.jei.default=Default diff --git a/src/main/resources/assets/jei/lang/ja_JP.lang b/src/main/resources/assets/jei/lang/ja_JP.lang index b6628bb94..cc9a34fb7 100644 --- a/src/main/resources/assets/jei/lang/ja_JP.lang +++ b/src/main/resources/assets/jei/lang/ja_JP.lang @@ -31,6 +31,7 @@ key.jei.showRecipe=アイテムのレシピの表示 key.jei.showUses=アイテムの用途の表示 key.jei.recipeBack=前のレシピページに戻る key.jei.toggleCheatMode=チートモードのオン/オフ +key.jei.toggleBookmark=ブックマークの切り替え # Config config.jei.default=デフォルト diff --git a/src/main/resources/assets/jei/lang/ko_KR.lang b/src/main/resources/assets/jei/lang/ko_KR.lang index d170cfa16..2eefa0259 100644 --- a/src/main/resources/assets/jei/lang/ko_KR.lang +++ b/src/main/resources/assets/jei/lang/ko_KR.lang @@ -28,6 +28,7 @@ key.jei.showRecipe=아이템 조합법 보기 key.jei.showUses=아이템 사용법 보기 key.jei.recipeBack=이전 아이템 조합법 보기 key.jei.toggleCheatMode=아이템 치트 모드 켜기/끄기 +key.jei.toggleBookmark=즐겨찾기 전환 # Config config.jei.default=기본값 diff --git a/src/main/resources/assets/jei/lang/pl_PL.lang b/src/main/resources/assets/jei/lang/pl_PL.lang index 76fda2202..4159d9d97 100644 --- a/src/main/resources/assets/jei/lang/pl_PL.lang +++ b/src/main/resources/assets/jei/lang/pl_PL.lang @@ -27,6 +27,7 @@ key.jei.showRecipe=Pokaż recepturę key.jei.showUses=Pokaż zastosowanie key.jei.recipeBack=Pokaż poprzednią stronę key.jei.toggleCheatMode=Włącz tryb duplikacji przedmiotu +key.jei.toggleBookmark=Przełącz zakładkę # Config config.jei.default=Domyślny diff --git a/src/main/resources/assets/jei/lang/pt_BR.lang b/src/main/resources/assets/jei/lang/pt_BR.lang index 436af03ff..22b19c2ea 100644 --- a/src/main/resources/assets/jei/lang/pt_BR.lang +++ b/src/main/resources/assets/jei/lang/pt_BR.lang @@ -29,6 +29,7 @@ key.jei.showRecipe=Mostrar Receita para o Item key.jei.showUses=Mostrar Usos do Item key.jei.recipeBack=Mostrar Página Anterior de Receitas key.jei.toggleCheatMode=Alternar Entre Modo de Trapaça de Itens +key.jei.toggleBookmark=Alternar Favorito # Config config.jei.default=Padrão diff --git a/src/main/resources/assets/jei/lang/ru_RU.lang b/src/main/resources/assets/jei/lang/ru_RU.lang index 7d79a3157..8555b4243 100644 --- a/src/main/resources/assets/jei/lang/ru_RU.lang +++ b/src/main/resources/assets/jei/lang/ru_RU.lang @@ -31,6 +31,7 @@ key.jei.showRecipe=Показывать рецепты предметов key.jei.showUses=Показывать применения предметов key.jei.recipeBack=Показать предыдущую страницу рецептов key.jei.toggleCheatMode=Переключить режим жульничества +key.jei.toggleBookmark=Переключить закладку # Config config.jei.default=По-умолчанию diff --git a/src/main/resources/assets/jei/lang/sv_SE.lang b/src/main/resources/assets/jei/lang/sv_SE.lang index abe9d59e0..179960a42 100644 --- a/src/main/resources/assets/jei/lang/sv_SE.lang +++ b/src/main/resources/assets/jei/lang/sv_SE.lang @@ -27,6 +27,7 @@ key.jei.showRecipe=Visa föremålsrecept key.jei.showUses=Visa användningar av föremål key.jei.recipeBack=Visa föregående receptsida key.jei.toggleCheatMode=Slå på/av föremålsfusk +key.jei.toggleBookmark=Växla bokmärke # Config config.jei.default=Standard diff --git a/src/main/resources/assets/jei/lang/uk_UA.lang b/src/main/resources/assets/jei/lang/uk_UA.lang index 6c35d7603..71a381c19 100644 --- a/src/main/resources/assets/jei/lang/uk_UA.lang +++ b/src/main/resources/assets/jei/lang/uk_UA.lang @@ -31,6 +31,7 @@ key.jei.showRecipe=Показувати рецепти предметів key.jei.showUses=Показувати використання предметів key.jei.recipeBack=Показувати минулу сторінку рецептів key.jei.toggleCheatMode=Перемкнути режим шахрайства +key.jei.toggleBookmark=Перемкнути закладку # Config config.jei.default=По замовчуванню diff --git a/src/main/resources/assets/jei/lang/zh_CN.lang b/src/main/resources/assets/jei/lang/zh_CN.lang index 054e9fc89..7a988832e 100644 --- a/src/main/resources/assets/jei/lang/zh_CN.lang +++ b/src/main/resources/assets/jei/lang/zh_CN.lang @@ -31,6 +31,7 @@ key.jei.showRecipe=显示物品合成表 key.jei.showUses=显示物品用途 key.jei.recipeBack=显示上一页 key.jei.toggleCheatMode=作弊模式开关 +key.jei.toggleBookmark=切换书签 # Config config.jei.default=默认 diff --git a/src/main/resources/assets/jei/lang/zh_TW.lang b/src/main/resources/assets/jei/lang/zh_TW.lang index 1dc455ef9..a9e98b8c7 100644 --- a/src/main/resources/assets/jei/lang/zh_TW.lang +++ b/src/main/resources/assets/jei/lang/zh_TW.lang @@ -31,6 +31,7 @@ key.jei.showRecipe=顯示物品合成錶 key.jei.showUses=顯示物品用途 key.jei.recipeBack=顯示上一頁 key.jei.toggleCheatMode=開關作弊模式 +key.jei.toggleBookmark=切換書籤 # Config 配寘 config.jei.default=默認