mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-17 19:15:13 +00:00
Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8870f095e1 | ||
|
|
c91f8ff386 | ||
|
|
cd1823712d | ||
|
|
e294abd0a7 | ||
|
|
69c8a653e3 | ||
|
|
f7c5b73728 | ||
|
|
c11f51624d | ||
|
|
b63b2d082b | ||
|
|
e748c6779b | ||
|
|
75e8270bad | ||
|
|
c4c7d6d055 | ||
|
|
2630d887eb | ||
|
|
f8cc9bd0e6 |
No files matched your search
@@ -468,7 +468,7 @@ public class BookmarkPanel extends PanelWidget {
|
||||
final ItemStack normalizedA = StackInfo.loadFromNBT(nbTagA);
|
||||
BookmarkRecipeId recipeId = null;
|
||||
|
||||
if (handlerName != "" && ingredients != null) {
|
||||
if (handlerName != "" && ingredients != null && !ingredients.isEmpty()) {
|
||||
recipeId = new BookmarkRecipeId(handlerName, ingredients);
|
||||
}
|
||||
|
||||
@@ -478,7 +478,7 @@ public class BookmarkPanel extends PanelWidget {
|
||||
BGrid.removeRecipe(idx, saveIngredients);
|
||||
} else {
|
||||
|
||||
if (saveIngredients && handlerName != "" && ingredients != null) {
|
||||
if (saveIngredients && handlerName != "" && ingredients != null && !ingredients.isEmpty()) {
|
||||
final Map<NBTTagCompound, Integer> unique = new HashMap<>();
|
||||
final ArrayList<NBTTagCompound> sorted = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -276,11 +276,7 @@ public class ItemsGrid {
|
||||
return listOrNull == null ? Collections.emptyList() : listOrNull;
|
||||
}
|
||||
|
||||
private void drawRecipeTooltip(int mousex, int mousey, List<String> itemTooltip) {
|
||||
if (!NEIClientConfig.isLoaded()) {
|
||||
return;
|
||||
}
|
||||
|
||||
private void drawRecipeTooltip(int mousex, int mousey) {
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
ItemPanelSlot focused = getSlotMouseOver(mousex, mousey);
|
||||
if (focused == null) {
|
||||
@@ -330,7 +326,12 @@ public class ItemsGrid {
|
||||
recipeTooltipGui.guiTop = 0;
|
||||
recipeTooltipGui.guiLeft = 0;
|
||||
}
|
||||
recipeTooltipLines = Math.max(1, itemTooltip.size());
|
||||
recipeTooltipLines = 2;
|
||||
if (focused.item != null && mc.currentScreen instanceof GuiContainer) {
|
||||
final List<String> tooltip = GuiContainerManager
|
||||
.itemDisplayNameMultiline(focused.item, (GuiContainer) mc.currentScreen, true);
|
||||
recipeTooltipLines = tooltip.size();
|
||||
}
|
||||
};
|
||||
}
|
||||
if (recipeTooltipGui == null) {
|
||||
@@ -339,12 +340,12 @@ public class ItemsGrid {
|
||||
|
||||
GL11.glPushMatrix();
|
||||
final float tooltipYOffset;
|
||||
if (mousey - marginTop > height / 2) {
|
||||
if (mousey > height / 2) {
|
||||
tooltipYOffset = mousey - recipeTooltipGui.getHeightAsWidget() + 8;
|
||||
} else {
|
||||
tooltipYOffset = mousey + ((recipeTooltipLines < 2) ? 1 : 3 + ((recipeTooltipLines - 1) * 10));
|
||||
tooltipYOffset = mousey - 7 + (recipeTooltipLines * 10);
|
||||
}
|
||||
GL11.glTranslatef(mousex, tooltipYOffset, 500);
|
||||
GL11.glTranslatef(mousex, tooltipYOffset, 100);
|
||||
|
||||
final GuiContainer gui;
|
||||
if (mc.currentScreen instanceof GuiRecipe) {
|
||||
@@ -454,12 +455,9 @@ public class ItemsGrid {
|
||||
drawSlotOutlines(mousex, mousey);
|
||||
drawItems();
|
||||
}
|
||||
}
|
||||
|
||||
public void postDrawTooltips(int mousex, int mousey, List<String> tooltip) {
|
||||
if (NEIClientConfig.showRecipeTooltips() && showRecipeTooltips) {
|
||||
try {
|
||||
drawRecipeTooltip(mousex, mousey, tooltip);
|
||||
drawRecipeTooltip(mousex, mousey);
|
||||
} catch (Exception e) {
|
||||
NEIClientConfig.logger.warn("Cannot draw recipe tooltip", e);
|
||||
}
|
||||
|
||||
@@ -280,13 +280,6 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postRenderTooltips(GuiContainer gui, int mousex, int mousey, List<String> tooltip) {
|
||||
if (!isHidden() && isEnabled()) {
|
||||
for (Widget widget : drawWidgets) widget.postDrawTooltips(mousex, mousey, tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleTooltip(GuiContainer gui, int mousex, int mousey, List<String> currenttip) {
|
||||
if (!isHidden() && isEnabled() && GuiContainerManager.shouldShowTooltip(gui)) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -191,11 +190,6 @@ public abstract class PanelWidget extends Widget {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postDrawTooltips(int mx, int my, List<String> tooltip) {
|
||||
grid.postDrawTooltips(mx, my, tooltip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(int mousex, int mousey, int button, long heldTime) {
|
||||
if (mouseDownSlot >= 0 && draggedStack == null
|
||||
|
||||
@@ -14,8 +14,6 @@ public abstract class Widget {
|
||||
|
||||
public void postDraw(int mx, int my) {}
|
||||
|
||||
public void postDrawTooltips(int mx, int my, List<String> tooltip) {}
|
||||
|
||||
public boolean handleClick(int mx, int my, int button) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -20,10 +20,6 @@ public abstract class ShortcutInputHandler {
|
||||
|
||||
public static boolean handleKeyEvent(ItemStack stackover) {
|
||||
|
||||
if (!NEIClientConfig.isLoaded()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (NEIClientConfig.isKeyHashDown("gui.overlay_hide")) {
|
||||
return hideOverlayRecipe();
|
||||
}
|
||||
@@ -71,10 +67,6 @@ public abstract class ShortcutInputHandler {
|
||||
|
||||
public static boolean handleMouseClick(ItemStack stackover) {
|
||||
|
||||
if (!NEIClientConfig.isLoaded()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (stackover != null) {
|
||||
final int button = Mouse.getEventButton();
|
||||
stackover = stackover.copy();
|
||||
|
||||
@@ -514,10 +514,6 @@ public class GuiContainerManager {
|
||||
if (tooltip.size() > 0) tooltip.set(0, tooltip.get(0) + GuiDraw.TOOLTIP_LINESPACE); // add space after 'title'
|
||||
|
||||
drawPagedTooltip(font, mousex + 12, mousey - 12, tooltip);
|
||||
|
||||
for (IContainerDrawHandler drawHandler : drawHandlers) {
|
||||
drawHandler.postRenderTooltips(window, mousex, mousey, tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
private static int tooltipPage;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package codechicken.nei.guihook;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
@@ -32,17 +30,6 @@ public interface IContainerDrawHandler {
|
||||
*/
|
||||
public void postRenderObjects(GuiContainer gui, int mousex, int mousey);
|
||||
|
||||
/**
|
||||
* Use this to draw things that should be drawn just after vanilla slot tooltips, on top of buttons and other
|
||||
* usually always-on-top widgets.
|
||||
*
|
||||
* @param gui An instance of the currentscreen
|
||||
* @param mousex The x position of the mouse in pixels from left
|
||||
* @param mousey The y position of the mouse in pixels from top
|
||||
* @param tooltip The contents of the tooltip that has previously been drawn
|
||||
*/
|
||||
default void postRenderTooltips(GuiContainer gui, int mousex, int mousey, List<String> tooltip) {}
|
||||
|
||||
/**
|
||||
* Render something over a slot before the item in the slot.
|
||||
*
|
||||
|
||||
@@ -146,29 +146,27 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
|
||||
private final int trueHeight;
|
||||
private final int trueGuiTop;
|
||||
private final GuiScreen trueGui;
|
||||
|
||||
private HeightHack() {
|
||||
trueHeight = height;
|
||||
trueGuiTop = guiTop;
|
||||
trueGui = Minecraft.getMinecraft().currentScreen;
|
||||
|
||||
isHeightHackApplied = NEIClientConfig.heightHackHandlerRegex.stream()
|
||||
.map(pattern -> pattern.matcher(handler.getHandlerId())).anyMatch(Matcher::matches);
|
||||
if (isHeightHackApplied) {
|
||||
// guiTop is the top edge of the recipe screen on the y-axis. Old recipe handlers expect a single paging
|
||||
// widget at the top and at the bottom of the recipe screen with a height of 16px each, but GTNH NEI
|
||||
// moved the bottom paging widget to the top following JEI's design, increasing the "forbidden" zone at
|
||||
// the top to 32px. To fix these old recipe handlers we move guiTop down 16px so that they can keep
|
||||
// working with the old 16px gap.
|
||||
// widget at the top and at the bottom of the recipe screen with a height of 16px, but GTNH NEI move the
|
||||
// bottom paging widget to the top following JEI's UI increasing the forbidden zone at the top to 32px.
|
||||
// To fix these old recipe handlers we move guiTop down 16px so that they can keep working with the old
|
||||
// 16px gap.
|
||||
guiTop += 16;
|
||||
|
||||
// The old NEI recipe screen had a fixed width and height and was always centered on the screen. Legacy
|
||||
// recipe handlers use the calculation ((height - 166) / 2) to compute the y-value of the top edge of
|
||||
// the NEI window. GTNH NEI changes the layout so that the recipe screen length now has a flexible
|
||||
// length and is no longer centered vertically. In order for the top-of-screen calculation to return the
|
||||
// correct result, we have to hack the height field with an inverse of the calculation using the actual
|
||||
// top of the recipe screen stored in guiTop.
|
||||
// the NEI recipe screen. GTNH NEI now has a flexible recipe screen length and is no longer centered
|
||||
// vertically, so in order for the top-of-screen calculation to return the correct result, we have to
|
||||
// hack the height field with an inverse of the calculation using the actual top of the recipe screen
|
||||
// stored in guiTop.
|
||||
height = (2 * guiTop) + 166;
|
||||
|
||||
// For reference, in case we ever need to modify width as well:
|
||||
@@ -176,12 +174,6 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
// guiWidth (the x-value of the left edge of the NEI recipe screen). So if we wanted to override width
|
||||
// as well, we'd do this:
|
||||
// width = (2 * guiWidth) + 176;
|
||||
|
||||
// Recipe handlers may assume the current screen is the GuiRecipe object, which is not the case in
|
||||
// recipe tooltips drawn on the bookmarks panel with the main inventory open.
|
||||
if (limitToOneRecipe) {
|
||||
Minecraft.getMinecraft().currentScreen = GuiRecipe.this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,7 +181,6 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
public void close() {
|
||||
guiTop = trueGuiTop;
|
||||
height = trueHeight;
|
||||
Minecraft.getMinecraft().currentScreen = trueGui;
|
||||
isHeightHackApplied = false;
|
||||
}
|
||||
}
|
||||
@@ -252,14 +243,15 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
|
||||
final int recipesPerPage = getRecipesPerPage();
|
||||
overlayButtons = new GuiButton[recipesPerPage];
|
||||
final int xOffset = limitToOneRecipe ? ((xSize / 2) - 2) : (width / 2);
|
||||
final int xOffset = limitToOneRecipe ? (xSize / 2) : (width / 2);
|
||||
final int yOffset = limitToOneRecipe ? -14 : guiTop;
|
||||
final String overlayKeyName = NEIClientConfig
|
||||
.getKeyName(NEIClientConfig.getKeyBinding("gui.overlay_use"), true);
|
||||
for (int i = 0; i < recipesPerPage; i++) {
|
||||
overlayButtons[i] = new GuiNEIButton(
|
||||
OVERLAY_BUTTON_ID_START + i,
|
||||
xOffset + 65,
|
||||
16 + (handlerInfo.getHeight() * (i + 1)) - 2,
|
||||
yOffset + 16 + (handlerInfo.getHeight() * (i + 1)) - 2,
|
||||
buttonWidth,
|
||||
buttonHeight,
|
||||
"?");
|
||||
@@ -748,7 +740,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
}
|
||||
|
||||
public int getHeightAsWidget() {
|
||||
return (handlerInfo == null) ? ySize : (handlerInfo.getHeight() + 56);
|
||||
return (handlerInfo == null) ? ySize : (handlerInfo.getHeight() + 40);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user