mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-18 19:39:06 +00:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79660a09d5 | ||
|
|
b03ae51e3c | ||
|
|
91d57c28b7 | ||
|
|
06cdea3fd6 |
No files matched your search
@@ -1285,12 +1285,21 @@ public class BookmarkPanel extends PanelWidget {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected int getHoveredGroupId() {
|
||||
public int getHoveredGroupId(boolean groupPanel) {
|
||||
final BookmarkGrid BGrid = (BookmarkGrid) grid;
|
||||
final int overRowIndex = BGrid.getHoveredRowIndex(true);
|
||||
final int overRowIndex = BGrid.getHoveredRowIndex(groupPanel);
|
||||
return overRowIndex >= 0 ? BGrid.getRowGroupId(overRowIndex) : -1;
|
||||
}
|
||||
|
||||
public void removeGroup(int groupId) {
|
||||
final BookmarkGrid BGrid = (BookmarkGrid) grid;
|
||||
|
||||
if (groupId >= 0 || groupId < BGrid.groups.size()) {
|
||||
BGrid.removeGroup(groupId);
|
||||
saveBookmarks();
|
||||
}
|
||||
}
|
||||
|
||||
protected String getNamespaceLabelText(boolean shortFormat) {
|
||||
String activePage = String.valueOf(activeNamespaceIndex + 1);
|
||||
|
||||
@@ -1951,32 +1960,6 @@ public class BookmarkPanel extends PanelWidget {
|
||||
return super.handleTooltip(mx, my, tooltip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleKeyPress(int keyID, char keyChar) {
|
||||
|
||||
if (NEIClientConfig.isKeyHashDown("gui.bookmark_pull_items")) {
|
||||
return this.pullBookmarkItems(this.getHoveredGroupId(), false);
|
||||
}
|
||||
|
||||
if (NEIClientConfig.isKeyHashDown("gui.bookmark_pull_items_ingredients")) {
|
||||
return this.pullBookmarkItems(this.getHoveredGroupId(), true);
|
||||
}
|
||||
|
||||
if (NEIClientConfig.isKeyHashDown("gui.bookmark_recipe")) {
|
||||
final BookmarkGrid BGrid = (BookmarkGrid) grid;
|
||||
final int overRowIndex = BGrid.getHoveredRowIndex(true);
|
||||
|
||||
if (overRowIndex >= 0) {
|
||||
BGrid.removeGroup(BGrid.getRowGroupId(overRowIndex));
|
||||
saveBookmarks();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return super.handleKeyPress(keyID, keyChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseUp(int mousex, int mousey, int button) {
|
||||
|
||||
@@ -2005,6 +1988,7 @@ public class BookmarkPanel extends PanelWidget {
|
||||
|
||||
this.mouseDownSlot = -1;
|
||||
this.groupingItem = null;
|
||||
grid.onItemsChanged(); /* make sure grid redraws the new item */
|
||||
saveBookmarks();
|
||||
} else {
|
||||
super.mouseUp(mousex, mousey, button);
|
||||
@@ -2092,7 +2076,7 @@ public class BookmarkPanel extends PanelWidget {
|
||||
* meta.factor;
|
||||
|
||||
if (count <= Integer.MAX_VALUE) {
|
||||
return StackInfo.loadFromNBT(nbTag, Math.max((int) count, 0));
|
||||
return StackInfo.loadFromNBT(nbTag, Math.max(count, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2109,7 +2093,7 @@ public class BookmarkPanel extends PanelWidget {
|
||||
|
||||
final BookmarkGrid BGrid = (BookmarkGrid) grid;
|
||||
final ArrayList<ItemStack> items = new ArrayList<>();
|
||||
final ItemStackMap<Integer> uniqueItems = new ItemStackMap<>();
|
||||
final ItemStackMap<Long> uniqueItems = new ItemStackMap<>();
|
||||
final BookmarkGroup group = groupId >= 0 ? BGrid.groups.get(groupId) : null;
|
||||
ItemStackMetadata meta;
|
||||
|
||||
@@ -2121,16 +2105,21 @@ public class BookmarkPanel extends PanelWidget {
|
||||
|
||||
if (!onlyIngredients || meta.ingredient && (group == null || group.crafting == null
|
||||
|| group.crafting.inputs.containsKey(BGrid.realItems.get(idx)))) {
|
||||
final NBTTagCompound nbTag = StackInfo.itemStackToNBT(stack);
|
||||
uniqueItems.put(stack, uniqueItems.getOrDefault(stack, 0) + nbTag.getInteger("Count"));
|
||||
uniqueItems.put(
|
||||
stack,
|
||||
uniqueItems.getOrDefault(stack, 0L) + StackInfo.itemStackToNBT(stack).getInteger("Count"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
for (ItemStackMap.Entry<Integer> entry : uniqueItems.entries()) {
|
||||
final NBTTagCompound nbTag = StackInfo.itemStackToNBT(entry.key);
|
||||
items.add(StackInfo.loadFromNBT(nbTag, entry.value));
|
||||
for (ItemStackMap.Entry<Long> entry : uniqueItems.entries()) {
|
||||
if (entry.value > 0) {
|
||||
items.add(
|
||||
StackInfo.loadFromNBT(
|
||||
StackInfo.itemStackToNBT(entry.key),
|
||||
Math.min(entry.value, 9 * 4 * entry.key.getMaxStackSize())));
|
||||
}
|
||||
}
|
||||
|
||||
if (items.isEmpty()) {
|
||||
|
||||
@@ -35,6 +35,23 @@ public abstract class ShortcutInputHandler {
|
||||
return hideOverlayRecipe();
|
||||
}
|
||||
|
||||
if (NEIClientConfig.isKeyHashDown("gui.bookmark_pull_items")) {
|
||||
return ItemPanels.bookmarkPanel.pullBookmarkItems(ItemPanels.bookmarkPanel.getHoveredGroupId(true), false);
|
||||
}
|
||||
|
||||
if (NEIClientConfig.isKeyHashDown("gui.bookmark_pull_items_ingredients")) {
|
||||
return ItemPanels.bookmarkPanel.pullBookmarkItems(ItemPanels.bookmarkPanel.getHoveredGroupId(true), true);
|
||||
}
|
||||
|
||||
if (stackover == null && NEIClientConfig.isKeyHashDown("gui.bookmark_recipe")) {
|
||||
final int groupId = ItemPanels.bookmarkPanel.getHoveredGroupId(true);
|
||||
|
||||
if (groupId != -1) {
|
||||
ItemPanels.bookmarkPanel.removeGroup(groupId);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (stackover == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package codechicken.nei.recipe;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.fontRenderer;
|
||||
import static codechicken.nei.NEIClientUtils.translate;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
@@ -31,6 +30,7 @@ import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.Button;
|
||||
import codechicken.nei.GuiNEIButton;
|
||||
import codechicken.nei.LayoutManager;
|
||||
import codechicken.nei.NEICPH;
|
||||
@@ -248,6 +248,28 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
|
||||
};
|
||||
|
||||
protected static Button toggleSearch = new Button() {
|
||||
|
||||
@Override
|
||||
public boolean onButtonPress(boolean rightclick) {
|
||||
if (rightclick) return false;
|
||||
|
||||
if (searchField.isVisible()) {
|
||||
searchField.setText("");
|
||||
searchField.setFocus(false);
|
||||
searchField.setVisible(false);
|
||||
state = 0;
|
||||
} else {
|
||||
searchField.setVisible(true);
|
||||
searchField.setFocus(true);
|
||||
state = 2;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* This will only be true iff height hacking has been configured for the current recipe handler AND we are currently
|
||||
* within the scope of an active {@link CompatibilityHacks} instance.
|
||||
@@ -395,6 +417,9 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
nextpage = new GuiNEIButton(2, leftButtonX, guiTop + 17, buttonWidth, buttonHeight, "<");
|
||||
prevpage = new GuiNEIButton(3, rightButtonX, guiTop + 17, buttonWidth, buttonHeight, ">");
|
||||
|
||||
toggleSearch.icon = new DrawableBuilder("nei:textures/nei_sprites.png", 0, 38, 8, 8).setTextureSize(128, 128)
|
||||
.build();
|
||||
|
||||
buttonList.addAll(Arrays.asList(nexttype, prevtype, nextpage, prevpage));
|
||||
|
||||
if (currenthandlers.size() == 1) {
|
||||
@@ -484,6 +509,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
if (!limitToOneRecipe) {
|
||||
searchField.setText("");
|
||||
searchField.setVisible(false);
|
||||
toggleSearch.state = 0;
|
||||
}
|
||||
|
||||
page = Math.min(Math.max(0, recipe), handler.numRecipes() - 1) / getRecipesPerPage();
|
||||
@@ -648,19 +674,14 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
protected void mouseClicked(int mousex, int mousey, int button) {
|
||||
|
||||
if (!limitToOneRecipe && handler != null && IRecipeFilterProvider.filteringAvailable(handler)) {
|
||||
if (new Rectangle(borderPadding + buttonWidth - 2, 15, xSize - (borderPadding + buttonWidth) * 2 + 2, 16)
|
||||
.contains(mousex - guiLeft, mousey - guiTop)) {
|
||||
searchField.setVisible(true);
|
||||
if (toggleSearch.contains(mousex - guiLeft, mousey - guiTop)) {
|
||||
toggleSearch.handleClick(mousex - guiLeft, mousey - guiTop, button);
|
||||
} else if (searchField.contains(mousex - guiLeft, mousey - guiTop)) {
|
||||
searchField.handleClick(mousex - guiLeft, mousey - guiTop, button);
|
||||
if (!searchField.focused()) {
|
||||
searchField.setFocus(true);
|
||||
}
|
||||
} else {
|
||||
searchField.onGuiClick(mousex - guiLeft, mousey - guiTop);
|
||||
if (searchField.text().isEmpty() && !searchField.focused()) {
|
||||
searchField.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try (CompatibilityHacks compatibilityHacks = new CompatibilityHacks()) {
|
||||
@@ -753,14 +774,15 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
}
|
||||
recipeTabs.handleTooltip(mousex, mousey, currenttip);
|
||||
|
||||
if (currenttip.isEmpty()
|
||||
&& new Rectangle(borderPadding + buttonWidth - 2, 15, xSize - (borderPadding + buttonWidth) * 2 + 2, 16)
|
||||
if (currenttip.isEmpty() && searchField.isVisible()
|
||||
&& new Rectangle(searchField.x + searchField.w, 15, 44, 16)
|
||||
.contains(mousex - guiLeft, mousey - guiTop)) {
|
||||
|
||||
if (!searchField.isVisible() && IRecipeFilterProvider.filteringAvailable(handler)) {
|
||||
currenttip.add(translate("recipe.search.show"));
|
||||
}
|
||||
final String s = String.format("%d/%d", page + 1, (handler.numRecipes() - 1) / getRecipesPerPage() + 1);
|
||||
|
||||
if (fontRendererObj.getStringWidth(s) >= 45) {
|
||||
currenttip.add(s);
|
||||
}
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
@@ -845,9 +867,13 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
checkYShift();
|
||||
|
||||
if (!limitToOneRecipe) {
|
||||
toggleSearch.w = toggleSearch.h = 12;
|
||||
toggleSearch.x = borderPadding + buttonWidth;
|
||||
toggleSearch.y = 17;
|
||||
|
||||
searchField.y = 16;
|
||||
searchField.x = borderPadding + buttonWidth - 2;
|
||||
searchField.w = xSize - (borderPadding + buttonWidth) * 2 + 1 - 45;
|
||||
searchField.x = borderPadding + buttonWidth + toggleSearch.w - 1;
|
||||
searchField.w = xSize - (borderPadding + buttonWidth) * 2 + 1 - toggleSearch.w - 45;
|
||||
searchField.h = 14;
|
||||
}
|
||||
|
||||
@@ -940,7 +966,11 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
String s = handler.getRecipeName().trim();
|
||||
fontRendererObj.drawStringWithShadow(s, (xSize - fontRendererObj.getStringWidth(s)) / 2, 5, 0xffffff);
|
||||
|
||||
if (!limitToOneRecipe && searchField.isVisible()) {
|
||||
if (IRecipeFilterProvider.filteringAvailable(handler)) {
|
||||
toggleSearch.draw(mouseX - guiLeft, mouseY - guiTop);
|
||||
}
|
||||
|
||||
if (searchField.isVisible()) {
|
||||
searchField.draw(mouseX - guiLeft, mouseY - guiTop);
|
||||
s = NEIClientUtils.cropText(
|
||||
fontRendererObj,
|
||||
@@ -1143,10 +1173,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
@Override
|
||||
public boolean handleDragNDrop(GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button) {
|
||||
|
||||
if (!limitToOneRecipe && handler != null
|
||||
&& new Rectangle(borderPadding + buttonWidth - 2, 15, xSize - (borderPadding + buttonWidth) * 2 + 2, 16)
|
||||
.contains(mousex - guiLeft, mousey - guiTop)
|
||||
&& IRecipeFilterProvider.filteringAvailable(handler)) {
|
||||
if (searchField.isVisible() && searchField.contains(mousex - guiLeft, mousey - guiTop)) {
|
||||
final FluidStack fluidStack = StackInfo.getFluid(draggedStack);
|
||||
|
||||
if (fluidStack != null) {
|
||||
@@ -1155,7 +1182,6 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
searchField.setText(formattingText(draggedStack.getDisplayName()));
|
||||
}
|
||||
|
||||
searchField.setVisible(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,6 @@ import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import codechicken.core.TaskProfiler;
|
||||
import codechicken.nei.ItemList;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
@@ -91,8 +89,9 @@ class RecipeHandlerQuery<T extends IRecipeHandler> {
|
||||
}
|
||||
|
||||
private boolean isHidden(T handler) {
|
||||
final String handlerId = Objects.firstNonNull(handler.getOverlayIdentifier(), handler.getHandlerId());
|
||||
return NEIClientConfig.hiddenHandlers.stream().anyMatch(h -> h.equals(handlerId));
|
||||
final String handlerName = handler.getHandlerId();
|
||||
final String handlerId = handler.getOverlayIdentifier();
|
||||
return NEIClientConfig.hiddenHandlers.stream().anyMatch(h -> h.equals(handlerId) || h.equals(handlerName));
|
||||
}
|
||||
|
||||
private void printLog(Throwable t) {
|
||||
|
||||
@@ -64,7 +64,7 @@ public class StackInfo {
|
||||
|
||||
if (nbtTag != null) {
|
||||
nbtTag = (NBTTagCompound) nbtTag.copy();
|
||||
nbtTag.setInteger("Count", Math.max(customCount <= Integer.MAX_VALUE ? (int) customCount : 0, 0));
|
||||
nbtTag.setInteger("Count", (int) Math.max(Math.min(customCount, Integer.MAX_VALUE), 0));
|
||||
return loadFromNBT(nbtTag);
|
||||
}
|
||||
|
||||
|
||||
@@ -288,7 +288,6 @@ nei.options.tools.dump.handlers.mode.1=Json
|
||||
|
||||
nei.recipe.page=Page %s/%s
|
||||
nei.recipe.tooltip=Recipes
|
||||
nei.recipe.search.show=Click to Search
|
||||
nei.recipe.shaped=Shaped Crafting
|
||||
nei.recipe.shapeless=Shapeless Crafting
|
||||
nei.recipe.furnace=Smelting
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 34 KiB |
Reference in new issue
Block a user