mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-17 02:55:04 +00:00
Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c6cc8b693 | ||
|
|
43ae1b613a | ||
|
|
402c4325a6 | ||
|
|
550e85c456 | ||
|
|
1673079cbb | ||
|
|
e6174c446a | ||
|
|
869b4571b0 | ||
|
|
35f5400ecb | ||
|
|
1e2801c891 | ||
|
|
1b3b495fec | ||
|
|
2844ea35bc | ||
|
|
c020ecbf1f |
No files matched your search
@@ -33,12 +33,10 @@ body:
|
||||
description: What Java version are you using? It's worth mentioning that if you play on Java9+ you should try update to latest minor release (e.g. prefer Java 17.0.6 over 17.0.2) of that version.
|
||||
options:
|
||||
- Java 8
|
||||
- Java 9
|
||||
- Java 11
|
||||
- Java 17
|
||||
- Java 19
|
||||
- Java 20
|
||||
- Java 21
|
||||
- java 25
|
||||
- java 26
|
||||
- Other (Please Specify)
|
||||
validations:
|
||||
required: true
|
||||
|
||||
@@ -572,7 +572,7 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
|
||||
|
||||
return;
|
||||
} else if (this.sortableGroup != null) {
|
||||
final int overRowIndex = grid.getRowIndex(mousey);
|
||||
final int overRowIndex = Math.min(grid.getRowIndex(mousey), grid.getRows() - 1);
|
||||
|
||||
if (overRowIndex >= 0 && this.sortableGroup.groupId != this.grid.getRowGroupId(overRowIndex)) {
|
||||
this.grid.moveGroup(this.sortableGroup, overRowIndex);
|
||||
@@ -1105,7 +1105,7 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
|
||||
}
|
||||
|
||||
if (super.onMouseWheel(shift, mousex, mousey)) {
|
||||
final int overRowIndex = grid.getRowIndex(mousey);
|
||||
final int overRowIndex = Math.min(grid.getRowIndex(mousey), grid.getRows() - 1);
|
||||
|
||||
if (this.sortableGroup != null && overRowIndex >= 0
|
||||
&& this.sortableGroup.groupId != this.grid.getRowGroupId(overRowIndex)) {
|
||||
|
||||
@@ -111,8 +111,14 @@ public class ItemZoom extends Widget implements IContainerInputHandler {
|
||||
this.xPosition = (availableAreaWidth - this.scale * SLOT_SIZE) / 2;
|
||||
this.availableAreaWidth = (int) (availableAreaWidth / screenScale);
|
||||
|
||||
if (availableAreaWidth / screenScale >= mouse.x) {
|
||||
this.xPosition += gui.width * screenScale - availableAreaWidth;
|
||||
final float rightSideShift = gui.width * screenScale - availableAreaWidth;
|
||||
final boolean leftSideFree = availableAreaWidth / screenScale < mouse.x;
|
||||
final boolean rightSideFree = mouse.x < gui.width - availableAreaWidth / screenScale;
|
||||
|
||||
final boolean showOnRight = leftSideFree && rightSideFree ? !preferLeftSide() : !leftSideFree;
|
||||
|
||||
if (showOnRight) {
|
||||
this.xPosition += rightSideShift;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -128,6 +134,22 @@ public class ItemZoom extends Widget implements IContainerInputHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean preferLeftSide() {
|
||||
switch (NEIClientConfig.getIntSetting("inventory.itemzoom.preferredSide")) {
|
||||
case 1:
|
||||
return true;
|
||||
case 2:
|
||||
return false;
|
||||
}
|
||||
|
||||
final int leftCount = NEIClientConfig.isBookmarkPanelHidden()
|
||||
|| ItemPanels.bookmarkPanel.getGrid().getPerPage() == 0 ? 0 : ItemPanels.bookmarkPanel.getGrid().size();
|
||||
final int rightCount = ItemPanels.itemPanel.getGrid().getPerPage() == 0 ? 0
|
||||
: ItemPanels.itemPanel.getGrid().size();
|
||||
|
||||
return leftCount <= rightCount;
|
||||
}
|
||||
|
||||
private float getPointSize(GuiContainer gui) {
|
||||
final float screenScale = 1.0f / getScreenScale();
|
||||
final float availableAreaWidth = (gui.width - (gui.xSize + gui.width) / 2) * screenScale;
|
||||
|
||||
@@ -167,7 +167,7 @@ public class ItemsTooltipLineHandler implements ITooltipLineHandler {
|
||||
protected int activeStackIndex = -1;
|
||||
protected Dimension size = new Dimension();
|
||||
|
||||
protected final boolean showNames;
|
||||
protected int maxNamedRows = Integer.MAX_VALUE;
|
||||
|
||||
protected int length = 0;
|
||||
protected int rows = 0;
|
||||
@@ -175,29 +175,25 @@ public class ItemsTooltipLineHandler implements ITooltipLineHandler {
|
||||
protected int gridColumns = 0;
|
||||
protected int gridCount = 0;
|
||||
|
||||
public static ItemsTooltipLineHandler grid(String label, List<ItemStack> items, int maxRows) {
|
||||
return new ItemsTooltipLineHandler(label, items, true, maxRows, false);
|
||||
}
|
||||
|
||||
public static ItemsTooltipLineHandler list(String label, List<ItemStack> items, int maxRows) {
|
||||
return new ItemsTooltipLineHandler(label, items, true, maxRows, true);
|
||||
public static ItemsTooltipLineHandler of(String label, List<ItemStack> items, int maxRows, int maxNamedRows) {
|
||||
return new ItemsTooltipLineHandler(label, items, true, maxRows, maxNamedRows);
|
||||
}
|
||||
|
||||
public ItemsTooltipLineHandler(String label, List<ItemStack> items) {
|
||||
this(label, items, true, DEFAULT_MAX_ROWS, false);
|
||||
this(label, items, true, DEFAULT_MAX_ROWS, 0);
|
||||
}
|
||||
|
||||
public ItemsTooltipLineHandler(String label, List<ItemStack> items, boolean saveStackSize, int maxRows) {
|
||||
this(label, items, saveStackSize, maxRows, false);
|
||||
this(label, items, saveStackSize, maxRows, 0);
|
||||
}
|
||||
|
||||
protected ItemsTooltipLineHandler(String label, List<ItemStack> items, boolean saveStackSize, int maxRows,
|
||||
boolean showNames) {
|
||||
int maxNamedRows) {
|
||||
this.label = label;
|
||||
this.items = groupingItemStacks(items);
|
||||
this.amountRenderer = saveStackSize ? new TotalAmountRenderer() : new NoAmountRenderer();
|
||||
this.length = this.items.size();
|
||||
this.showNames = showNames;
|
||||
this.maxNamedRows = maxNamedRows;
|
||||
|
||||
setMaxRows(maxRows);
|
||||
}
|
||||
@@ -214,7 +210,7 @@ public class ItemsTooltipLineHandler implements ITooltipLineHandler {
|
||||
this.names.clear();
|
||||
this.nameRows = 0;
|
||||
|
||||
if (!this.showNames || !layoutWithNames(maxRows)) {
|
||||
if (!layoutWithNames(maxRows)) {
|
||||
layoutAsGrid(maxRows);
|
||||
}
|
||||
|
||||
@@ -228,7 +224,7 @@ public class ItemsTooltipLineHandler implements ITooltipLineHandler {
|
||||
}
|
||||
|
||||
protected boolean layoutWithNames(int maxRows) {
|
||||
final int maxNames = this.length <= maxRows ? this.length : maxRows - 1;
|
||||
final int maxNames = Math.min(this.maxNamedRows, this.length <= maxRows ? this.length : maxRows - 1);
|
||||
final int[] lineWidth = new int[maxNames + 1];
|
||||
lineWidth[0] = labelWidth();
|
||||
|
||||
|
||||
@@ -200,6 +200,11 @@ public class NEIClientConfig {
|
||||
tag.getTag("inventory.bookmarks.showRecipeMarkerMode").setComment("Show Recipe Marker").getIntValue(0);
|
||||
API.addOption(new OptionCycled("inventory.bookmarks.showRecipeMarkerMode", 3, true));
|
||||
|
||||
tag.getTag("inventory.bookmarks.maxVerticalTooltipRows")
|
||||
.setComment("Max rows in vertical crafting chain tooltip lists (0 - disable, always use grid)")
|
||||
.getIntValue(12);
|
||||
API.addOption(new OptionIntegerField("inventory.bookmarks.maxVerticalTooltipRows", 0, 50));
|
||||
|
||||
tag.getTag("inventory.bookmarks.recipeMarkerColor").setComment("Color of the icon marker")
|
||||
.getHexValue(0xADADAD);
|
||||
API.addOption(
|
||||
@@ -267,6 +272,11 @@ public class NEIClientConfig {
|
||||
.getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.guirecipe.scrollPages", true));
|
||||
|
||||
tag.getTag("inventory.guirecipe.freezeCycleOnHover")
|
||||
.setComment("Stop cycling the recipe while hovering over an ingredient or a button")
|
||||
.getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.guirecipe.freezeCycleOnHover", true));
|
||||
|
||||
tag.getTag("inventory.guirecipe.profile").getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.guirecipe.profile", true));
|
||||
|
||||
@@ -372,6 +382,11 @@ public class NEIClientConfig {
|
||||
tag.getTag("inventory.itemzoom.onlySolid").getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.itemzoom.onlySolid", true));
|
||||
|
||||
tag.getTag("inventory.itemzoom.preferredSide")
|
||||
.setComment("Which side to prefer showing the zoomed item on, when both sides are free.")
|
||||
.getIntValue(0);
|
||||
API.addOption(new OptionCycled("inventory.itemzoom.preferredSide", 3, true));
|
||||
|
||||
tag.getTag("inventory.itemzoom.helpText")
|
||||
.setComment("Display name \"Item Zoom\" and the hotkey to toggle this mod below the zoomed item.")
|
||||
.getBooleanValue(true);
|
||||
@@ -1106,6 +1121,10 @@ public class NEIClientConfig {
|
||||
return getIntSetting("inventory.bookmarks.showRecipeMarkerMode");
|
||||
}
|
||||
|
||||
public static int getMaxVerticalTooltipRows() {
|
||||
return getIntSetting("inventory.bookmarks.maxVerticalTooltipRows");
|
||||
}
|
||||
|
||||
public static boolean showItemQuantityWidget() {
|
||||
return getBooleanSetting("inventory.showItemQuantityWidget");
|
||||
}
|
||||
@@ -1166,6 +1185,10 @@ public class NEIClientConfig {
|
||||
return getBooleanSetting("inventory.guirecipe.cycledIngredientsTooltip");
|
||||
}
|
||||
|
||||
public static boolean freezeCycleOnHover() {
|
||||
return getBooleanSetting("inventory.guirecipe.freezeCycleOnHover");
|
||||
}
|
||||
|
||||
public static boolean requireShiftForOverlayRecipe() {
|
||||
return getBooleanSetting("inventory.guirecipe.shiftOverlayRecipe");
|
||||
}
|
||||
|
||||
@@ -361,7 +361,7 @@ public class PositionedStack implements Cloneable {
|
||||
return;
|
||||
}
|
||||
|
||||
FluidDrawer.drawFluid(
|
||||
FluidDrawer.drawTank(
|
||||
this.relx,
|
||||
this.rely,
|
||||
this.width,
|
||||
|
||||
@@ -445,7 +445,7 @@ public class SearchTokenParser {
|
||||
final char ch = input.charAt(index);
|
||||
|
||||
if (!insideQuotes && delimiters.indexOf(ch) >= 0
|
||||
&& (!space || index == 0 || input.charAt(index - 1) == ' ')) {
|
||||
&& (!space || index == 0 || input.charAt(index - 1) == ' ' || lastEnd == index)) {
|
||||
|
||||
if (lastEnd == index) {
|
||||
token += String.valueOf(ch);
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
@@ -33,6 +34,7 @@ import codechicken.nei.SubsetWidget.SubsetTag;
|
||||
import codechicken.nei.api.IRecipeFilter.IRecipeFilterProvider;
|
||||
import codechicken.nei.api.ItemFilter.ItemFilterProvider;
|
||||
import codechicken.nei.config.Option;
|
||||
import codechicken.nei.item.FluidDrawer;
|
||||
import codechicken.nei.recipe.CatalystInfo;
|
||||
import codechicken.nei.recipe.GuiCraftingRecipe;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
@@ -375,6 +377,16 @@ public class API {
|
||||
StackInfo.stackStringifyHandlers.add(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the default rendering of a fluid in NEI fluid display slots and fluid tanks.
|
||||
*
|
||||
* @param fluid the fluid to render
|
||||
* @param renderer the renderer, or null to restore the default rendering
|
||||
*/
|
||||
public static void registerFluidRenderer(Fluid fluid, IFluidRenderer renderer) {
|
||||
FluidDrawer.registerFluidRenderer(fluid, renderer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an association between an ingredient and what it can craft. (i.e. Furnace ItemStack -> Smelting and Fuel
|
||||
* Recipes) Allows players to see what ingredient they need to craft in order to make recipes from a recipe
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package codechicken.nei.api;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
/**
|
||||
* Custom renderer for a fluid, used by NEI fluid display slots and fluid tanks in recipes.
|
||||
* <p>
|
||||
* Register with {@link API#registerFluidRenderer(Fluid, IFluidRenderer)}.
|
||||
*/
|
||||
public interface IFluidRenderer {
|
||||
|
||||
/**
|
||||
* Renders one 16x16 tile of the fluid. Partial tiles of a tank are clipped by NEI. The amount overlay is drawn by
|
||||
* NEI.
|
||||
*/
|
||||
void renderFluid(Fluid fluid, int x, int y);
|
||||
}
|
||||
@@ -19,7 +19,6 @@ import codechicken.nei.BookmarkContainerInfo;
|
||||
import codechicken.nei.FavoriteRecipes;
|
||||
import codechicken.nei.ItemPanels;
|
||||
import codechicken.nei.ItemQuantityField;
|
||||
import codechicken.nei.ItemsGrid.ItemsGridSlot;
|
||||
import codechicken.nei.KeyManager;
|
||||
import codechicken.nei.LayoutManager;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
@@ -38,6 +37,7 @@ import codechicken.nei.recipe.GuiCraftingRecipe;
|
||||
import codechicken.nei.recipe.GuiFavoriteButton;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.GuiUsageRecipe;
|
||||
import codechicken.nei.recipe.HoveredRecipe;
|
||||
import codechicken.nei.recipe.Recipe;
|
||||
import codechicken.nei.recipe.Recipe.RecipeId;
|
||||
import codechicken.nei.recipe.RecipeHandlerRef;
|
||||
@@ -415,41 +415,37 @@ public abstract class ShortcutInputHandler {
|
||||
|
||||
private static Recipe getFocusedRecipe(ItemStack stackover, int mousex, int mousey, boolean useFavorites) {
|
||||
final GuiContainer gui = NEIClientUtils.getGuiContainer();
|
||||
Recipe recipe = null;
|
||||
|
||||
if (useFavorites) {
|
||||
ItemsGridSlot itemSlot = ItemPanels.itemPanel.getSlotMouseOver(mousex, mousey);
|
||||
|
||||
if (itemSlot == null) {
|
||||
itemSlot = ItemPanels.itemPanel.historyPanel.getSlotMouseOver(mousex, mousey);
|
||||
}
|
||||
|
||||
if (itemSlot == null) {
|
||||
itemSlot = ItemPanels.itemPanel.craftablesPanel.getSlotMouseOver(mousex, mousey);
|
||||
}
|
||||
|
||||
if (itemSlot != null) {
|
||||
final RecipeId recipeId = itemSlot.getRecipeId();
|
||||
|
||||
if (recipeId != null && (recipe = Recipe.of(recipeId)) != null) {
|
||||
|
||||
recipe.getIngredients().stream().forEach(ingr -> {
|
||||
final List<ItemStack> permutations = ingr.getPermutations();
|
||||
for (int index = 0; index < permutations.size(); index++) {
|
||||
if (FavoriteRecipes.contains(permutations.get(index))) {
|
||||
ingr.setActiveIndex(index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
if (gui instanceof GuiRecipe<?>guiRecipe) {
|
||||
final Recipe focusedRecipe = guiRecipe.getFocusedRecipe();
|
||||
|
||||
if (focusedRecipe != null) {
|
||||
return focusedRecipe;
|
||||
}
|
||||
}
|
||||
|
||||
if (gui instanceof GuiRecipe<?>guiRecipe) {
|
||||
recipe = guiRecipe.getFocusedRecipe();
|
||||
if (!useFavorites) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final HoveredRecipe hovered = HoveredRecipe.of(gui, stackover);
|
||||
|
||||
if (hovered == null || hovered.source != HoveredRecipe.Source.ITEM_PANEL) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final Recipe recipe = Recipe.of(hovered.recipeId);
|
||||
|
||||
if (recipe != null) {
|
||||
recipe.getIngredients().stream().forEach(ingr -> {
|
||||
final List<ItemStack> permutations = ingr.getPermutations();
|
||||
for (int index = 0; index < permutations.size(); index++) {
|
||||
if (FavoriteRecipes.contains(permutations.get(index))) {
|
||||
ingr.setActiveIndex(index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return recipe;
|
||||
@@ -529,7 +525,9 @@ public abstract class ShortcutInputHandler {
|
||||
}
|
||||
|
||||
final BookmarksGridSlot slot = ItemPanels.bookmarkPanel.getSlotMouseOver(mousex, mousey);
|
||||
final RecipeId recipeId = getHotkeyRecipeId(gui, mousex, mousey, stack, slot);
|
||||
final HoveredRecipe hovered = HoveredRecipe.of(gui, stack);
|
||||
final RecipeId recipeId = hovered == null || hovered.source == HoveredRecipe.Source.OTHER
|
||||
|| hovered.source == HoveredRecipe.Source.BOOKMARK && hovered.favorite ? null : hovered.recipeId;
|
||||
|
||||
if (slot != null) {
|
||||
final BookmarkGroup group = slot.getGroup();
|
||||
@@ -729,36 +727,4 @@ public abstract class ShortcutInputHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private static RecipeId getHotkeyRecipeId(GuiContainer gui, int mousex, int mousey, ItemStack stack,
|
||||
BookmarksGridSlot slot) {
|
||||
|
||||
if (slot != null) {
|
||||
return slot.getType() == BookmarkItemType.INGREDIENT ? null : slot.getRecipeId();
|
||||
}
|
||||
|
||||
ItemsGridSlot itemSlot = ItemPanels.itemPanel.getSlotMouseOver(mousex, mousey);
|
||||
|
||||
if (itemSlot == null) {
|
||||
itemSlot = ItemPanels.itemPanel.historyPanel.getSlotMouseOver(mousex, mousey);
|
||||
}
|
||||
|
||||
if (itemSlot == null) {
|
||||
itemSlot = ItemPanels.itemPanel.craftablesPanel.getSlotMouseOver(mousex, mousey);
|
||||
}
|
||||
|
||||
if (itemSlot != null) {
|
||||
return itemSlot.getRecipeId();
|
||||
}
|
||||
|
||||
if (gui instanceof GuiRecipe<?>guiRecipe) {
|
||||
final Recipe focusedRecipe = guiRecipe.getFocusedRecipe();
|
||||
|
||||
if (focusedRecipe != null) {
|
||||
return focusedRecipe.getRecipeId();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import static org.objectweb.asm.Opcodes.ILOAD;
|
||||
import static org.objectweb.asm.Opcodes.INVOKESPECIAL;
|
||||
import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL;
|
||||
import static org.objectweb.asm.Opcodes.IRETURN;
|
||||
import static org.objectweb.asm.Opcodes.NEW;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -22,11 +23,14 @@ import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.FieldInsnNode;
|
||||
import org.objectweb.asm.tree.InsnList;
|
||||
import org.objectweb.asm.tree.InsnNode;
|
||||
import org.objectweb.asm.tree.MethodInsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
import org.objectweb.asm.tree.TypeInsnNode;
|
||||
import org.objectweb.asm.tree.VarInsnNode;
|
||||
|
||||
import codechicken.lib.asm.ASMBlock;
|
||||
@@ -98,6 +102,48 @@ public class NEITransformer implements IClassTransformer {
|
||||
}
|
||||
});
|
||||
|
||||
if (Boolean.getBoolean("nei.recipeOrigins")) {
|
||||
// Replace the plain ArrayList CraftingManager's constructor builds its recipe list with, so every recipe
|
||||
// added anywhere (including vanilla's own, added in that same constructor) is observed for
|
||||
// codechicken.nei.recipe.debug.RecipeOrigins. Must be done at classload time, since by the time any mod
|
||||
// code runs vanilla has already populated the list. Capturing a stack trace per recipe is slow, so this is
|
||||
// opt-in via -Dnei.recipeOrigins=true.
|
||||
transformer.add(
|
||||
new MethodTransformer(
|
||||
new ObfMapping("net/minecraft/item/crafting/CraftingManager", "<init>", "()V")) {
|
||||
|
||||
@Override
|
||||
public void transform(MethodNode mv) {
|
||||
ASMHelper.logger.debug("NEI: Hooking CraftingManager recipe list for origin tracking");
|
||||
|
||||
TypeInsnNode newInsn = null;
|
||||
MethodInsnNode initInsn = null;
|
||||
|
||||
// only the first ArrayList construction, the recipe list field
|
||||
for (AbstractInsnNode insn : mv.instructions.toArray()) {
|
||||
if (newInsn == null) {
|
||||
if (insn.getOpcode() == NEW
|
||||
&& "java/util/ArrayList".equals(((TypeInsnNode) insn).desc)) {
|
||||
newInsn = (TypeInsnNode) insn;
|
||||
}
|
||||
} else if (insn.getOpcode() == INVOKESPECIAL
|
||||
&& "java/util/ArrayList".equals(((MethodInsnNode) insn).owner)
|
||||
&& "<init>".equals(((MethodInsnNode) insn).name)) {
|
||||
initInsn = (MethodInsnNode) insn;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (newInsn == null || initInsn == null) {
|
||||
ASMHelper.logger.warn("NEI: CraftingManager recipe list not found, origins disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
newInsn.desc = initInsn.owner = "codechicken/nei/recipe/debug/RecipeOrigins$TrackingList";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// put glint alpha into the buffer correctly for exporting
|
||||
transformer.add(
|
||||
new MethodReplacer(
|
||||
|
||||
@@ -799,6 +799,7 @@ public class BookmarkGrid extends ItemsGrid<BookmarksGridSlot, BookmarkGrid.Book
|
||||
sortableGroup.groupId = groupId;
|
||||
this.onItemsChanged();
|
||||
this.getMask();// force generate grid
|
||||
overGroupId = getRowGroupId(overRowIndex);
|
||||
}
|
||||
|
||||
if (sortableGroup.groupId == overGroupId) {
|
||||
|
||||
@@ -198,6 +198,11 @@ public class BookmarkStorage {
|
||||
final BookmarkItem item = BookmarkItem.of(parser.parse(itemStr).getAsJsonObject());
|
||||
|
||||
if (item != null) {
|
||||
|
||||
if (!grid.groups.containsKey(item.groupId)) {
|
||||
item.groupId = BookmarkGrid.DEFAULT_GROUP_ID;
|
||||
}
|
||||
|
||||
grid.addItem(item, false);
|
||||
} else {
|
||||
wasError = true;
|
||||
|
||||
@@ -162,7 +162,7 @@ public class GuiCraftingTree extends GuiContainer implements INEIGuiHandler, IGu
|
||||
final ItemTreeSlot replaceNode = this.uiState.replaceRecipeNode;
|
||||
this.uiState.replaceRecipeNode = null;
|
||||
|
||||
if (recipe != null) {
|
||||
if (recipe != null && this.grid.getGroup(this.groupId) != null) {
|
||||
final RecipeId recipeId = recipe.getRecipeId();
|
||||
boolean changed = false;
|
||||
|
||||
@@ -190,6 +190,13 @@ public class GuiCraftingTree extends GuiContainer implements INEIGuiHandler, IGu
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
|
||||
// the group can be removed from the bookmark panel while a recipe screen opened from this tree is shown
|
||||
if (this.grid.getGroup(this.groupId) == null) {
|
||||
this.mc.displayGuiScreen(this.prevGui);
|
||||
return;
|
||||
}
|
||||
|
||||
this.xSize = this.width;
|
||||
this.ySize = this.height;
|
||||
|
||||
|
||||
@@ -2,15 +2,14 @@ package codechicken.nei.item;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.nei.item.FluidDrawer.FillDirection;
|
||||
import codechicken.nei.util.ReadableNumberConverter;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -34,37 +33,13 @@ public class FluidDisplayRenderer implements IItemRenderer {
|
||||
return;
|
||||
}
|
||||
|
||||
renderIcon(item, fluidDisplay);
|
||||
renderIcon(item);
|
||||
renderAmountOverlay(item, fluidDisplay);
|
||||
}
|
||||
|
||||
private void renderIcon(ItemStack item, ItemFluidDisplay fluidDisplay) {
|
||||
final IIcon icon = fluidDisplay.getIconIndex(item);
|
||||
if (icon == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int color = fluidDisplay.getColorFromItemStack(item, 0);
|
||||
final float red = (color >> 16 & 0xFF) / 255F;
|
||||
final float green = (color >> 8 & 0xFF) / 255F;
|
||||
final float blue = (color & 0xFF) / 255F;
|
||||
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
|
||||
GL11.glColor4f(red, green, blue, 1F);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper
|
||||
.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
final Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV(0, 16, 0, icon.getMinU(), icon.getMaxV());
|
||||
tessellator.addVertexWithUV(16, 16, 0, icon.getMaxU(), icon.getMaxV());
|
||||
tessellator.addVertexWithUV(16, 0, 0, icon.getMaxU(), icon.getMinV());
|
||||
tessellator.addVertexWithUV(0, 0, 0, icon.getMinU(), icon.getMinV());
|
||||
tessellator.draw();
|
||||
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
private void renderIcon(ItemStack item) {
|
||||
final Fluid fluid = FluidRegistry.getFluid(item.getItemDamage());
|
||||
FluidDrawer.drawFluidArea(fluid != null ? fluid : FluidRegistry.WATER, 0, 0, 16, 16, false, FillDirection.UP);
|
||||
}
|
||||
|
||||
private void renderAmountOverlay(ItemStack item, ItemFluidDisplay fluidDisplay) {
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
package codechicken.nei.item;
|
||||
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.nei.api.IFluidRenderer;
|
||||
import codechicken.nei.scroll.GuiHelper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -27,28 +34,32 @@ public class FluidDrawer {
|
||||
return this == LEFT || this == RIGHT;
|
||||
}
|
||||
|
||||
public FillDirection resolve(FluidStack fluidStack) {
|
||||
public FillDirection resolve(Fluid fluid) {
|
||||
if (this != AUTO) return this;
|
||||
return fluidStack.getFluid().isGaseous(fluidStack) ? DOWN : UP;
|
||||
return fluid.isGaseous() ? DOWN : UP;
|
||||
}
|
||||
}
|
||||
|
||||
private static final Map<Fluid, IFluidRenderer> fluidRenderers = new IdentityHashMap<>();
|
||||
|
||||
private FluidDrawer() {}
|
||||
|
||||
public static void drawFluid(int x, int y, int width, int height, int capacity, FluidStack fluidStack,
|
||||
boolean flowing, FillDirection direction) {
|
||||
final Fluid fluid = fluidStack.getFluid();
|
||||
IIcon icon = flowing ? fluid.getFlowingIcon() : null;
|
||||
|
||||
if (icon == null) {
|
||||
icon = fluid.getIcon(fluidStack);
|
||||
public static void registerFluidRenderer(Fluid fluid, IFluidRenderer renderer) {
|
||||
if (renderer == null) {
|
||||
fluidRenderers.remove(fluid);
|
||||
} else {
|
||||
fluidRenderers.put(fluid, renderer);
|
||||
}
|
||||
}
|
||||
|
||||
if (icon == null || fluidStack.amount <= 0) {
|
||||
public static void drawTank(int x, int y, int width, int height, int capacity, FluidStack fluidStack,
|
||||
boolean flowing, FillDirection direction) {
|
||||
if (fluidStack.amount <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
direction = direction.resolve(fluidStack);
|
||||
final Fluid fluid = fluidStack.getFluid();
|
||||
direction = direction.resolve(fluid);
|
||||
|
||||
final int tankSize = direction.isHorizontal() ? width : height;
|
||||
final int tankCapacity = capacity > 0 ? capacity : fluidStack.amount;
|
||||
@@ -59,38 +70,109 @@ public class FluidDrawer {
|
||||
final int fillHeight = direction.isHorizontal() ? height : Math.min(fillSize, height);
|
||||
final int fillX = direction == FillDirection.LEFT ? x + width - fillWidth : x;
|
||||
final int fillY = direction == FillDirection.DOWN ? y : y + height - fillHeight;
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
drawFluidArea(fluid, fillX, fillY, fillWidth, fillHeight, flowing, direction);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills the area with fluid tiles. The tiles start from the side the fluid fills from, so a partial tile ends up at
|
||||
* the fluid surface.
|
||||
*/
|
||||
public static void drawFluidArea(Fluid fluid, int x, int y, int width, int height, boolean flowing,
|
||||
FillDirection direction) {
|
||||
direction = direction.resolve(fluid);
|
||||
final boolean anchorRight = direction == FillDirection.LEFT;
|
||||
final boolean anchorBottom = direction != FillDirection.DOWN;
|
||||
final IFluidRenderer renderer = fluidRenderers.get(fluid);
|
||||
|
||||
final int color = fluid.getColor(fluidStack);
|
||||
if (renderer == null) {
|
||||
drawDefaultFluid(fluid, x, y, width, height, flowing, anchorRight, anchorBottom);
|
||||
} else {
|
||||
drawCustomFluid(renderer, fluid, x, y, width, height, anchorRight, anchorBottom);
|
||||
}
|
||||
}
|
||||
|
||||
private static void drawCustomFluid(IFluidRenderer renderer, Fluid fluid, int x, int y, int width, int height,
|
||||
boolean anchorRight, boolean anchorBottom) {
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_LIGHTING_BIT);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
|
||||
final boolean clip = width % 16 != 0 || height % 16 != 0;
|
||||
|
||||
if (clip) {
|
||||
GuiHelper.pushScissorFrame(x, y, width, height);
|
||||
}
|
||||
|
||||
try {
|
||||
for (int tx = 0; tx < width; tx += 16) {
|
||||
final int tileX = anchorRight ? x + width - tx - 16 : x + tx;
|
||||
|
||||
for (int ty = 0; ty < height; ty += 16) {
|
||||
final int tileY = anchorBottom ? y + height - ty - 16 : y + ty;
|
||||
renderer.renderFluid(fluid, tileX, tileY);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (clip) {
|
||||
GuiHelper.popScissorFrame();
|
||||
}
|
||||
|
||||
GL11.glPopAttrib();
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
}
|
||||
}
|
||||
|
||||
private static void drawDefaultFluid(Fluid fluid, int x, int y, int width, int height, boolean flowing,
|
||||
boolean anchorRight, boolean anchorBottom) {
|
||||
IIcon icon = flowing ? fluid.getFlowingIcon() : null;
|
||||
|
||||
if (icon == null) {
|
||||
icon = fluid.getStillIcon();
|
||||
}
|
||||
|
||||
if (icon == null) {
|
||||
icon = FluidRegistry.WATER.getStillIcon();
|
||||
}
|
||||
|
||||
if (icon == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int color = fluid.getColor();
|
||||
final float red = (color >> 16 & 0xFF) / 255F;
|
||||
final float green = (color >> 8 & 0xFF) / 255F;
|
||||
final float blue = (color & 0xFF) / 255F;
|
||||
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
|
||||
GL11.glColor3f(red, green, blue);
|
||||
GL11.glColor4f(red, green, blue, 1F);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
OpenGlHelper
|
||||
.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
final double iconMinU = icon.getMinU();
|
||||
final double iconMaxU = icon.getMaxU();
|
||||
final double iconMinV = icon.getMinV();
|
||||
final double iconMaxV = icon.getMaxV();
|
||||
final Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
for (int tx = 0; tx < fillWidth; tx += 16) {
|
||||
final int tileWidth = Math.min(16, fillWidth - tx);
|
||||
for (int tx = 0; tx < width; tx += 16) {
|
||||
final int tileWidth = Math.min(16, width - tx);
|
||||
// a cropped tile keeps the texture edge that stays seamless against the neighbouring tile
|
||||
final double uSize = (icon.getMaxU() - icon.getMinU()) * tileWidth / 16D;
|
||||
final double uMin = anchorRight ? icon.getMaxU() - uSize : icon.getMinU();
|
||||
final double uMax = anchorRight ? icon.getMaxU() : icon.getMinU() + uSize;
|
||||
final int leftX = anchorRight ? fillX + fillWidth - tx - tileWidth : fillX + tx;
|
||||
final double uSize = (iconMaxU - iconMinU) * tileWidth / 16D;
|
||||
final double uMin = anchorRight ? iconMaxU - uSize : iconMinU;
|
||||
final double uMax = anchorRight ? iconMaxU : iconMinU + uSize;
|
||||
final int leftX = anchorRight ? x + width - tx - tileWidth : x + tx;
|
||||
final int rightX = leftX + tileWidth;
|
||||
|
||||
for (int ty = 0; ty < fillHeight; ty += 16) {
|
||||
final int tileHeight = Math.min(16, fillHeight - ty);
|
||||
final double vSize = (icon.getMaxV() - icon.getMinV()) * tileHeight / 16D;
|
||||
final double vMin = anchorBottom ? icon.getMaxV() - vSize : icon.getMinV();
|
||||
final double vMax = anchorBottom ? icon.getMaxV() : icon.getMinV() + vSize;
|
||||
final int bottomY = anchorBottom ? fillY + fillHeight - ty : fillY + ty + tileHeight;
|
||||
for (int ty = 0; ty < height; ty += 16) {
|
||||
final int tileHeight = Math.min(16, height - ty);
|
||||
final double vSize = (iconMaxV - iconMinV) * tileHeight / 16D;
|
||||
final double vMin = anchorBottom ? iconMaxV - vSize : iconMinV;
|
||||
final double vMax = anchorBottom ? iconMaxV : iconMinV + vSize;
|
||||
final int bottomY = anchorBottom ? y + height - ty : y + ty + tileHeight;
|
||||
final int topY = bottomY - tileHeight;
|
||||
|
||||
tessellator.addVertexWithUV(leftX, bottomY, 0, uMin, vMax);
|
||||
@@ -102,7 +184,6 @@ public class FluidDrawer {
|
||||
tessellator.draw();
|
||||
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
}
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public class ItemFluidDisplay extends Item implements IFluidContainerItem {
|
||||
@Override
|
||||
public FluidStack getFluid(ItemStack stack) {
|
||||
|
||||
if (stack == null || !(stack.getItem() instanceof ItemFluidDisplay) || !stack.hasTagCompound()) {
|
||||
if (stack == null || !(stack.getItem() instanceof ItemFluidDisplay)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public class ItemFluidDisplay extends Item implements IFluidContainerItem {
|
||||
final NBTTagCompound nbTag = stack.getTagCompound();
|
||||
final FluidStack fluidStack = new FluidStack(
|
||||
fluid,
|
||||
(int) Math.min(nbTag.getLong("neiFluidDisplayAmount"), Integer.MAX_VALUE));
|
||||
(int) Math.min(nbTag != null ? nbTag.getLong("neiFluidDisplayAmount") : 0, Integer.MAX_VALUE));
|
||||
|
||||
return fluidStack;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package codechicken.nei.recipe;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
@@ -13,14 +12,9 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.FavoriteRecipes;
|
||||
import codechicken.nei.ItemPanels;
|
||||
import codechicken.nei.ItemsGrid.ItemsGridSlot;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.bookmark.BookmarkItem.BookmarkItemType;
|
||||
import codechicken.nei.bookmark.BookmarksGridSlot;
|
||||
import codechicken.nei.recipe.Recipe.RecipeId;
|
||||
|
||||
public class GuiCraftingRecipe extends GuiRecipe<ICraftingHandler> {
|
||||
@@ -138,39 +132,8 @@ public class GuiCraftingRecipe extends GuiRecipe<ICraftingHandler> {
|
||||
}
|
||||
|
||||
public static RecipeId getRecipeId(GuiScreen gui, ItemStack stackover) {
|
||||
|
||||
if (gui instanceof GuiRecipe<?>guiRecipe) {
|
||||
final Recipe focusedRecipe = guiRecipe.getFocusedRecipe();
|
||||
|
||||
if (focusedRecipe != null) {
|
||||
return focusedRecipe.getRecipeId();
|
||||
}
|
||||
}
|
||||
|
||||
final Point mouseover = GuiDraw.getMousePosition();
|
||||
final BookmarksGridSlot panelSlot = ItemPanels.bookmarkPanel.getSlotMouseOver(mouseover.x, mouseover.y);
|
||||
|
||||
if (panelSlot != null) {
|
||||
return panelSlot.getType() == BookmarkItemType.INGREDIENT || panelSlot.getRecipeId() == null
|
||||
? FavoriteRecipes.getFavorite(stackover)
|
||||
: panelSlot.getRecipeId();
|
||||
}
|
||||
|
||||
ItemsGridSlot itemSlot = ItemPanels.itemPanel.getSlotMouseOver(mouseover.x, mouseover.y);
|
||||
|
||||
if (itemSlot == null) {
|
||||
itemSlot = ItemPanels.itemPanel.historyPanel.getSlotMouseOver(mouseover.x, mouseover.y);
|
||||
}
|
||||
|
||||
if (itemSlot == null) {
|
||||
itemSlot = ItemPanels.itemPanel.craftablesPanel.getSlotMouseOver(mouseover.x, mouseover.y);
|
||||
}
|
||||
|
||||
if (itemSlot != null) {
|
||||
return itemSlot.getRecipeId();
|
||||
}
|
||||
|
||||
return null;
|
||||
final HoveredRecipe hovered = HoveredRecipe.of(gui, stackover);
|
||||
return hovered != null ? hovered.recipeId : null;
|
||||
}
|
||||
|
||||
private GuiCraftingRecipe(ArrayList<ICraftingHandler> handlers) {
|
||||
|
||||
@@ -263,7 +263,7 @@ public class GuiOverlayButton extends GuiRecipeButton {
|
||||
|
||||
if (!items.isEmpty()) {
|
||||
this.missedMaterialsTooltipLineHandler = ItemsTooltipLineHandler
|
||||
.grid(NEIClientUtils.translate("recipe.overlay.missing"), items, Integer.MAX_VALUE);
|
||||
.of(NEIClientUtils.translate("recipe.overlay.missing"), items, Integer.MAX_VALUE, 0);
|
||||
} else {
|
||||
this.missedMaterialsTooltipLineHandler = null;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
@@ -295,73 +295,118 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
}
|
||||
|
||||
/**
|
||||
* Many old mods assumed a fixed NEI window height of {@code 166} pixels. Now that this is no longer the case, their
|
||||
* tooltip and click zone handling is broken. This helper class fixes these old mods by hacking the {@link #height}
|
||||
* property's value so that these old mods' calculations return the correct value for the new height.
|
||||
* Many old mods assumed a fixed NEI window size of {@code 176x166} pixels, with exactly one recipe shown at a time,
|
||||
* flush against the top-left corner of the window. Now that none of these assumptions hold (the window has a
|
||||
* flexible size, several recipes can be stacked in the same scrollable list, and the recipe area is inset from the
|
||||
* window's edges), these old mods' tooltip and click zone handling is broken. This helper class fixes these old
|
||||
* mods by hacking the {@link #width}, {@link #height}, {@link #guiLeft} and {@link #guiTop} properties' values so
|
||||
* that these old mods' calculations return the correct value for whichever recipe they are currently being asked
|
||||
* about.
|
||||
*
|
||||
* <p>
|
||||
* New and old mods often assume that the handler is only drawn when {@link GuiRecipe} is the currently active
|
||||
* screen in {@link net.minecraft.client.Minecraft}. This is no longer true since the addition of recipe tooltips
|
||||
* which need to render the recipe in other containers on mouse hover, this class temporarily switches the active
|
||||
* screen to {@code this} while rendering them to avoid ClassCastExceptions and other similar crashes.
|
||||
* Since each recipe handled by a {@link RecipeWidget} can sit at a different real position, this must be
|
||||
* constructed with that widget's top-left edge every time a legacy entry point ({@code mouseClicked},
|
||||
* {@code handleTooltip}, ...) is invoked for it, rather than once per {@link GuiRecipe}.
|
||||
*
|
||||
* <p>
|
||||
* This class is an {@link AutoCloseable} so that it can be used with try-with-resources, which will ensure that
|
||||
* {@link #height} and {@link net.minecraft.client.Minecraft#currentScreen} is returned to the correct value
|
||||
* {@link #width}, {@link #height}, {@link #guiLeft} and {@link #guiTop} are returned to the correct value
|
||||
* afterwards.
|
||||
*/
|
||||
private class CompatibilityHacks implements AutoCloseable {
|
||||
public static final class CompatibilityHacks implements AutoCloseable {
|
||||
|
||||
// The historical NEI recipe screen's fixed size: a single top paging widget 16px tall, no horizontal inset,
|
||||
// and a 176x166 box. Legacy handlers either read guiLeft/guiTop directly (expecting them to point 16px above
|
||||
// their recipe, flush on the left) or recompute them from width/height with these same two constants.
|
||||
private static final int LEGACY_TOP_GAP = 16;
|
||||
private static final int LEGACY_BOX_WIDTH = 176;
|
||||
private static final int LEGACY_BOX_HEIGHT = 166;
|
||||
|
||||
// layoutWindow() places the recipe container at (guiLeft + 3, guiTop + 32); RecipePageManager then places
|
||||
// each left-aligned recipe widget another 2px to the right of that. This is the inverse of both, undoing the
|
||||
// container's own inset so a legacy handler sees its recipe flush with guiLeft as it expects.
|
||||
private static final int CONTAINER_LEFT_INSET = 3 + 2;
|
||||
|
||||
private final GuiRecipe<?> gui;
|
||||
private final int trueWidth;
|
||||
private final int trueHeight;
|
||||
private final int trueGuiLeft;
|
||||
private final int trueGuiTop;
|
||||
|
||||
private CompatibilityHacks() {
|
||||
trueHeight = height;
|
||||
trueGuiTop = guiTop;
|
||||
/**
|
||||
* @param widget The recipe widget a legacy entry point ({@code mouseClicked}, {@code handleTooltip}, ...) is
|
||||
* about to be invoked for.
|
||||
*/
|
||||
public CompatibilityHacks(GuiRecipe<?> gui, RecipeWidget widget) {
|
||||
this.gui = gui;
|
||||
this.trueWidth = gui.width;
|
||||
this.trueHeight = gui.height;
|
||||
this.trueGuiLeft = gui.guiLeft;
|
||||
this.trueGuiTop = gui.guiTop;
|
||||
|
||||
isHeightHackApplied = NEIClientConfig.heightHackHandlerRegex.stream()
|
||||
.map(pattern -> pattern.matcher(handler.original.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.
|
||||
guiTop += 16;
|
||||
final String handlerId = gui.handler.original.getHandlerId();
|
||||
gui.isHeightHackApplied = NEIClientConfig.heightHackHandlerRegex.stream()
|
||||
.anyMatch(pattern -> pattern.matcher(handlerId).matches());
|
||||
|
||||
// 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.
|
||||
height = (2 * guiTop) + 166;
|
||||
|
||||
// For reference, in case we ever need to modify width as well:
|
||||
// the legacy calculation used for width is ((width - 176) / 2), which should
|
||||
// evaluate to be equal to
|
||||
// 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;
|
||||
if (gui.isHeightHackApplied) {
|
||||
gui.guiTop = recipeTop(widget) - LEGACY_TOP_GAP;
|
||||
gui.guiLeft = widget.x - CONTAINER_LEFT_INSET;
|
||||
gui.height = (2 * gui.guiTop) + LEGACY_BOX_HEIGHT;
|
||||
gui.width = (2 * gui.guiLeft) + LEGACY_BOX_WIDTH;
|
||||
}
|
||||
}
|
||||
|
||||
// recipiesPerPage() == 2 is the IRecipeHandler default: a handler only ends up with this value if it never
|
||||
// overrode the method, or if it overrode it and chose 2 on purpose. We only care about the latter case, so
|
||||
// we require the override to actually come from the handler's own class rather than being inherited as-is.
|
||||
private static final Map<Class<?>, Boolean> overridesRecipiesPerPage = new WeakHashMap<>();
|
||||
|
||||
/**
|
||||
* The real top edge of this widget's recipe, as a legacy handler following the {@link #LEGACY_TOP_GAP}
|
||||
* convention would expect to find it at guiTop. A few handlers (e.g. ImmersiveEngineering) are left over from
|
||||
* the old {@code recipiesPerPage() == 2} convention, where two recipes shared one physical page: their own
|
||||
* {@code mouseClicked}/{@code handleTooltip} still add a hardcoded "recipe height * (recipe % 2)" on top of
|
||||
* guiTop to find the odd one of the pair. Since every recipe is its own independent widget now, we pre-subtract
|
||||
* that same offset here so their own addition cancels out and lands back on this widget's real top.
|
||||
*
|
||||
* <p>
|
||||
* This only applies when the handler itself overrides {@link IRecipeHandler#recipiesPerPage()} to return
|
||||
* {@code 2}: that method defaults to {@code 2} on the interface, so most height-hacked handlers return it
|
||||
* without ever having implemented this pairing (e.g. BuildCraftCompat never overrides it at all, and only reads
|
||||
* it elsewhere to pick a cosmetic sub-name), and applying this compensation to them would break them. A handler
|
||||
* that went out of its way to declare {@code return 2;} itself is making a deliberate statement about this
|
||||
* legacy convention that a handler which simply never mentions the method isn't.
|
||||
*/
|
||||
private static int recipeTop(RecipeWidget widget) {
|
||||
final RecipeHandlerRef ref = widget.getRecipeHandlerRef();
|
||||
final HandlerInfo handlerInfo = widget.getHandlerInfo();
|
||||
final int top = widget.y + handlerInfo.getYShift();
|
||||
|
||||
if (ref.handler.recipiesPerPage() == 2 && declaresRecipiesPerPage(ref.handler)) {
|
||||
return top - handlerInfo.getHeight() * (ref.recipeIndex % 2);
|
||||
}
|
||||
|
||||
return top;
|
||||
}
|
||||
|
||||
private static boolean declaresRecipiesPerPage(IRecipeHandler handler) {
|
||||
return overridesRecipiesPerPage.computeIfAbsent(handler.getClass(), clazz -> {
|
||||
try {
|
||||
return clazz.getMethod("recipiesPerPage").getDeclaringClass() != IRecipeHandler.class;
|
||||
} catch (NoSuchMethodException e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
guiTop = trueGuiTop;
|
||||
height = trueHeight;
|
||||
this.gui.guiLeft = this.trueGuiLeft;
|
||||
this.gui.guiTop = this.trueGuiTop;
|
||||
this.gui.width = this.trueWidth;
|
||||
this.gui.height = this.trueHeight;
|
||||
|
||||
isHeightHackApplied = false;
|
||||
this.gui.isHeightHackApplied = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -698,10 +743,8 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
return;
|
||||
}
|
||||
|
||||
try (CompatibilityHacks compatibilityHacks = new CompatibilityHacks()) {
|
||||
if (this.container.handleClick(mousex, mousey, button)) {
|
||||
return;
|
||||
}
|
||||
if (this.container.handleClick(mousex, mousey, button)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.recipeTabs.mouseClicked(mousex, mousey, button)) {
|
||||
@@ -749,11 +792,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
public void mouseScrolled(int scroll) {
|
||||
// Height hacking is not necessary here since mouse scrolling is a new feature,
|
||||
// added in
|
||||
// GTNH NEI. So no old mods will use this. Though not hacking the height here
|
||||
// does mean that
|
||||
// the value of the height field will be different from in other mouseover
|
||||
// methods, which
|
||||
// could be confusing...
|
||||
// GTNH NEI. So no old mods will use this.
|
||||
|
||||
// First, invoke scroll handling over recipe handler tabbar. Makes sure it is
|
||||
// not overwritten by recipe
|
||||
@@ -766,10 +805,8 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
return;
|
||||
}
|
||||
|
||||
try (CompatibilityHacks compatibilityHacks = new CompatibilityHacks()) {
|
||||
if (this.container.onMouseWheel(scroll, mouse.x, mouse.y)) {
|
||||
return;
|
||||
}
|
||||
if (this.container.onMouseWheel(scroll, mouse.x, mouse.y)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If shift is held, try switching to the next recipe handler. Replicates the
|
||||
@@ -821,9 +858,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
currenttip = this.recipeCatalyst.handleTooltip(mousex, mousey, currenttip);
|
||||
}
|
||||
|
||||
try (CompatibilityHacks compatibilityHacks = new CompatibilityHacks()) {
|
||||
currenttip = this.container.handleTooltip(mousex, mousey, currenttip);
|
||||
}
|
||||
currenttip = this.container.handleTooltip(mousex, mousey, currenttip);
|
||||
|
||||
this.recipeTabs.handleTooltip(mousex, mousey, currenttip);
|
||||
|
||||
@@ -869,9 +904,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
hotkeys = this.recipeCatalyst.handleHotkeys(mousex, mousey, hotkeys);
|
||||
}
|
||||
|
||||
try (CompatibilityHacks compatibilityHacks = new CompatibilityHacks()) {
|
||||
hotkeys = this.container.handleHotkeys(mousex, mousey, hotkeys);
|
||||
}
|
||||
hotkeys = this.container.handleHotkeys(mousex, mousey, hotkeys);
|
||||
|
||||
return hotkeys;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
package codechicken.nei.recipe;
|
||||
|
||||
import java.awt.Point;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.FavoriteRecipes;
|
||||
import codechicken.nei.ItemPanels;
|
||||
import codechicken.nei.ItemsGrid.ItemsGridSlot;
|
||||
import codechicken.nei.bookmark.BookmarkItem.BookmarkItemType;
|
||||
import codechicken.nei.bookmark.BookmarksGridSlot;
|
||||
import codechicken.nei.recipe.Recipe.RecipeId;
|
||||
|
||||
public final class HoveredRecipe {
|
||||
|
||||
public enum Source {
|
||||
RECIPE_GUI,
|
||||
BOOKMARK,
|
||||
ITEM_PANEL,
|
||||
OTHER
|
||||
}
|
||||
|
||||
public final RecipeId recipeId;
|
||||
public final Source source;
|
||||
public final boolean favorite;
|
||||
|
||||
private HoveredRecipe(RecipeId recipeId, Source source, boolean favorite) {
|
||||
this.recipeId = recipeId;
|
||||
this.source = source;
|
||||
this.favorite = favorite;
|
||||
}
|
||||
|
||||
public static HoveredRecipe of(GuiScreen gui, ItemStack stackover) {
|
||||
|
||||
if (gui instanceof GuiRecipe<?>guiRecipe) {
|
||||
final Recipe focusedRecipe = guiRecipe.getFocusedRecipe();
|
||||
|
||||
if (focusedRecipe != null) {
|
||||
return new HoveredRecipe(focusedRecipe.getRecipeId(), Source.RECIPE_GUI, false);
|
||||
}
|
||||
}
|
||||
|
||||
final Point mouseover = GuiDraw.getMousePosition();
|
||||
final BookmarksGridSlot bookmarkSlot = ItemPanels.bookmarkPanel.getSlotMouseOver(mouseover.x, mouseover.y);
|
||||
|
||||
if (bookmarkSlot != null) {
|
||||
|
||||
if (bookmarkSlot.getType() != BookmarkItemType.INGREDIENT && bookmarkSlot.getRecipeId() != null) {
|
||||
return new HoveredRecipe(bookmarkSlot.getRecipeId(), Source.BOOKMARK, false);
|
||||
}
|
||||
|
||||
return favorite(stackover, Source.BOOKMARK);
|
||||
}
|
||||
|
||||
ItemsGridSlot itemSlot = ItemPanels.itemPanel.getSlotMouseOver(mouseover.x, mouseover.y);
|
||||
|
||||
if (itemSlot == null) {
|
||||
itemSlot = ItemPanels.itemPanel.historyPanel.getSlotMouseOver(mouseover.x, mouseover.y);
|
||||
}
|
||||
|
||||
if (itemSlot == null) {
|
||||
itemSlot = ItemPanels.itemPanel.craftablesPanel.getSlotMouseOver(mouseover.x, mouseover.y);
|
||||
}
|
||||
|
||||
if (itemSlot != null) {
|
||||
|
||||
if (itemSlot.getRecipeId() != null) {
|
||||
return new HoveredRecipe(itemSlot.getRecipeId(), Source.ITEM_PANEL, false);
|
||||
}
|
||||
|
||||
return favorite(stackover, Source.ITEM_PANEL);
|
||||
}
|
||||
|
||||
if (gui instanceof GuiRecipe<?>guiRecipe && guiRecipe.getSlotAtPosition(mouseover.x, mouseover.y) != null) {
|
||||
return favorite(stackover, Source.RECIPE_GUI);
|
||||
}
|
||||
|
||||
return favorite(stackover, Source.OTHER);
|
||||
}
|
||||
|
||||
private static HoveredRecipe favorite(ItemStack stackover, Source source) {
|
||||
final RecipeId recipeId = FavoriteRecipes.getFavorite(stackover);
|
||||
return recipeId != null ? new HoveredRecipe(recipeId, source, true) : null;
|
||||
}
|
||||
}
|
||||
@@ -7,14 +7,10 @@ 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.BookmarkPanel.BookmarkViewMode;
|
||||
import codechicken.nei.FavoriteRecipes;
|
||||
import codechicken.nei.ItemPanels;
|
||||
import codechicken.nei.ItemsGrid.ItemsGridSlot;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.api.ShortcutInputHandler;
|
||||
import codechicken.nei.bookmark.BookmarkItem.BookmarkItemType;
|
||||
import codechicken.nei.bookmark.BookmarksGridSlot;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.guihook.IContainerInputHandler;
|
||||
@@ -58,7 +54,9 @@ public class RecipeItemInputHandler implements IContainerInputHandler, IContaine
|
||||
List<String> currenttip) {
|
||||
|
||||
if (itemstack != null) {
|
||||
final RecipeId recipeId = getHoveredRecipeId(gui, itemstack, mousex, mousey);
|
||||
final HoveredRecipe hovered = HoveredRecipe.of(gui, itemstack);
|
||||
final RecipeId recipeId = hovered != null && showRecipeTooltip(hovered, mousex, mousey) ? hovered.recipeId
|
||||
: null;
|
||||
|
||||
if (recipeId == null) {
|
||||
recipeTooltipLineHandler = null;
|
||||
@@ -76,49 +74,21 @@ public class RecipeItemInputHandler implements IContainerInputHandler, IContaine
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
private RecipeId getHoveredRecipeId(GuiContainer gui, ItemStack itemstack, int mousex, int mousey) {
|
||||
private boolean showRecipeTooltip(HoveredRecipe hovered, int mousex, int mousey) {
|
||||
return switch (hovered.source) {
|
||||
case BOOKMARK -> !hovered.favorite && showRecipeTooltipInBookmarks(mousex, mousey);
|
||||
case ITEM_PANEL -> NEIClientConfig.showRecipeTooltipInPanel();
|
||||
case RECIPE_GUI -> hovered.favorite && NEIClientConfig.showRecipeTooltipInGui();
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
|
||||
if (ItemPanels.bookmarkPanel.contains(mousex, mousey)) {
|
||||
final BookmarksGridSlot slot = ItemPanels.bookmarkPanel.getSlotMouseOver(mousex, mousey);
|
||||
|
||||
if (slot != null && slot.getRecipeId() != null
|
||||
&& slot.getType() != BookmarkItemType.INGREDIENT
|
||||
&& NEIClientConfig.getRecipeTooltipsMode() != 0) {
|
||||
final int tooltipMode = NEIClientConfig.getRecipeTooltipsMode();
|
||||
final BookmarkViewMode viewMode = slot.getGroup().viewMode;
|
||||
if (tooltipMode == 3 || viewMode == BookmarkViewMode.DEFAULT && tooltipMode == 1
|
||||
|| viewMode == BookmarkViewMode.TODO_LIST && tooltipMode == 2) {
|
||||
return slot.getRecipeId();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (NEIClientConfig.showRecipeTooltipInPanel()) {
|
||||
ItemsGridSlot panelSlot = ItemPanels.itemPanel.getSlotMouseOver(mousex, mousey);
|
||||
|
||||
if (panelSlot == null) {
|
||||
panelSlot = ItemPanels.itemPanel.historyPanel.getSlotMouseOver(mousex, mousey);
|
||||
}
|
||||
|
||||
if (panelSlot == null) {
|
||||
panelSlot = ItemPanels.itemPanel.craftablesPanel.getSlotMouseOver(mousex, mousey);
|
||||
}
|
||||
|
||||
if (panelSlot != null) {
|
||||
return panelSlot.getRecipeId();
|
||||
}
|
||||
}
|
||||
|
||||
if (gui instanceof GuiRecipe<?>guiRecipe
|
||||
&& new Rectangle4i(gui.guiLeft, gui.guiTop, gui.xSize, gui.ySize).contains(mousex, mousey)
|
||||
&& NEIClientConfig.showRecipeTooltipInGui()
|
||||
&& guiRecipe.getFocusedRecipe() == null) {
|
||||
return FavoriteRecipes.getFavorite(itemstack);
|
||||
}
|
||||
|
||||
return null;
|
||||
private boolean showRecipeTooltipInBookmarks(int mousex, int mousey) {
|
||||
final BookmarksGridSlot slot = ItemPanels.bookmarkPanel.getSlotMouseOver(mousex, mousey);
|
||||
final int tooltipMode = NEIClientConfig.getRecipeTooltipsMode();
|
||||
final BookmarkViewMode viewMode = slot.getGroup().viewMode;
|
||||
return tooltipMode == 3 || viewMode == BookmarkViewMode.DEFAULT && tooltipMode == 1
|
||||
|| viewMode == BookmarkViewMode.TODO_LIST && tooltipMode == 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,6 +21,7 @@ import codechicken.nei.ItemStackAmount;
|
||||
import codechicken.nei.ItemsTooltipLineHandler;
|
||||
import codechicken.nei.ItemsTooltipLineHandler.StacksAmountRenderer;
|
||||
import codechicken.nei.ItemsTooltipLineHandler.TotalAmountRenderer;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.api.IGuiContainerOverlay;
|
||||
@@ -163,9 +164,9 @@ public class RecipeItemsTooltipLineHandler extends CompositeTooltipLineHandler {
|
||||
|
||||
protected void addResultLine(List<ItemStack> items, Set<NBTTagCompound> approximate) {
|
||||
final String label = NEIClientUtils.translate("recipe.items.results");
|
||||
final ItemsTooltipLineHandler line = items.size() == 1
|
||||
? ItemsTooltipLineHandler.list(label, items, maxLineRows())
|
||||
: ItemsTooltipLineHandler.grid(label, items, maxLineRows());
|
||||
final int maxRows = maxLineRows();
|
||||
final int maxNamedRows = items.size() == 1 ? NEIClientConfig.getMaxVerticalTooltipRows() : 0;
|
||||
final ItemsTooltipLineHandler line = ItemsTooltipLineHandler.of(label, items, maxRows, maxNamedRows);
|
||||
|
||||
if (line.isEmpty()) {
|
||||
return;
|
||||
@@ -188,7 +189,9 @@ public class RecipeItemsTooltipLineHandler extends CompositeTooltipLineHandler {
|
||||
|
||||
protected void addRequiredLine(List<ItemStack> items, Set<NBTTagCompound> approximate) {
|
||||
final String label = NEIClientUtils.translate("recipe.items.ingredients");
|
||||
final ItemsTooltipLineHandler line = ItemsTooltipLineHandler.list(label, items, maxLineRows());
|
||||
final int maxRows = maxLineRows();
|
||||
final int maxNamedRows = NEIClientConfig.getMaxVerticalTooltipRows();
|
||||
final ItemsTooltipLineHandler line = ItemsTooltipLineHandler.of(label, items, maxRows, maxNamedRows);
|
||||
|
||||
if (line.isEmpty()) {
|
||||
return;
|
||||
@@ -211,8 +214,9 @@ public class RecipeItemsTooltipLineHandler extends CompositeTooltipLineHandler {
|
||||
|
||||
protected void addNeededLine(List<ItemStack> items, Set<NBTTagCompound> approximate, boolean vertical) {
|
||||
final String label = NEIClientUtils.translate("recipe.items.ingredients_needed");
|
||||
final ItemsTooltipLineHandler line = vertical ? ItemsTooltipLineHandler.list(label, items, maxLineRows())
|
||||
: ItemsTooltipLineHandler.grid(label, items, maxLineRows());
|
||||
final int maxRows = maxLineRows();
|
||||
final int maxNamedRows = vertical ? NEIClientConfig.getMaxVerticalTooltipRows() : 0;
|
||||
final ItemsTooltipLineHandler line = ItemsTooltipLineHandler.of(label, items, maxRows, maxNamedRows);
|
||||
|
||||
if (line.isEmpty()) {
|
||||
return;
|
||||
|
||||
@@ -25,6 +25,7 @@ import codechicken.nei.ItemsTooltipLineHandler;
|
||||
import codechicken.nei.ItemsTooltipLineHandler.AmountRenderer;
|
||||
import codechicken.nei.ItemsTooltipLineHandler.StacksAmountRenderer;
|
||||
import codechicken.nei.ItemsTooltipLineHandler.TotalAmountRenderer;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.bookmark.BookmarkItem;
|
||||
import codechicken.nei.drawable.DrawableResource;
|
||||
@@ -354,8 +355,8 @@ public class RecipeChainTooltipLineHandler extends CompositeTooltipLineHandler {
|
||||
|
||||
protected void addLine(String label, List<ItemStack> items, boolean vertical, EnumChatFormatting labelColor,
|
||||
AmountRenderer amountRenderer) {
|
||||
final ItemsTooltipLineHandler line = vertical ? ItemsTooltipLineHandler.list(label, items, maxLineRows())
|
||||
: ItemsTooltipLineHandler.grid(label, items, maxLineRows());
|
||||
final int maxNamedRows = vertical ? NEIClientConfig.getMaxVerticalTooltipRows() : 0;
|
||||
final ItemsTooltipLineHandler line = ItemsTooltipLineHandler.of(label, items, maxLineRows(), maxNamedRows);
|
||||
|
||||
if (line.isEmpty()) {
|
||||
return;
|
||||
|
||||
@@ -25,6 +25,7 @@ public class CheckboxWidget extends Button implements IUpdatableWidget {
|
||||
|
||||
@Override
|
||||
public boolean onButtonPress(boolean rightclick) {
|
||||
if (this.state == 2) return false;
|
||||
this.value = !this.value;
|
||||
onChange.accept(this);
|
||||
return true;
|
||||
|
||||
@@ -30,19 +30,24 @@ import codechicken.nei.ClientHandler;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.Widget;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.drawable.DrawableBuilder;
|
||||
import codechicken.nei.drawable.DrawableResource;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.guihook.IContainerTooltipHandler;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.GuiRecipeButton;
|
||||
import codechicken.nei.recipe.GuiRecipeTab;
|
||||
import codechicken.nei.recipe.HandlerInfo;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import codechicken.nei.recipe.RecipeHandlerRef;
|
||||
import codechicken.nei.recipe.ShapedRecipeHandler;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler.RecipeTransferRect;
|
||||
import codechicken.nei.recipe.widget.RecipeWidget;
|
||||
import codechicken.nei.scroll.ScrollContainer;
|
||||
|
||||
public class DebugHandlerWidget extends Widget {
|
||||
public class DebugHandlerWidget extends Widget implements IContainerTooltipHandler {
|
||||
|
||||
private static class HandlerInfoRecord {
|
||||
|
||||
@@ -152,6 +157,9 @@ public class DebugHandlerWidget extends Widget {
|
||||
private Map<String, HandlerInfoRecord> patches = new HashMap<>();
|
||||
|
||||
private HandlerInfoRecord record;
|
||||
private RecipeWidget hoveredRecipe;
|
||||
private boolean duplicatesOnly = false;
|
||||
private String duplicatesHandlerId;
|
||||
|
||||
private Point dragPoint = null;
|
||||
private boolean showWidget = false;
|
||||
@@ -166,7 +174,9 @@ public class DebugHandlerWidget extends Widget {
|
||||
private static final int BORDER_PADDING = 6;
|
||||
private static final int TRANSPARENCY_BORDER = 4;
|
||||
|
||||
public DebugHandlerWidget() {
|
||||
protected DebugHandlerWidget() {
|
||||
GuiContainerManager.addTooltipHandler(this);
|
||||
|
||||
this.w = WINDOW_WIDTH;
|
||||
this.x = 10;
|
||||
this.y = 50;
|
||||
@@ -242,6 +252,20 @@ public class DebugHandlerWidget extends Widget {
|
||||
saveHandlerInfoPatch();
|
||||
}, y);
|
||||
|
||||
if (Boolean.getBoolean("nei.recipeOrigins")) {
|
||||
y = addCheckboxWidget("DuplicatesOnly", button -> {
|
||||
this.duplicatesOnly = button.value;
|
||||
|
||||
if (NEIClientUtils.getGuiContainer() instanceof GuiRecipe<?>recipe) {
|
||||
this.duplicatesHandlerId = getHandlerID(recipe.getHandler());
|
||||
recipe.forceRefreshPage();
|
||||
}
|
||||
}, y + LINE_HEIGHT / 2);
|
||||
|
||||
// only the handler the checkbox was toggled on is filtered, so switching handlers does not pay for a rescan
|
||||
API.addRecipeFilter(() -> this.duplicatesOnly ? this::isDuplicate : null);
|
||||
}
|
||||
|
||||
this.h = 10 + LINE_HEIGHT + y;
|
||||
this.container.h = this.h - INLINE_PADDING * 2 - LINE_HEIGHT;
|
||||
}
|
||||
@@ -417,6 +441,11 @@ public class DebugHandlerWidget extends Widget {
|
||||
|
||||
updateOverride();
|
||||
|
||||
if (this.values.get("duplicatesonly") instanceof CheckboxWidget duplicates) {
|
||||
duplicates.state = handler instanceof ShapedRecipeHandler ? 0 : 2;
|
||||
resetDuplicatesOnly();
|
||||
}
|
||||
|
||||
this.container.removeIf(
|
||||
widget -> this.values.get("height") == widget || this.values.get("height_readonly") == widget);
|
||||
if (handler.getRecipeHeight(0) > 0) {
|
||||
@@ -430,11 +459,26 @@ public class DebugHandlerWidget extends Widget {
|
||||
} else {
|
||||
this.record = null;
|
||||
this.showWidget = false;
|
||||
resetDuplicatesOnly();
|
||||
}
|
||||
|
||||
this.container.update();
|
||||
}
|
||||
|
||||
private void resetDuplicatesOnly() {
|
||||
if (!this.duplicatesOnly) return;
|
||||
|
||||
this.duplicatesOnly = false;
|
||||
|
||||
if (this.values.get("duplicatesonly") instanceof CheckboxWidget duplicates) {
|
||||
duplicates.updateValue("false");
|
||||
}
|
||||
|
||||
if (NEIClientUtils.getGuiContainer() instanceof GuiRecipe<?>recipe) {
|
||||
recipe.forceRefreshPage();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleTooltip(int mx, int my, List<String> tooltip) {
|
||||
return this.record != null ? this.container.handleTooltip(mx, my, tooltip) : tooltip;
|
||||
@@ -532,9 +576,51 @@ public class DebugHandlerWidget extends Widget {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleTooltip(GuiContainer gui, int mousex, int mousey, List<String> tooltip) {
|
||||
final RecipeWidget widget = this.hoveredRecipe;
|
||||
this.hoveredRecipe = null;
|
||||
|
||||
if (widget == null || !this.showWidget || !tooltip.isEmpty()) {
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
final RecipeHandlerRef ref = widget.getRecipeHandlerRef();
|
||||
|
||||
for (List<String> origin : RecipeOrigins.findOrigins(ref.handler, ref.recipeIndex)) {
|
||||
addOriginLines(tooltip, origin);
|
||||
}
|
||||
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
private static void addOriginLines(List<String> tooltip, List<String> lines) {
|
||||
tooltip.add(
|
||||
EnumChatFormatting.WHITE + NEIClientUtils.translate("debug.RecipeHandler.RegisteredBy", lines.get(0))
|
||||
+ GuiDraw.TOOLTIP_LINESPACE);
|
||||
|
||||
for (int i = 1; i < lines.size(); i++) {
|
||||
tooltip.add(EnumChatFormatting.GRAY + lines.get(i));
|
||||
}
|
||||
|
||||
tooltip.add("");
|
||||
}
|
||||
|
||||
// only the handler the checkbox was toggled on is filtered
|
||||
private boolean isDuplicate(IRecipeHandler handler, int recipeIndex) {
|
||||
return !getHandlerID(handler).equals(this.duplicatesHandlerId)
|
||||
|| RecipeOrigins.hasDuplicates(handler, recipeIndex);
|
||||
}
|
||||
|
||||
public void drawGuiPlaceholder(RecipeWidget widget) {
|
||||
if (!this.showWidget) return;
|
||||
|
||||
final Point mouse = GuiDraw.getMousePosition();
|
||||
if (widget.getRecipeHandlerRef().handler instanceof ShapedRecipeHandler && widget.contains(mouse.x, mouse.y)
|
||||
&& widget.getStackMouseOver(mouse.x, mouse.y) == null) {
|
||||
this.hoveredRecipe = widget;
|
||||
}
|
||||
|
||||
NEIClientUtils.gl2DRenderContext(() -> {
|
||||
|
||||
// background
|
||||
|
||||
@@ -0,0 +1,317 @@
|
||||
package codechicken.nei.recipe.debug;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.ShapedRecipes;
|
||||
import net.minecraft.item.crafting.ShapelessRecipes;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import codechicken.nei.recipe.ShapedRecipeHandler;
|
||||
import codechicken.nei.recipe.ShapedRecipeHandler.CachedShapedRecipe;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler.CachedRecipe;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
|
||||
/**
|
||||
* Tracks which mod registered each crafting recipe, so the recipe handler debug widget can show it in the recipe
|
||||
* tooltip. {@link TrackingList} is spliced in as the type of {@link CraftingManager}'s internal recipe list by
|
||||
* {@link codechicken.nei.asm.NEITransformer} (see the {@code <init>} transform there) in place of the plain
|
||||
* {@code ArrayList} vanilla constructs it with. Patching the constructor itself, rather than swapping the field later
|
||||
* on, means every single recipe is observed, including vanilla's own, which are added by that same constructor before
|
||||
* any mod code ever runs. Opt-in via {@code -Dnei.recipeOrigins=true}, since capturing a stack trace per recipe slows
|
||||
* down loading.
|
||||
*/
|
||||
public class RecipeOrigins {
|
||||
|
||||
private static final int MAX_FRAMES = 10;
|
||||
|
||||
private static final Map<IRecipe, List<String>> origins = Collections.synchronizedMap(new IdentityHashMap<>());
|
||||
|
||||
private static class OutputIndex {
|
||||
|
||||
final int size;
|
||||
final Map<Item, List<IRecipe>> byItem;
|
||||
|
||||
OutputIndex(int size, Map<Item, List<IRecipe>> byItem) {
|
||||
this.size = size;
|
||||
this.byItem = byItem;
|
||||
}
|
||||
}
|
||||
|
||||
private static final Map<CachedRecipe, List<List<String>>> cache = new WeakHashMap<>();
|
||||
|
||||
private static volatile OutputIndex outputIndex = new OutputIndex(-1, Collections.emptyMap());
|
||||
|
||||
private RecipeOrigins() {}
|
||||
|
||||
public static List<List<String>> findOrigins(IRecipeHandler handler, int recipeIndex) {
|
||||
if (!(handler instanceof ShapedRecipeHandler shaped)) return Collections.emptyList();
|
||||
|
||||
final CachedRecipe recipe = shaped.arecipes.get(recipeIndex);
|
||||
List<List<String>> found;
|
||||
|
||||
synchronized (cache) {
|
||||
found = cache.get(recipe);
|
||||
}
|
||||
|
||||
if (found == null) {
|
||||
found = findOrigins(shaped, recipe.getResult(), recipe.getIngredients());
|
||||
|
||||
synchronized (cache) {
|
||||
cache.put(recipe, found);
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
public static boolean hasDuplicates(IRecipeHandler handler, int recipeIndex) {
|
||||
return handler instanceof ShapedRecipeHandler shaped
|
||||
&& hasDuplicateCandidates(shaped.arecipes.get(recipeIndex).getResult())
|
||||
&& findOrigins(handler, recipeIndex).size() > 1;
|
||||
}
|
||||
|
||||
private static boolean hasDuplicateCandidates(PositionedStack result) {
|
||||
if (origins.isEmpty() || result == null || result.item == null) return false;
|
||||
|
||||
int count = 0;
|
||||
|
||||
for (IRecipe recipe : getRecipesByOutput(result.item.getItem())) {
|
||||
if (origins.containsKey(recipe)
|
||||
&& NEIServerUtils.areStacksSameTypeCrafting(recipe.getRecipeOutput(), result.item)
|
||||
&& ++count > 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static List<List<String>> findOrigins(ShapedRecipeHandler handler, PositionedStack result,
|
||||
List<PositionedStack> ingredients) {
|
||||
if (origins.isEmpty() || result == null || result.item == null) return Collections.emptyList();
|
||||
final List<List<String>> found = new ArrayList<>();
|
||||
|
||||
for (IRecipe recipe : getRecipesByOutput(result.item.getItem())) {
|
||||
final List<String> origin = origins.get(recipe);
|
||||
|
||||
if (origin != null && NEIServerUtils.areStacksSameTypeCrafting(recipe.getRecipeOutput(), result.item)
|
||||
&& matchesIngredients(handler, recipe, ingredients)) {
|
||||
final List<String> entry = new ArrayList<>(origin);
|
||||
entry.add(recipe.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(recipe)));
|
||||
found.add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
private static List<IRecipe> getRecipesByOutput(Item item) {
|
||||
final List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
|
||||
OutputIndex index = outputIndex;
|
||||
|
||||
if (recipes.size() != index.size) {
|
||||
synchronized (RecipeOrigins.class) {
|
||||
index = outputIndex;
|
||||
|
||||
if (recipes.size() != index.size) {
|
||||
final Map<Item, List<IRecipe>> byItem = new HashMap<>();
|
||||
|
||||
for (IRecipe recipe : recipes) {
|
||||
final ItemStack output = recipe.getRecipeOutput();
|
||||
if (output != null)
|
||||
byItem.computeIfAbsent(output.getItem(), k -> new ArrayList<>()).add(recipe);
|
||||
}
|
||||
|
||||
outputIndex = index = new OutputIndex(recipes.size(), byItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return index.byItem.getOrDefault(item, Collections.emptyList());
|
||||
}
|
||||
|
||||
private static boolean matchesIngredients(ShapedRecipeHandler handler, IRecipe recipe,
|
||||
List<PositionedStack> ingredients) {
|
||||
if (recipe instanceof ShapedRecipes shaped) {
|
||||
return matchesGrid(handler.new CachedShapedRecipe(shaped), ingredients);
|
||||
}
|
||||
if (recipe instanceof ShapedOreRecipe shaped)
|
||||
return matchesGrid(handler.forgeShapedRecipe(shaped), ingredients);
|
||||
if (recipe instanceof ShapelessRecipes shapeless) return matchesUnordered(shapeless.recipeItems, ingredients);
|
||||
if (recipe instanceof ShapelessOreRecipe shapeless) return matchesUnordered(shapeless.getInput(), ingredients);
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean matchesGrid(CachedShapedRecipe reference, List<PositionedStack> ingredients) {
|
||||
if (reference == null || reference.ingredients.size() != ingredients.size()) return false;
|
||||
|
||||
for (PositionedStack expected : reference.ingredients) {
|
||||
final PositionedStack actual = ingredients.stream()
|
||||
.filter(stack -> stack.relx == expected.relx && stack.rely == expected.rely).findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (actual == null || !matchesItems(expected.items, actual.items)) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean matchesItems(ItemStack[] expected, ItemStack[] actual) {
|
||||
for (ItemStack candidate : expected) {
|
||||
for (ItemStack item : actual) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(candidate, item)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean matchesUnordered(List<?> inputs, List<PositionedStack> ingredients) {
|
||||
final List<PositionedStack> remaining = new ArrayList<>(ingredients);
|
||||
|
||||
for (Object input : inputs) {
|
||||
if (input == null) continue;
|
||||
|
||||
final PositionedStack match = remaining.stream().filter(stack -> matchesInput(input, stack)).findFirst()
|
||||
.orElse(null);
|
||||
if (match == null) return false;
|
||||
remaining.remove(match);
|
||||
}
|
||||
|
||||
return remaining.isEmpty();
|
||||
}
|
||||
|
||||
private static boolean matchesInput(Object input, PositionedStack stack) {
|
||||
final List<?> candidates = input instanceof List<?>list ? list : Collections.singletonList(input);
|
||||
|
||||
for (Object candidate : candidates) {
|
||||
if (!(candidate instanceof ItemStack candidateStack)) continue;
|
||||
for (ItemStack item : stack.items) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(candidateStack, item)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static class TrackingList extends ArrayList<IRecipe> {
|
||||
|
||||
@Override
|
||||
public boolean add(IRecipe recipe) {
|
||||
origins.put(recipe, captureOrigin());
|
||||
return super.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int index, IRecipe recipe) {
|
||||
origins.put(recipe, captureOrigin());
|
||||
super.add(index, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipe set(int index, IRecipe recipe) {
|
||||
origins.put(recipe, captureOrigin());
|
||||
return super.set(index, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends IRecipe> recipes) {
|
||||
final List<String> origin = captureOrigin();
|
||||
for (IRecipe recipe : recipes) origins.put(recipe, origin);
|
||||
return super.addAll(recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(int index, Collection<? extends IRecipe> recipes) {
|
||||
final List<String> origin = captureOrigin();
|
||||
for (IRecipe recipe : recipes) origins.put(recipe, origin);
|
||||
return super.addAll(index, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipe remove(int index) {
|
||||
final IRecipe removed = super.remove(index);
|
||||
origins.remove(removed);
|
||||
return removed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object recipe) {
|
||||
final boolean removed = super.remove(recipe);
|
||||
if (removed) origins.remove(recipe);
|
||||
return removed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
origins.clear();
|
||||
super.clear();
|
||||
}
|
||||
}
|
||||
|
||||
private static List<String> captureOrigin() {
|
||||
final List<StackTraceElement> frames = findCallerFrames();
|
||||
|
||||
if (frames.isEmpty()) return Collections.singletonList("Unknown");
|
||||
|
||||
final ModContainer container = Loader.instance().activeModContainer();
|
||||
final List<String> lines = new ArrayList<>(frames.size() + 1);
|
||||
|
||||
lines.add(container != null ? container.getName() : "Unknown");
|
||||
|
||||
for (int i = 0; i < frames.size(); i++) {
|
||||
lines.add(formatFrame(frames.get(i)));
|
||||
}
|
||||
|
||||
return lines;
|
||||
}
|
||||
|
||||
private static String formatFrame(StackTraceElement frame) {
|
||||
return frame.getFileName() != null ? frame.getClassName() + "."
|
||||
+ frame.getMethodName()
|
||||
+ "("
|
||||
+ frame.getFileName()
|
||||
+ ":"
|
||||
+ frame.getLineNumber()
|
||||
+ ")" : frame.getClassName() + "." + frame.getMethodName();
|
||||
}
|
||||
|
||||
private static List<StackTraceElement> findCallerFrames() {
|
||||
final List<StackTraceElement> frames = new ArrayList<>(MAX_FRAMES);
|
||||
|
||||
for (StackTraceElement element : Thread.currentThread().getStackTrace()) {
|
||||
final String className = element.getClassName();
|
||||
|
||||
if (className.startsWith("java.") || className.startsWith("net.minecraft.")
|
||||
|| className.startsWith("net.minecraftforge.")
|
||||
|| className.startsWith("cpw.mods.fml.")
|
||||
|| className.startsWith("sun.")
|
||||
|| className.startsWith("jdk.")
|
||||
|| className.startsWith("org.spongepowered.")
|
||||
|| className.startsWith("codechicken.nei.recipe.debug.RecipeOrigins")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
frames.add(element);
|
||||
if (frames.size() >= MAX_FRAMES) break;
|
||||
}
|
||||
|
||||
return frames;
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,6 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
|
||||
protected static Method getFluidFromDisplayStack = null;
|
||||
protected static Class<?> gtMetaGeneratedTool = null;
|
||||
protected static Field playSound = null;
|
||||
private static boolean loggedNoNbtDisplay = false;
|
||||
|
||||
static {
|
||||
try {
|
||||
|
||||
@@ -526,7 +526,9 @@ public class RecipeWidget extends Widget {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.handler.mouseClicked(guiRecipe, button, getRecipeIndex());
|
||||
try (GuiRecipe.CompatibilityHacks hack = new GuiRecipe.CompatibilityHacks(guiRecipe, this)) {
|
||||
return this.handler.mouseClicked(guiRecipe, button, getRecipeIndex());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -550,7 +552,9 @@ public class RecipeWidget extends Widget {
|
||||
return buttonTooltip;
|
||||
}
|
||||
|
||||
return this.handler.handleTooltip(guiRecipe, tooltip, getRecipeIndex());
|
||||
try (GuiRecipe.CompatibilityHacks hack = new GuiRecipe.CompatibilityHacks(guiRecipe, this)) {
|
||||
return this.handler.handleTooltip(guiRecipe, tooltip, getRecipeIndex());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -741,7 +745,8 @@ public class RecipeWidget extends Widget {
|
||||
return true;
|
||||
}
|
||||
|
||||
return !this.showAsWidget && contains(mouseX, mouseY)
|
||||
return NEIClientConfig.freezeCycleOnHover() && !this.showAsWidget
|
||||
&& contains(mouseX, mouseY)
|
||||
&& (getPositionedStackMouseOver(mouseX, mouseY) != null
|
||||
|| forEachButtons(button -> button.contains(mouseX, mouseY) ? true : null, false));
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
public class GuiHelper {
|
||||
|
||||
private static final Stack<int[]> scissorFrameStack = new Stack<>();
|
||||
private static final FloatBuffer MATRIX_BUFFER = BufferUtils.createFloatBuffer(16);
|
||||
|
||||
public static void useScissor(int x, int y, int width, int height, Runnable codeBlock) {
|
||||
pushScissorFrame(x, y, width, height);
|
||||
@@ -36,7 +37,7 @@ public class GuiHelper {
|
||||
return currentTopFrame;
|
||||
}
|
||||
|
||||
private static void pushScissorFrame(int x, int y, int width, int height) {
|
||||
public static void pushScissorFrame(int x, int y, int width, int height) {
|
||||
int[] matrix = prepareMatrix(x, y, width, height);
|
||||
int[] parentScissor = peekFirstScissorOrFullScreen();
|
||||
int parentX = parentScissor[0];
|
||||
@@ -110,7 +111,7 @@ public class GuiHelper {
|
||||
|
||||
private static int[] prepareMatrix(int x, int y, int w, int h) {
|
||||
// Get the current translation component to support the Gui being drawn at any position on the screen
|
||||
final FloatBuffer matBuf = BufferUtils.createFloatBuffer(16);
|
||||
final FloatBuffer matBuf = MATRIX_BUFFER;
|
||||
GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, matBuf);
|
||||
final float xScale = matBuf.get(0);
|
||||
final float yScale = matBuf.get(5);
|
||||
|
||||
@@ -289,6 +289,7 @@ nei.options.inventory.bookmarks.showRecipeMarkerMode=Show Recipe Marker
|
||||
nei.options.inventory.bookmarks.showRecipeMarkerMode.0=None
|
||||
nei.options.inventory.bookmarks.showRecipeMarkerMode.1=Text
|
||||
nei.options.inventory.bookmarks.showRecipeMarkerMode.2=Background
|
||||
nei.options.inventory.bookmarks.maxVerticalTooltipRows=Max Vertical Tooltip Rows (0 - disable)
|
||||
nei.options.inventory.bookmarks.showRecipeHandlerIcon=Show Handler Icon
|
||||
nei.options.inventory.bookmarks.showRecipeHandlerIcon.true=Yes
|
||||
nei.options.inventory.bookmarks.showRecipeHandlerIcon.false=No
|
||||
@@ -427,6 +428,9 @@ nei.options.inventory.autocrafting.false=Disabled
|
||||
nei.options.inventory.guirecipe.shiftOverlayRecipe=Require holding shift to move items when overlaying recipe
|
||||
nei.options.inventory.guirecipe.shiftOverlayRecipe.true=Yes
|
||||
nei.options.inventory.guirecipe.shiftOverlayRecipe.false=No
|
||||
nei.options.inventory.guirecipe.freezeCycleOnHover=Stop cycling the recipe while hovering over an ingredient or a button
|
||||
nei.options.inventory.guirecipe.freezeCycleOnHover.true=Yes
|
||||
nei.options.inventory.guirecipe.freezeCycleOnHover.false=No
|
||||
nei.options.inventory.widgetsenabled.true=NEI Enabled
|
||||
nei.options.inventory.widgetsenabled.false=NEI Disabled
|
||||
nei.options.inventory.cheatmode.0=Recipe Mode
|
||||
@@ -516,6 +520,13 @@ nei.options.inventory.itemzoom.neiOnly.tip=Zoom items only from the JEI ingredie
|
||||
nei.options.inventory.itemzoom.onlySolid=Show Only Solid Items
|
||||
nei.options.inventory.itemzoom.onlySolid.true=Enabled
|
||||
nei.options.inventory.itemzoom.onlySolid.false=Disabled
|
||||
nei.options.inventory.itemzoom.preferredSide=Preferred Side
|
||||
nei.options.inventory.itemzoom.preferredSide.0=Auto
|
||||
nei.options.inventory.itemzoom.preferredSide.1=Left
|
||||
nei.options.inventory.itemzoom.preferredSide.2=Right
|
||||
nei.options.inventory.itemzoom.preferredSide.0.tip=Prefer whichever side currently has fewer items in its panel.
|
||||
nei.options.inventory.itemzoom.preferredSide.1.tip=Always prefer the left side, unless the cursor is there.
|
||||
nei.options.inventory.itemzoom.preferredSide.2.tip=Always prefer the right side, unless the cursor is there.
|
||||
nei.options.inventory.itemzoom.helpText=Display Help Text
|
||||
nei.options.inventory.itemzoom.helpText.true=Enabled
|
||||
nei.options.inventory.itemzoom.helpText.false=Disabled
|
||||
@@ -617,6 +628,7 @@ nei.debug.RecipeHandler.Width=Width
|
||||
nei.debug.RecipeHandler.ShowFavorites=Show Favorites
|
||||
nei.debug.RecipeHandler.ShowOverlay=Show Overlays
|
||||
nei.debug.RecipeHandler.ShowBadge=Show Badge
|
||||
nei.debug.RecipeHandler.DuplicatesOnly=Duplicates Only
|
||||
nei.debug.RecipeHandler.AllowOverflowY=Allow Overflow Y
|
||||
nei.debug.RecipeHandler.AllowOverflowX=Allow Overflow X
|
||||
nei.debug.RecipeHandler.Override=Override
|
||||
@@ -625,6 +637,7 @@ nei.debug.RecipeHandler.checkbox.off=Off
|
||||
nei.debug.RecipeHandler.yes=Yes
|
||||
nei.debug.RecipeHandler.no=No
|
||||
nei.debug.RecipeHandler.reset=Reset
|
||||
nei.debug.RecipeHandler.RegisteredBy=Registered by: %s
|
||||
|
||||
nei.recipe.page=Page %s/%s
|
||||
nei.recipe.tooltip=Recipes
|
||||
|
||||
@@ -265,6 +265,9 @@ nei.options.inventory.optimize_gui_overlap_computation.false=Нет
|
||||
nei.options.inventory.guirecipe.shiftOverlayRecipe=Требовать удержание Shift для перемещения предметов при отображении рецепта
|
||||
nei.options.inventory.guirecipe.shiftOverlayRecipe.true=Да
|
||||
nei.options.inventory.guirecipe.shiftOverlayRecipe.false=Нет
|
||||
nei.options.inventory.guirecipe.freezeCycleOnHover=Останавливать перелистывание рецепта при наведении на предмет или кнопку
|
||||
nei.options.inventory.guirecipe.freezeCycleOnHover.true=Да
|
||||
nei.options.inventory.guirecipe.freezeCycleOnHover.false=Нет
|
||||
nei.options.inventory.widgetsenabled.true=NEI включен
|
||||
nei.options.inventory.widgetsenabled.false=NEI выключен
|
||||
nei.options.inventory.cheatmode.0=Режим рецептов
|
||||
@@ -332,6 +335,13 @@ nei.options.inventory.itemzoom.neiOnly.tip=Увеличивать предмет
|
||||
nei.options.inventory.itemzoom.onlySolid=Показывать только твердые предметы
|
||||
nei.options.inventory.itemzoom.onlySolid.true=Включено
|
||||
nei.options.inventory.itemzoom.onlySolid.false=Отключено
|
||||
nei.options.inventory.itemzoom.preferredSide=Предпочитаемая сторона
|
||||
nei.options.inventory.itemzoom.preferredSide.0=Авто
|
||||
nei.options.inventory.itemzoom.preferredSide.1=Слева
|
||||
nei.options.inventory.itemzoom.preferredSide.2=Справа
|
||||
nei.options.inventory.itemzoom.preferredSide.0.tip=Выбирать сторону, где сейчас меньше предметов в панели.
|
||||
nei.options.inventory.itemzoom.preferredSide.1.tip=Всегда предпочитать левую сторону, если там нет курсора.
|
||||
nei.options.inventory.itemzoom.preferredSide.2.tip=Всегда предпочитать правую сторону, если там нет курсора.
|
||||
nei.options.inventory.itemzoom.helpText=Показывать текст помощи
|
||||
nei.options.inventory.itemzoom.helpText.true=Включено
|
||||
nei.options.inventory.itemzoom.helpText.false=Отключено
|
||||
|
||||
@@ -64,6 +64,7 @@ public class SearchTokenParserTest {
|
||||
new ModeValue(1, "Extended mode"), new ModeValue(2, "Regex mode"), new ModeValue(3, "Extended+ mode") };
|
||||
private static final ModeValue[] extendedPlusPatternMode = { patternModes[3] };
|
||||
private static final ModeValue[] extendedPatternModes = { patternModes[1], patternModes[3] };
|
||||
private static final ModeValue[] nonGrammarPatternModes = { patternModes[0], patternModes[1], patternModes[2] };
|
||||
|
||||
private static final SearchParserProvider defaultParserProvider = parserProvider(
|
||||
'\0',
|
||||
@@ -119,6 +120,10 @@ public class SearchTokenParserTest {
|
||||
|
||||
private static final List<Arguments> allModesTestProvider = combinationsProvider(spaceModes, patternModes);
|
||||
|
||||
private static final List<Arguments> nonGrammarAllSpaceModesTestProvider = combinationsProvider(
|
||||
spaceModes,
|
||||
nonGrammarPatternModes);
|
||||
|
||||
private static final List<Arguments> extendedPlusAllSpaceModesTestProvider = combinationsProvider(
|
||||
spaceModes,
|
||||
extendedPlusPatternMode);
|
||||
@@ -236,6 +241,36 @@ public class SearchTokenParserTest {
|
||||
assertTrue(matchedItems.contains(itemA));
|
||||
}
|
||||
|
||||
@DisplayName("Negated prefix (dash)")
|
||||
@ParameterizedTest(name = "{argumentsWithNames}")
|
||||
@FieldSource("allModesTestProvider")
|
||||
public void testNegatedPrefixDash(int spaceMode, int patternMode) {
|
||||
SearchTokenParser searchParser = new SearchTokenParser();
|
||||
searchParser.addProvider(defaultParserProvider);
|
||||
searchParser
|
||||
.addProvider(parserProvider('?', "custom", SearchTokenParser.SearchMode.PREFIX, customCreateFilter));
|
||||
|
||||
Set<ItemStack> matchedItems = testFilterAgainstAllItems(spaceMode, patternMode, searchParser, "-?A");
|
||||
|
||||
assertEquals(5, matchedItems.size());
|
||||
assertFalse(matchedItems.contains(itemA));
|
||||
}
|
||||
|
||||
@DisplayName("Negated prefix (bang)")
|
||||
@ParameterizedTest(name = "{argumentsWithNames}")
|
||||
@FieldSource("nonGrammarAllSpaceModesTestProvider")
|
||||
public void testNegatedPrefixBang(int spaceMode, int patternMode) {
|
||||
SearchTokenParser searchParser = new SearchTokenParser();
|
||||
searchParser.addProvider(defaultParserProvider);
|
||||
searchParser
|
||||
.addProvider(parserProvider('?', "custom", SearchTokenParser.SearchMode.PREFIX, customCreateFilter));
|
||||
|
||||
Set<ItemStack> matchedItems = testFilterAgainstAllItems(spaceMode, patternMode, searchParser, "!?A");
|
||||
|
||||
assertEquals(5, matchedItems.size());
|
||||
assertFalse(matchedItems.contains(itemA));
|
||||
}
|
||||
|
||||
@DisplayName("Space mode")
|
||||
@ParameterizedTest(name = "{argumentsWithNames}")
|
||||
@FieldSource("spaceIsSpaceAllModesTestProvider")
|
||||
|
||||
Reference in new issue
Block a user