mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-16 18:54:45 +00:00
Compare commits
40
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b83456f01 | ||
|
|
4b7b84b031 | ||
|
|
75309b81ec | ||
|
|
24e46bb43e | ||
|
|
2ba0773401 | ||
|
|
eac913c80c | ||
|
|
126f0ea73c | ||
|
|
cd4668ec84 | ||
|
|
7c247dd0d2 | ||
|
|
87b549fab5 | ||
|
|
8ed1f7a043 | ||
|
|
f2efa35654 | ||
|
|
bcef287e71 | ||
|
|
7f555f7a7f | ||
|
|
9fd38da205 | ||
|
|
2fa5563408 | ||
|
|
541c0e2def | ||
|
|
ac868097e7 | ||
|
|
2f0de0b6a8 | ||
|
|
32bc29e654 | ||
|
|
ef8a7d8bd5 | ||
|
|
adc5a5df16 | ||
|
|
a828ff227a | ||
|
|
9b6f98330e | ||
|
|
667c8cb5b6 | ||
|
|
a186f69444 | ||
|
|
16f4f20239 | ||
|
|
bac207cacb | ||
|
|
630e856d83 | ||
|
|
42d96aed0c | ||
|
|
bd6384bf24 | ||
|
|
af9726d356 | ||
|
|
1e1d2f1076 | ||
|
|
7cb94fb22a | ||
|
|
87aa4f9ed5 | ||
|
|
9760fd3eaf | ||
|
|
1054871982 | ||
|
|
d90a667f68 | ||
|
|
69e6df5848 | ||
|
|
25fa7ce44e |
No files matched your search
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
dependencies {
|
||||
api('com.github.GTNewHorizons:CodeChickenCore:1.4.7:dev')
|
||||
implementation('com.github.GTNewHorizons:GTNHLib:0.7.0:dev')
|
||||
implementation('com.github.GTNewHorizons:GTNHLib:0.8.0:dev')
|
||||
|
||||
shadowImplementation('org.apache.commons:commons-csv:1.10.0')
|
||||
|
||||
|
||||
+9
-1
@@ -96,7 +96,9 @@ usesMixinDebug = false
|
||||
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
|
||||
mixinPlugin =
|
||||
|
||||
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
|
||||
# Specify the package that contains all of your Mixins. The package must exist or
|
||||
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
|
||||
# it must match with this or the build will fail.
|
||||
mixinsPackage =
|
||||
|
||||
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
||||
@@ -172,6 +174,12 @@ curseForgeRelations = requiredDependency\:codechickencore-unofficial
|
||||
# projects. New projects should not use this parameter.
|
||||
# customArchiveBaseName =
|
||||
|
||||
# Optional parameter to customize the default working directory used by the runClient* tasks. Relative to the project directory.
|
||||
# runClientWorkingDirectory = run/client
|
||||
|
||||
# Optional parameter to customize the default working directory used by the runServer* tasks. Relative to the project directory.
|
||||
# runServerWorkingDirectory = run/server
|
||||
|
||||
# Optional parameter to have the build automatically fail if an illegal version is used.
|
||||
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
|
||||
# The check is ONLY performed if the version is a git tag.
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -114,7 +114,7 @@ case "$( uname )" in #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
CLASSPATH="\\\"\\\""
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
@@ -213,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
|
||||
Vendored
+2
-2
@@ -70,11 +70,11 @@ goto fail
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
set CLASSPATH=
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.44'
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.48'
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,9 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.ItemsGrid.ItemsGridSlot;
|
||||
import codechicken.nei.api.GuiInfo;
|
||||
import codechicken.nei.api.ShortcutInputHandler;
|
||||
import codechicken.nei.drawable.DrawableBuilder;
|
||||
import codechicken.nei.drawable.DrawableResource;
|
||||
@@ -19,6 +21,7 @@ public abstract class AbstractSubpanel<T extends ItemsGrid<? extends ItemsGridSl
|
||||
|
||||
protected int mouseDownItemIndex = -1;
|
||||
protected int splittingLineColor = 0xffffffff;
|
||||
protected int linePaddingStart = 0;
|
||||
protected T grid;
|
||||
|
||||
public boolean isEmpty() {
|
||||
@@ -51,19 +54,30 @@ public abstract class AbstractSubpanel<T extends ItemsGrid<? extends ItemsGridSl
|
||||
return this.grid.getSlotMouseOver(mousex, mousey);
|
||||
}
|
||||
|
||||
protected void updateLinePadding() {
|
||||
GuiContainer guiContainer = NEIClientUtils.getGuiContainer();
|
||||
this.linePaddingStart = 0;
|
||||
|
||||
while (GuiInfo
|
||||
.hideItemPanelSlot(guiContainer, new Rectangle4i(this.x + this.linePaddingStart, this.y - 1, 10, 2))) {
|
||||
this.linePaddingStart += 10;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void drawSplittingLine() {
|
||||
float alpha = (this.splittingLineColor >> 24 & 255) / 255.0F;
|
||||
float red = (this.splittingLineColor >> 16 & 255) / 255.0F;
|
||||
float green = (this.splittingLineColor >> 8 & 255) / 255.0F;
|
||||
float blue = (this.splittingLineColor & 255) / 255.0F;
|
||||
|
||||
int width = this.grid.columns * ItemsGrid.SLOT_SIZE;
|
||||
int width = this.grid.columns * ItemsGrid.SLOT_SIZE - this.linePaddingStart;
|
||||
int repeat = width / 6;
|
||||
int shiftX = this.x + (this.w - width) / 2;
|
||||
int shiftX = this.x + this.linePaddingStart + (this.w - width) / 2;
|
||||
|
||||
GL11.glColor4f(red, green, blue, alpha);
|
||||
for (int i = 0; i < repeat; i++) {
|
||||
DASH.draw(shiftX + i * 6, y);
|
||||
DASH.draw(shiftX + i * 6, this.y);
|
||||
}
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import codechicken.nei.api.IBookmarkContainerHandler;
|
||||
import codechicken.nei.bookmark.BookmarkGrid;
|
||||
import codechicken.nei.bookmark.BookmarkGroup;
|
||||
import codechicken.nei.bookmark.BookmarkItem;
|
||||
import codechicken.nei.bookmark.BookmarkItem.BookmarkItemType;
|
||||
import codechicken.nei.bookmark.BookmarkStorage;
|
||||
import codechicken.nei.bookmark.BookmarksGridSlot;
|
||||
import codechicken.nei.bookmark.GroupingItem;
|
||||
@@ -184,8 +185,8 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
|
||||
final boolean existsRecipe = recipeId != null
|
||||
&& this.grid.existsRecipe(recipeId, BookmarkGrid.DEFAULT_GROUP_ID);
|
||||
final NBTTagCompound nbTag = StackInfo.itemStackToNBT(itemStack);
|
||||
long factor = nbTag.getInteger("Count");
|
||||
long count = factor;
|
||||
long count = nbTag.getInteger("Count");
|
||||
long factor = existsRecipe ? Math.max(count, 1) : 1;
|
||||
|
||||
if (existsRecipe) {
|
||||
for (int i = 0; i < this.grid.size(); i++) {
|
||||
@@ -196,12 +197,13 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
|
||||
}
|
||||
}
|
||||
|
||||
if (factor == 0) {
|
||||
factor = nbTag.hasKey("gtFluidName") ? Math.min(144, nbTag.getInteger("Count")) : 1;
|
||||
}
|
||||
|
||||
this.grid.addItem(
|
||||
BookmarkItem.of(groupId, StackInfo.withAmount(itemStack, count), factor, recipeId, false),
|
||||
BookmarkItem.of(
|
||||
groupId,
|
||||
StackInfo.withAmount(itemStack, count),
|
||||
factor,
|
||||
recipeId,
|
||||
existsRecipe ? BookmarkItemType.RESULT : BookmarkItemType.ITEM),
|
||||
true);
|
||||
return true;
|
||||
}
|
||||
@@ -244,7 +246,8 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
|
||||
|
||||
if (stack != null && uniqueRecipe.add(recipeId)) {
|
||||
this.grid.addItem(
|
||||
BookmarkItem.of(groupId, stack, StackInfo.getAmount(stack), recipeId, false),
|
||||
BookmarkItem
|
||||
.of(groupId, stack, StackInfo.getAmount(stack), recipeId, BookmarkItemType.ITEM),
|
||||
true);
|
||||
uniqueStack.add(stack);
|
||||
}
|
||||
@@ -304,7 +307,7 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
|
||||
}
|
||||
|
||||
final int groupId = slot.getGroupId();
|
||||
final RecipeId recipeId = slot.getRecipeId();
|
||||
final RecipeId recipeId = slot.getType() == BookmarkItemType.ITEM ? null : slot.getRecipeId();
|
||||
final BookmarkGroup group = slot.getGroup();
|
||||
|
||||
if (group.crafting != null && group.collapsed) {
|
||||
@@ -368,7 +371,7 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
|
||||
|
||||
public RecipeId getRecipeId(int itemIndex) {
|
||||
BookmarkItem meta = this.grid.getCalculatedItem(itemIndex);
|
||||
return meta.isIngredient ? null : meta.recipeId;
|
||||
return meta.type == BookmarkItemType.INGREDIENT ? null : meta.recipeId;
|
||||
}
|
||||
|
||||
public boolean existsRecipe(RecipeId recipeId, int groupId) {
|
||||
@@ -922,7 +925,8 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
|
||||
|
||||
if (slot != null) {
|
||||
|
||||
if (slot.isIngredient() && slot.getRecipeId() != null && slot.getBookmarkItem().permutations.size() > 1) {
|
||||
if (slot.getType() == BookmarkItemType.INGREDIENT && slot.getRecipeId() != null
|
||||
&& slot.getBookmarkItem().permutations.size() > 1) {
|
||||
RecipeId recipeId = slot.getRecipeId();
|
||||
|
||||
if (recipeId == null) {
|
||||
@@ -992,7 +996,7 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
|
||||
@Override
|
||||
public boolean onMouseWheel(int shift, int mousex, int mousey) {
|
||||
|
||||
if (!inEditingState() && new Rectangle4i(
|
||||
if ((!inEditingState() || this.sortableGroup != null) && new Rectangle4i(
|
||||
namespacePrev.x,
|
||||
namespacePrev.y,
|
||||
namespaceNext.x + namespaceNext.w - namespacePrev.x,
|
||||
@@ -1020,7 +1024,8 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
|
||||
if (NEIClientUtils.altKey()) {
|
||||
multiplier = NEIClientConfig.showItemQuantityWidget() ? NEIClientConfig.getItemQuantity() : 0;
|
||||
if (multiplier == 0) {
|
||||
multiplier = slot.getItemStack().getMaxStackSize();
|
||||
multiplier = StackInfo.itemStackToNBT(slot.getItemStack()).hasKey("gtFluidName") ? 144
|
||||
: slot.getItemStack().getMaxStackSize();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1182,7 +1187,15 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
|
||||
}
|
||||
|
||||
if (!items.isEmpty()) {
|
||||
containerHandler.pullBookmarkItemsFromContainer(guiContainer, items);
|
||||
final int helmStackIndex = FastTransferManager.dropHeldItem(guiContainer);
|
||||
|
||||
if (guiContainer.mc.thePlayer.inventory.getItemStack() == null) {
|
||||
containerHandler.pullBookmarkItemsFromContainer(guiContainer, items);
|
||||
|
||||
if (helmStackIndex != -1) {
|
||||
FastTransferManager.clickSlot(guiContainer, helmStackIndex, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -1253,7 +1266,7 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
|
||||
@Deprecated
|
||||
public BookmarkRecipeId getBookmarkRecipeId(int itemIndex) {
|
||||
BookmarkItem item = this.grid.getCalculatedItem(itemIndex);
|
||||
return item == null || item.isIngredient || item.recipeId == null ? null
|
||||
return item == null || item.type == BookmarkItemType.INGREDIENT || item.recipeId == null ? null
|
||||
: new BookmarkRecipeId(item.recipeId.getHandleName(), item.recipeId.getIngredients());
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiErrorScreen;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiSelectWorld;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -42,7 +43,6 @@ import com.google.common.collect.Lists;
|
||||
|
||||
import codechicken.core.ClassDiscoverer;
|
||||
import codechicken.core.ClientUtils;
|
||||
import codechicken.core.GuiModListScroll;
|
||||
import codechicken.lib.packet.PacketCustom;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.IConfigureNEI;
|
||||
@@ -153,6 +153,7 @@ public class ClientHandler {
|
||||
loadHiddenHandlers();
|
||||
loadEnableAutoFocus();
|
||||
loadGuiCraftablesBlacklist();
|
||||
loadDefaultBookmarkContainers();
|
||||
ItemInfo.preInit();
|
||||
StackInfo.loadGuidFilters();
|
||||
}
|
||||
@@ -253,6 +254,20 @@ public class ClientHandler {
|
||||
lines -> ItemCraftablesPanel.guiBlacklist = lines.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
public static void loadDefaultBookmarkContainers() {
|
||||
loadSettingsFile("defaultbookmarkcontainers.cfg", lines -> {
|
||||
for (String clazz : lines.collect(Collectors.toList())) {
|
||||
try {
|
||||
API.registerBookmarkContainerHandler(
|
||||
(Class<? extends GuiContainer>) Class.forName(clazz),
|
||||
new DefaultBookmarkContainerHandler());
|
||||
} catch (Exception e) {
|
||||
NEIClientConfig.logger.error("Failed to load class '{}' for defaultbookmarkcontainers.cfg", clazz);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void loadHiddenItems() {
|
||||
loadSettingsFile("hiddenitems.cfg", lines -> lines.forEach(API::hideItem));
|
||||
}
|
||||
@@ -260,7 +275,6 @@ public class ClientHandler {
|
||||
public static void load() {
|
||||
instance = new ClientHandler();
|
||||
|
||||
GuiModListScroll.register("NotEnoughItems");
|
||||
PacketCustom.assignHandler(NEICPH.channel, new NEICPH());
|
||||
FMLCommonHandler.instance().bus().register(instance);
|
||||
MinecraftForge.EVENT_BUS.register(instance);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -12,36 +12,19 @@ public class DefaultBookmarkContainerHandler implements IBookmarkContainerHandle
|
||||
|
||||
@Override
|
||||
public void pullBookmarkItemsFromContainer(GuiContainer guiContainer, ArrayList<ItemStack> bookmarkItems) {
|
||||
FastTransferManager manager = new FastTransferManager();
|
||||
LinkedList<ItemStack> containerStacks = manager.saveContainer(guiContainer.inventorySlots);
|
||||
final FastTransferManager manager = new FastTransferManager();
|
||||
final List<ItemStack> containerStacks = getStorageStacks(guiContainer);
|
||||
|
||||
for (ItemStack bookmarkItem : bookmarkItems) {
|
||||
|
||||
int bookmarkSizeBackup = bookmarkItem.stackSize;
|
||||
|
||||
for (int i = 0; i < containerStacks.size() - 4 * 9; i++) { // Last 36 slots are player inventory
|
||||
ItemStack containerItem = containerStacks.get(i);
|
||||
|
||||
if (containerItem == null) {
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < containerStacks.size() && bookmarkItem.stackSize > 0; i++) {
|
||||
final ItemStack containerItem = containerStacks.get(i);
|
||||
|
||||
if (bookmarkItem.isItemEqual(containerItem)) {
|
||||
if (bookmarkItem.stackSize <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
int transferAmount = Math.min(bookmarkItem.stackSize, containerItem.stackSize);
|
||||
|
||||
final int transferAmount = Math.min(bookmarkItem.stackSize, containerItem.stackSize);
|
||||
manager.transferItems(guiContainer, i, transferAmount);
|
||||
bookmarkItem.stackSize -= transferAmount;
|
||||
|
||||
if (bookmarkItem.stackSize == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
bookmarkItem.stackSize = bookmarkSizeBackup;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,9 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -281,6 +283,27 @@ public class FastTransferManager {
|
||||
GuiContainerManager.getManager(window).handleSlotClick(slotIndex, button, modifier);
|
||||
}
|
||||
|
||||
public static int dropHeldItem(GuiContainer window) {
|
||||
final EntityPlayerSP player = window.mc.thePlayer;
|
||||
final ItemStack held = player.inventory.getItemStack();
|
||||
|
||||
if (held == null) return -1;
|
||||
|
||||
for (int i = 0; held != null && i < window.inventorySlots.inventorySlots.size(); i++) {
|
||||
final Slot slot = window.inventorySlots.inventorySlots.get(i);
|
||||
|
||||
if (slot.inventory instanceof InventoryPlayer && !slot.getHasStack() && slot.isItemValid(held)) {
|
||||
clickSlot(window, i, 0, 0);
|
||||
|
||||
if (player.inventory.getItemStack() == null) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private boolean fillZoneWithHeldItem(GuiContainer window, int zoneIndex) {
|
||||
for (int transferTo : slotZones.get(zoneIndex)) {
|
||||
ItemStack held = NEIClientUtils.getHeldItem();
|
||||
|
||||
@@ -183,6 +183,10 @@ public class FavoriteRecipes {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int size() {
|
||||
return items.size() + fluids.size();
|
||||
}
|
||||
|
||||
public static boolean contains(ItemStack stack) {
|
||||
return getFavorite(stack) != null;
|
||||
}
|
||||
|
||||
@@ -61,6 +61,11 @@ public class FormattedTextField extends GuiTextField {
|
||||
super.setFocused(focus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(String rawText) {
|
||||
super.setText(EnumChatFormatting.getTextWithoutFormattingCodes(rawText));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelectionPos(int p_146199_1_) {
|
||||
String text = this.getText();
|
||||
|
||||
@@ -36,7 +36,8 @@ public class HeldItemHandler implements IContainerInputHandler, IContainerToolti
|
||||
|
||||
if (contains(mousex, mousey)) {
|
||||
|
||||
if (NEIClientConfig.canPerformAction("delete") && NEIClientConfig.canPerformAction("item")) {
|
||||
if (NEIClientConfig.canPerformAction("delete") && NEIClientConfig.canPerformAction("item")
|
||||
|| NEIClientUtils.mc().playerController.isInCreativeMode()) {
|
||||
if (button == 1) {
|
||||
NEIClientUtils.decreaseSlotStack(-999);
|
||||
} else {
|
||||
@@ -101,7 +102,8 @@ public class HeldItemHandler implements IContainerInputHandler, IContainerToolti
|
||||
if (contains(mousex, mousey)) {
|
||||
currenttip.clear();
|
||||
|
||||
if (NEIClientConfig.canPerformAction("delete") && NEIClientConfig.canPerformAction("item")) {
|
||||
if (NEIClientConfig.canPerformAction("delete") && NEIClientConfig.canPerformAction("item")
|
||||
|| NEIClientUtils.mc().playerController.isInCreativeMode()) {
|
||||
currenttip.add(EnumChatFormatting.RED + translate("itempanel.deleteItem"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,11 @@ package codechicken.nei;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
@@ -90,6 +91,7 @@ public class ItemCraftablesPanel
|
||||
private GuiContainer lastGuiContainer = null;
|
||||
private ItemStackAmount lastPlayerInventory = null;
|
||||
private long lastPlayerInventorySync = 0;
|
||||
private int lastFavoritesCount = 0;
|
||||
|
||||
public ItemCraftablesPanel() {
|
||||
this.grid = new ItemsGrid<>() {
|
||||
@@ -106,28 +108,42 @@ public class ItemCraftablesPanel
|
||||
public List<CraftablesGridSlot> getMask() {
|
||||
|
||||
if (this.gridMask == null) {
|
||||
int maxSlotIndex = this.rows * this.columns;
|
||||
final AtomicInteger slotIndex = new AtomicInteger(0);
|
||||
final int maxSlotIndex = this.rows * this.columns;
|
||||
final List<CraftablesGridSlot> gridMask = new ArrayList<>();
|
||||
this.realItems.clear();
|
||||
|
||||
if (!ItemCraftablesPanel.this.availableRecipes.isEmpty()) {
|
||||
ItemCraftablesPanel.this.availableRecipes.entrySet().stream()
|
||||
.sorted(Map.Entry.comparingByKey(ItemSorter.instance)).forEach(entry -> {
|
||||
this.realItems.add(entry.getKey());
|
||||
gridMask.add(
|
||||
new CraftablesGridSlot(
|
||||
slotIndex.get(),
|
||||
slotIndex.get(),
|
||||
entry.getKey(),
|
||||
entry.getValue()));
|
||||
slotIndex.incrementAndGet();
|
||||
});
|
||||
final List<Map.Entry<ItemStack, RecipeId>> entries = ItemCraftablesPanel.this.availableRecipes
|
||||
.entrySet().stream()
|
||||
.sorted(
|
||||
Map.Entry.comparingByKey(
|
||||
Comparator.comparing(FavoriteRecipes::contains).reversed()
|
||||
.thenComparing(ItemSorter.instance)))
|
||||
.limit(maxSlotIndex).collect(Collectors.toList());
|
||||
int slotIndex = 0;
|
||||
int itemIndex = 0;
|
||||
|
||||
this.gridMask = gridMask.subList(0, Math.min(gridMask.size(), maxSlotIndex));
|
||||
for (Map.Entry<ItemStack, RecipeId> entry : entries) {
|
||||
if (!isInvalidSlot(slotIndex)) {
|
||||
this.realItems.add(entry.getKey());
|
||||
gridMask.add(
|
||||
new CraftablesGridSlot(
|
||||
slotIndex,
|
||||
itemIndex++,
|
||||
entry.getKey(),
|
||||
entry.getValue()));
|
||||
}
|
||||
if (slotIndex++ >= maxSlotIndex) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.gridMask = gridMask;
|
||||
} else {
|
||||
this.gridMask = Collections.emptyList();
|
||||
}
|
||||
|
||||
ItemCraftablesPanel.this.updateLinePadding();
|
||||
}
|
||||
|
||||
return this.gridMask;
|
||||
@@ -192,11 +208,16 @@ public class ItemCraftablesPanel
|
||||
this.lastPlayerInventorySync = System.currentTimeMillis();
|
||||
|
||||
if (firstGui != null && !ItemCraftablesPanel.guiBlacklist.contains(firstGui.getClass().getName())) {
|
||||
final boolean showOnlyFavorites = NEIClientConfig
|
||||
.getBooleanSetting("inventory.craftables.favoritesOnly");
|
||||
final ItemStackAmount inv = AutoCraftingManager.getInventoryItems(firstGui);
|
||||
|
||||
if (this.lastGuiContainer != (this.lastGuiContainer = firstGui)
|
||||
if (this.lastGuiContainer != firstGui
|
||||
|| showOnlyFavorites && this.lastFavoritesCount != FavoriteRecipes.size()
|
||||
|| !inv.equals(this.lastPlayerInventory)) {
|
||||
this.lastPlayerInventory = inv;
|
||||
this.lastGuiContainer = firstGui;
|
||||
this.lastFavoritesCount = FavoriteRecipes.size();
|
||||
this.availableRecipes = generateCraftables(firstGui);
|
||||
this.grid.onGridChanged();
|
||||
}
|
||||
@@ -251,12 +272,14 @@ public class ItemCraftablesPanel
|
||||
private Map<ItemStack, RecipeId> filterHandlerRecipes(IRecipeHandler handler, GuiContainer firstGui,
|
||||
List<ItemStack> invStacks) {
|
||||
final Map<ItemStack, RecipeId> availableRecipes = new HashMap<>();
|
||||
final boolean showOnlyFavorites = NEIClientConfig.getBooleanSetting("inventory.craftables.favoritesOnly");
|
||||
|
||||
IntStream.range(0, handler.numRecipes()).parallel().forEach(recipeIndex -> {
|
||||
if (existsIngredients(firstGui, handler.getIngredientStacks(recipeIndex), invStacks)) {
|
||||
final Recipe recipe = Recipe.of(handler, recipeIndex);
|
||||
|
||||
if (!recipe.getResults().isEmpty()) {
|
||||
if (!recipe.getResults().isEmpty()
|
||||
&& (!showOnlyFavorites || FavoriteRecipes.getFavorite(recipe.getRecipeId()) != null)) {
|
||||
synchronized (availableRecipes) {
|
||||
availableRecipes.put(recipe.getResult(), recipe.getRecipeId());
|
||||
}
|
||||
|
||||
@@ -40,9 +40,15 @@ public class ItemHistoryPanel extends AbstractSubpanel<ItemsGrid<ItemHistoryPane
|
||||
|
||||
if (this.gridMask == null) {
|
||||
this.gridMask = new ArrayList<>();
|
||||
for (int slotIndex = 0; slotIndex < Math.min(size(), this.rows * this.columns); slotIndex++) {
|
||||
this.gridMask.add(new HistoryGridSlot(slotIndex, slotIndex, getItem(slotIndex)));
|
||||
int itemIndex = 0;
|
||||
for (int slotIndex = 0; slotIndex < this.rows * this.columns && itemIndex < size(); slotIndex++) {
|
||||
if (!isInvalidSlot(slotIndex)) {
|
||||
this.gridMask.add(new HistoryGridSlot(slotIndex, itemIndex, getItem(itemIndex)));
|
||||
itemIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
ItemHistoryPanel.this.updateLinePadding();
|
||||
}
|
||||
|
||||
return this.gridMask;
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
@@ -308,7 +309,13 @@ public class ItemList {
|
||||
action.run();
|
||||
|
||||
if (stack.hasTagCompound() && hashOld != stack.stackTagCompound.hashCode()) {
|
||||
FMLLog.warning("NEI: Forced tag update with reason (" + reason + ") for " + stack);
|
||||
FMLLog.warning(
|
||||
"NEI: Forced tag update with reason (" + reason
|
||||
+ ") for "
|
||||
+ stack
|
||||
+ "("
|
||||
+ stack.getItem()
|
||||
+ ")");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,6 +337,7 @@ public class ItemList {
|
||||
runChecked(stack, () -> item.getToolClasses(stack), "getToolClasses");
|
||||
runChecked(stack, () -> item.getUnlocalizedNameInefficiently(stack), "getUnlocalizedNameInefficiently");
|
||||
runChecked(stack, () -> item.hasEffect(stack), "hasEffect");
|
||||
runChecked(stack, () -> item.getDigSpeed(stack, Blocks.stone, 0), "getDigSpeed");
|
||||
|
||||
/*
|
||||
* unused... for now runChecked(stack, () -> GameRegistry.getFuelValue(stack), "getFuelValue");
|
||||
|
||||
@@ -15,7 +15,6 @@ import net.minecraft.client.shader.Framebuffer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.api.GuiInfo;
|
||||
@@ -85,21 +84,6 @@ public abstract class ItemsGrid<T extends ItemsGrid.ItemsGridSlot, M extends Ite
|
||||
} else {
|
||||
this.framebuffer.framebufferClear();
|
||||
}
|
||||
|
||||
// copy depth buffer from MC (fix Angelica)
|
||||
OpenGlHelper.func_153171_g(GL30.GL_READ_FRAMEBUFFER, minecraft.getFramebuffer().framebufferObject);
|
||||
OpenGlHelper.func_153171_g(GL30.GL_DRAW_FRAMEBUFFER, this.framebuffer.framebufferObject);
|
||||
GL30.glBlitFramebuffer(
|
||||
0,
|
||||
0,
|
||||
minecraft.displayWidth,
|
||||
minecraft.displayHeight,
|
||||
0,
|
||||
0,
|
||||
minecraft.displayWidth,
|
||||
minecraft.displayHeight,
|
||||
GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT,
|
||||
GL11.GL_NEAREST);
|
||||
}
|
||||
|
||||
public void renderCapturedScreen() {
|
||||
|
||||
@@ -70,8 +70,8 @@ public class ItemsTooltipLineHandler implements ITooltipLineHandler {
|
||||
}
|
||||
|
||||
public void setActiveStack(ItemStack activeStack) {
|
||||
final ItemStack realStack = items.stream()
|
||||
.filter(stack -> NEIClientUtils.areStacksSameTypeWithNBT(stack, activeStack)).findFirst().orElse(null);
|
||||
final ItemStack realStack = items.stream().filter(stack -> NEIClientUtils.areStacksSameType(stack, activeStack))
|
||||
.findFirst().orElse(null);
|
||||
this.activeStackIndex = items.indexOf(realStack);
|
||||
}
|
||||
|
||||
|
||||
@@ -907,6 +907,9 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
final int ty2 = ty + 20 - h2 - te;
|
||||
final int tx2 = 200 - w2 - te;
|
||||
|
||||
final boolean is2DTexture = GL11.glGetBoolean(GL11.GL_TEXTURE_2D);
|
||||
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
changeTexture("textures/gui/widgets.png");
|
||||
drawTexturedModalRect(x, y, tx1, ty1, w1, h1); // top left
|
||||
drawTexturedModalRect(x, y2, tx1, ty2, w1, h2); // bottom left
|
||||
@@ -919,6 +922,8 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
|
||||
drawTexturedModalRect(x2, y, tx2, ty1, w2, h1); // top right
|
||||
drawTexturedModalRect(x2, y2, tx2, ty2, w2, h2); // bottom right
|
||||
|
||||
if (!is2DTexture) GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
public static void drawItemPresenceOverlay(int slotX, int slotY, boolean isPresent, boolean slotHighlight) {
|
||||
|
||||
@@ -225,13 +225,17 @@ public class NEIClientConfig {
|
||||
.getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.bookmarks.bookmarkItemsWithRecipe", true));
|
||||
|
||||
tag.getTag("inventory.bookmarks.bookmarkRecipeWithCount").setComment("Bookmark recipe with count")
|
||||
.getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.bookmarks.bookmarkRecipeWithCount", true));
|
||||
|
||||
tag.getTag("inventory.guirecipe.jeiStyleTabs").setComment("Enable/disable JEI Style Tabs")
|
||||
.getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButtonBoubs("inventory.guirecipe.jeiStyleTabs", true));
|
||||
|
||||
tag.getTag("inventory.guirecipe.jeiStyleRecipeCatalyst").setComment("Enable/disable JEI Style Recipe Catalysts")
|
||||
.getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.guirecipe.jeiStyleRecipeCatalyst", true));
|
||||
tag.getTag("inventory.guirecipe.jeiStyleRecipeCatalyst")
|
||||
.setComment("JEI Style Recipe Catalysts (0 - none, 1 - grid, 2 - scroll)").getIntValue(1);
|
||||
API.addOption(new OptionCycled("inventory.guirecipe.jeiStyleRecipeCatalyst", 3, true));
|
||||
|
||||
tag.getTag("inventory.guirecipe.cycledIngredientsTooltip").setComment("Show cycled ingredients tooltip")
|
||||
.getBooleanValue(true);
|
||||
@@ -292,6 +296,10 @@ public class NEIClientConfig {
|
||||
tag.getTag("inventory.craftables.useRows").setComment("Rows used in craftables areas").getIntValue(2);
|
||||
API.addOption(new OptionIntegerField("inventory.craftables.useRows", 1, 5));
|
||||
|
||||
tag.getTag("inventory.craftables.favoritesOnly").setComment("Show Only Favorites Recipes")
|
||||
.getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.craftables.favoritesOnly", true));
|
||||
|
||||
tag.getTag("inventory.collapsibleItems.enabled").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.collapsibleItems.enabled", true) {
|
||||
|
||||
@@ -843,24 +851,27 @@ public class NEIClientConfig {
|
||||
}
|
||||
|
||||
public static void loadWorld(String worldPath) {
|
||||
final File specificDir = new File(CommonUtils.getMinecraftDir(), "saves/NEI/" + worldPath);
|
||||
final boolean newWorld = !specificDir.exists();
|
||||
unloadWorld();
|
||||
setInternalEnabled(true);
|
||||
|
||||
if (!worldPath.equals(NEIClientConfig.worldPath)) {
|
||||
if (!worldPath.equals(NEIClientConfig.worldPath) || newWorld) {
|
||||
NEIClientConfig.worldPath = worldPath;
|
||||
|
||||
logger.debug("Loading " + (Minecraft.getMinecraft().isSingleplayer() ? "Local" : "Remote") + " World");
|
||||
|
||||
final File specificDir = new File(CommonUtils.getMinecraftDir(), "saves/NEI/" + worldPath);
|
||||
final boolean newWorld = !specificDir.exists();
|
||||
|
||||
if (newWorld) {
|
||||
specificDir.mkdirs();
|
||||
}
|
||||
|
||||
world = new ConfigSet(new File(specificDir, "NEI.dat"), new ConfigFile(new File(specificDir, "NEI.cfg")));
|
||||
|
||||
if (newWorld && Minecraft.getMinecraft().isSingleplayer()) {
|
||||
world.config.getTag("inventory.cheatmode")
|
||||
.setIntValue(NEIClientUtils.mc().playerController.isInCreativeMode() ? 2 : 0);
|
||||
}
|
||||
|
||||
bootNEI();
|
||||
onWorldLoad(newWorld);
|
||||
onWorldLoad();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -868,7 +879,7 @@ public class NEIClientConfig {
|
||||
return NEIClientConfig.worldPath;
|
||||
}
|
||||
|
||||
private static void onWorldLoad(boolean newWorld) {
|
||||
private static void onWorldLoad() {
|
||||
world.config.setComment(
|
||||
"World based configuration of NEI.\nMost of these options can be changed ingame.\nDeleting any element will restore it to it's default value");
|
||||
|
||||
@@ -876,12 +887,6 @@ public class NEIClientConfig {
|
||||
creativeInv = new ItemStack[54];
|
||||
LayoutManager.searchField.setText(getSearchExpression());
|
||||
LayoutManager.quantity.setText(Integer.toString(getItemQuantity()));
|
||||
|
||||
if (newWorld && Minecraft.getMinecraft().isSingleplayer()) {
|
||||
world.config.getTag("inventory.cheatmode")
|
||||
.setIntValue(NEIClientUtils.mc().playerController.isInCreativeMode() ? 2 : 0);
|
||||
}
|
||||
|
||||
NEIInfo.load(ClientUtils.getWorld());
|
||||
}
|
||||
|
||||
@@ -906,12 +911,7 @@ public class NEIClientConfig {
|
||||
SubsetWidget.saveHidden();
|
||||
FavoriteRecipes.save();
|
||||
CollapsibleItems.saveStates();
|
||||
|
||||
if (world != null) {
|
||||
world.saveNBT();
|
||||
NEIClientConfig.worldPath = null;
|
||||
world = null;
|
||||
}
|
||||
world.saveNBT();
|
||||
}
|
||||
|
||||
private static final Map<String, String> keySettings = new HashMap<>();
|
||||
@@ -1105,8 +1105,8 @@ public class NEIClientConfig {
|
||||
return getBooleanSetting("inventory.guirecipe.slotHighlightPresent");
|
||||
}
|
||||
|
||||
public static boolean areJEIStyleRecipeCatalystsVisible() {
|
||||
return getBooleanSetting("inventory.guirecipe.jeiStyleRecipeCatalyst");
|
||||
public static int getJEIStyleRecipeCatalysts() {
|
||||
return getIntSetting("inventory.guirecipe.jeiStyleRecipeCatalyst");
|
||||
}
|
||||
|
||||
public static boolean useCreativeTabStyle() {
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.ClientCommandHandler;
|
||||
|
||||
import codechicken.core.CommonUtils;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.GuiInfo;
|
||||
import codechicken.nei.api.IInfiniteItemHandler;
|
||||
@@ -156,20 +157,32 @@ public class NEIController implements IContainerSlotClickHandler, IContainerInpu
|
||||
|
||||
if (GuiInfo.hasCustomSlots(gui)) return false;
|
||||
|
||||
if (slotIndex >= 0 && NEIClientUtils.shiftKey()
|
||||
&& NEIClientUtils.getHeldItem() != null
|
||||
&& !slot.getHasStack()) {
|
||||
ItemStack held = NEIClientUtils.getHeldItem();
|
||||
manager.handleSlotClick(slot.slotNumber, button, 0);
|
||||
if (slot.isItemValid(held) && !ItemInfo.fastTransferExemptions.contains(slot.getClass()))
|
||||
fastTransferManager.performMassTransfer(gui, pickedUpFromSlot, slotIndex, held);
|
||||
if (NEIClientUtils.shiftKey()) {
|
||||
// fix small mouse movement while clicking causing slotIndex to be -999
|
||||
if (slotIndex == -999) {
|
||||
final Point mouse = GuiDraw.getMousePosition();
|
||||
slot = gui.getSlotAtPosition(mouse.x, mouse.y);
|
||||
|
||||
return true;
|
||||
}
|
||||
if (slot != null) {
|
||||
slotIndex = slot.slotNumber;
|
||||
}
|
||||
}
|
||||
|
||||
if (slotIndex == -999 && NEIClientUtils.shiftKey() && button == 0) {
|
||||
fastTransferManager.throwAll(gui, pickedUpFromSlot);
|
||||
return true;
|
||||
if (slotIndex >= 0 && NEIClientUtils.getHeldItem() != null && !slot.getHasStack()) {
|
||||
final ItemStack held = NEIClientUtils.getHeldItem();
|
||||
manager.handleSlotClick(slot.slotNumber, button, 0);
|
||||
|
||||
if (slot.isItemValid(held) && !ItemInfo.fastTransferExemptions.contains(slot.getClass())) {
|
||||
fastTransferManager.performMassTransfer(gui, pickedUpFromSlot, slotIndex, held);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (slotIndex == -999 && button == 0) {
|
||||
fastTransferManager.throwAll(gui, pickedUpFromSlot);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -7,8 +7,7 @@ import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
@@ -18,6 +17,7 @@ import codechicken.core.launch.CodeChickenCorePlugin;
|
||||
import codechicken.nei.api.IConfigureNEI;
|
||||
import codechicken.nei.asm.NEICorePlugin;
|
||||
import codechicken.nei.config.IMCHandler;
|
||||
import codechicken.nei.guihook.HideousLinkedList;
|
||||
import codechicken.nei.recipe.GuiRecipeTab;
|
||||
import cpw.mods.fml.client.FMLFileResourcePack;
|
||||
import cpw.mods.fml.client.FMLFolderResourcePack;
|
||||
@@ -31,13 +31,15 @@ import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
|
||||
import cpw.mods.fml.common.versioning.ArtifactVersion;
|
||||
import cpw.mods.fml.common.versioning.VersionParser;
|
||||
import cpw.mods.fml.common.versioning.VersionRange;
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public class NEIModContainer extends DummyModContainer {
|
||||
|
||||
public static LinkedList<IConfigureNEI> plugins = new LinkedList<>();
|
||||
public static final LinkedList<IConfigureNEI> plugins = new HideousLinkedList<>(new CopyOnWriteArrayList<>());
|
||||
|
||||
private static boolean gregTech5Loaded;
|
||||
private static boolean gtnhLibLoaded;
|
||||
@@ -46,7 +48,6 @@ public class NEIModContainer extends DummyModContainer {
|
||||
|
||||
public NEIModContainer() {
|
||||
super(getModMetadata());
|
||||
loadMetadata();
|
||||
}
|
||||
|
||||
private static ModMetadata getModMetadata() {
|
||||
@@ -85,30 +86,6 @@ public class NEIModContainer extends DummyModContainer {
|
||||
|
||||
private String description;
|
||||
|
||||
private void loadMetadata() {
|
||||
description = super.getMetadata().description.replace("Supporters:", EnumChatFormatting.AQUA + "Supporters:");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModMetadata getMetadata() {
|
||||
StringBuilder s_plugins = new StringBuilder();
|
||||
if (plugins.size() == 0) {
|
||||
s_plugins.append(EnumChatFormatting.RED).append("No installed plugins.");
|
||||
} else {
|
||||
s_plugins.append(EnumChatFormatting.GREEN).append("Installed plugins: ");
|
||||
for (int i = 0; i < plugins.size(); i++) {
|
||||
if (i > 0) s_plugins.append(", ");
|
||||
IConfigureNEI plugin = plugins.get(i);
|
||||
s_plugins.append(plugin.getName()).append(" ").append(plugin.getVersion());
|
||||
}
|
||||
s_plugins.append(".");
|
||||
}
|
||||
|
||||
ModMetadata meta = super.getMetadata();
|
||||
meta.description = description.replace("<plugins>", s_plugins.toString());
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean registerBus(EventBus bus, LoadController controller) {
|
||||
bus.register(this);
|
||||
@@ -125,8 +102,9 @@ public class NEIModContainer extends DummyModContainer {
|
||||
|
||||
@Subscribe
|
||||
public void init(FMLInitializationEvent event) {
|
||||
if (CommonUtils.isClient()) ClientHandler.load();
|
||||
|
||||
if (CommonUtils.isClient()) {
|
||||
ClientHandler.load();
|
||||
}
|
||||
ServerHandler.load();
|
||||
}
|
||||
|
||||
@@ -147,6 +125,11 @@ public class NEIModContainer extends DummyModContainer {
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onServerAboutToStart(FMLServerAboutToStartEvent event) {
|
||||
NEIServerConfig.resetFirstLoad();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void handleIMCMessages(FMLInterModComms.IMCEvent event) {
|
||||
IMCHandler.processIMC(event.getMessages());
|
||||
|
||||
@@ -18,7 +18,6 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.JsonToNBT;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.permission.PermissionLevel;
|
||||
@@ -37,21 +36,23 @@ import codechicken.lib.packet.PacketCustom;
|
||||
|
||||
public class NEIServerConfig {
|
||||
|
||||
private static MinecraftServer server;
|
||||
|
||||
private static boolean firstLoad;
|
||||
public static Logger logger = LogManager.getLogger("NotEnoughItems");
|
||||
public static File saveDir;
|
||||
public static ConfigFile serverConfig;
|
||||
public static Map<Integer, NBTTagCompound> dimTags = new HashMap<>();
|
||||
public static HashMap<String, PlayerSave> playerSaves = new HashMap<>();
|
||||
public static ItemStackMap<Set<String>> bannedItems = new ItemStackMap<>();
|
||||
|
||||
private static boolean doesPermAPIExist = false;
|
||||
|
||||
public static void resetFirstLoad() {
|
||||
firstLoad = true;
|
||||
}
|
||||
|
||||
public static void load(World world) {
|
||||
if (MinecraftServer.getServer() != server) {
|
||||
if (firstLoad) {
|
||||
firstLoad = false;
|
||||
logger.debug("Loading NEI Server");
|
||||
server = MinecraftServer.getServer();
|
||||
saveDir = new File(DimensionManager.getCurrentSaveRootDirectory(), "NEI");
|
||||
|
||||
dimTags.clear();
|
||||
|
||||
@@ -51,15 +51,18 @@ import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
|
||||
public class NEIServerUtils {
|
||||
|
||||
private static Class<?> gtMetaBaseItem;
|
||||
private static class GTMetaBaseItemHolder {
|
||||
|
||||
static {
|
||||
try {
|
||||
final ClassLoader loader = NEIServerUtils.class.getClassLoader();
|
||||
NEIServerUtils.gtMetaBaseItem = ReflectionHelper
|
||||
.getClass(loader, "gregtech.api.items.MetaBaseItem", "gregtech.api.items.GT_MetaBase_Item");
|
||||
} catch (Exception ignored) {
|
||||
/* Do nothing */
|
||||
private static final Class<?> gtMetaBaseItem = loadMetaBaseItem();
|
||||
|
||||
private static Class<?> loadMetaBaseItem() {
|
||||
try {
|
||||
final ClassLoader loader = NEIServerUtils.class.getClassLoader();
|
||||
return ReflectionHelper
|
||||
.getClass(loader, "gregtech.api.items.MetaBaseItem", "gregtech.api.items.GT_MetaBase_Item");
|
||||
} catch (Exception ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,7 +234,8 @@ public class NEIServerUtils {
|
||||
* @return
|
||||
*/
|
||||
public static boolean isItemTool(ItemStack stack) {
|
||||
return NEIServerUtils.gtMetaBaseItem != null && NEIServerUtils.gtMetaBaseItem.isInstance(stack.getItem());
|
||||
return GTMetaBaseItemHolder.gtMetaBaseItem != null
|
||||
&& GTMetaBaseItemHolder.gtMetaBaseItem.isInstance(stack.getItem());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -117,7 +117,7 @@ public class PositionedStack {
|
||||
public int getPermutationIndex(ItemStack stack) {
|
||||
|
||||
for (int index = 0; index < this.items.length; index++) {
|
||||
if (NEIServerUtils.areStacksSameTypeCraftingWithNBT(items[index], stack)) {
|
||||
if (NEIServerUtils.areStacksSameType(items[index], stack)) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
@@ -146,7 +146,7 @@ public class PositionedStack {
|
||||
}
|
||||
|
||||
public boolean contains(int mx, int my) {
|
||||
return this.relx <= mx && this.rely <= my && this.relx + 16 >= mx && this.rely + 16 >= my;
|
||||
return mx >= this.relx - 1 && mx < this.relx + 17 && my >= this.rely - 1 && my < this.rely + 17;
|
||||
}
|
||||
|
||||
public boolean contains(ItemStack ingredient) {
|
||||
|
||||
@@ -21,10 +21,8 @@ import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
|
||||
public class ServerHandler {
|
||||
|
||||
private static ServerHandler instance;
|
||||
|
||||
public static void load() {
|
||||
instance = new ServerHandler();
|
||||
ServerHandler instance = new ServerHandler();
|
||||
|
||||
PacketCustom.assignHandler(NEICPH.channel, new NEISPH());
|
||||
FMLCommonHandler.instance().bus().register(instance);
|
||||
|
||||
@@ -89,7 +89,7 @@ public abstract class TextField extends Widget {
|
||||
onTextChange(oldText);
|
||||
}
|
||||
|
||||
return handled;
|
||||
return handled || keyID == Keyboard.KEY_SPACE;
|
||||
}
|
||||
|
||||
public abstract void onTextChange(String oldText);
|
||||
|
||||
@@ -15,7 +15,7 @@ public interface IBookmarkContainerHandler {
|
||||
|
||||
for (int i = 0; i < slots.size() - 4 * 9; i++) {
|
||||
if (slots.get(i).getHasStack()) {
|
||||
stacks.add(slots.get(i).getStack());
|
||||
stacks.add(slots.get(i).getStack().copy());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,10 @@ public interface IStackStringifyHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
default ItemStack normalizeRecipeQueryStack(ItemStack stack) {
|
||||
return null;
|
||||
}
|
||||
|
||||
default void pauseItemDamageSound(boolean pause) {}
|
||||
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import codechicken.nei.SearchField;
|
||||
import codechicken.nei.bookmark.BookmarkGrid;
|
||||
import codechicken.nei.bookmark.BookmarkGroup;
|
||||
import codechicken.nei.bookmark.BookmarkItem;
|
||||
import codechicken.nei.bookmark.BookmarkItem.BookmarkItemType;
|
||||
import codechicken.nei.bookmark.BookmarksGridSlot;
|
||||
import codechicken.nei.recipe.AutoCraftingManager;
|
||||
import codechicken.nei.recipe.GuiCraftingRecipe;
|
||||
@@ -233,7 +234,7 @@ public abstract class ShortcutInputHandler {
|
||||
if (recipe != null) {
|
||||
math = RecipeChainMath.of(recipe, 1);
|
||||
}
|
||||
} else if (slot.getRecipeId() != null && !slot.isIngredient()) {
|
||||
} else if (slot.getRecipeId() != null && slot.getType() == BookmarkItemType.RESULT) {
|
||||
|
||||
if (slot.getGroup().crafting == null) {
|
||||
final Recipe recipe = Recipe.of(slot.getRecipeId());
|
||||
@@ -312,11 +313,14 @@ public abstract class ShortcutInputHandler {
|
||||
private static boolean saveRecipeInBookmark(ItemStack stackover, boolean saveIngredients, boolean saveStackSize) {
|
||||
final Point mousePos = GuiDraw.getMousePosition();
|
||||
|
||||
// If no slot was removed from the bookmark panel on click:
|
||||
if (!ItemPanels.bookmarkPanel.removeSlot(mousePos.x, mousePos.y, saveIngredients)) {
|
||||
final Recipe recipe = getFocusedRecipe(stackover, mousePos.x, mousePos.y, saveIngredients);
|
||||
|
||||
// --- Case 1: saving a recipe (with ingredients) ---
|
||||
if (recipe != null && saveIngredients) {
|
||||
|
||||
// If the recipe is not already bookmarked, add it
|
||||
if (!ItemPanels.bookmarkPanel.removeRecipe(recipe.getRecipeId(), BookmarkGrid.DEFAULT_GROUP_ID)) {
|
||||
final Recipe singleRecipe = Recipe.of(
|
||||
Arrays.asList(recipe.getResult(stackover)),
|
||||
@@ -324,18 +328,30 @@ public abstract class ShortcutInputHandler {
|
||||
recipe.getIngredients());
|
||||
singleRecipe.setCustomRecipeId(recipe.getRecipeId());
|
||||
|
||||
ItemPanels.bookmarkPanel
|
||||
.addRecipe(singleRecipe, saveStackSize ? 1 : 0, BookmarkGrid.DEFAULT_GROUP_ID);
|
||||
ItemPanels.bookmarkPanel.addRecipe(
|
||||
singleRecipe,
|
||||
// Determine if stack size should be saved
|
||||
saveStackSize
|
||||
|| NEIClientConfig.getBooleanSetting("inventory.bookmarks.bookmarkRecipeWithCount")
|
||||
? 1
|
||||
: 0,
|
||||
BookmarkGrid.DEFAULT_GROUP_ID);
|
||||
}
|
||||
|
||||
// --- Case 2: saving an item only ---
|
||||
} else {
|
||||
final RecipeId recipeId = recipe != null ? recipe.getRecipeId() : null;
|
||||
|
||||
// Determine if the item is associated with a recipe and should be saved with it
|
||||
final boolean existsRecipe = recipeId != null
|
||||
&& ItemPanels.bookmarkPanel.existsRecipe(recipeId, BookmarkGrid.DEFAULT_GROUP_ID)
|
||||
|| NEIClientConfig.getBooleanSetting("inventory.bookmarks.bookmarkItemsWithRecipe");
|
||||
|
||||
// If the item was not removed from the bookmarks, add it
|
||||
if (!ItemPanels.bookmarkPanel
|
||||
.removeItem(stackover, existsRecipe ? recipeId : null, BookmarkGrid.DEFAULT_GROUP_ID)) {
|
||||
|
||||
// Determine whether to preserve the item count
|
||||
saveStackSize = saveStackSize || saveIngredients
|
||||
|| ItemPanels.bookmarkPanel.existsRecipe(recipeId, BookmarkGrid.DEFAULT_GROUP_ID);
|
||||
|
||||
@@ -469,7 +485,7 @@ public abstract class ShortcutInputHandler {
|
||||
hotkeys.put(
|
||||
NEIClientConfig.getKeyName("gui.bookmark", NEIClientUtils.SHIFT_HASH),
|
||||
NEIClientUtils.translate("bookmark.group.remove_recipe"));
|
||||
} else if (slot.getRecipeId() == null) {
|
||||
} else if (slot.getRecipeId() == null || slot.getType() == BookmarkItemType.ITEM) {
|
||||
hotkeys.put(
|
||||
NEIClientConfig.getKeyName("gui.bookmark"),
|
||||
NEIClientUtils.translate("bookmark.remove_item"));
|
||||
@@ -484,7 +500,7 @@ public abstract class ShortcutInputHandler {
|
||||
NEIClientConfig.getKeyName("gui.bookmark", NEIClientUtils.SHIFT_HASH),
|
||||
NEIClientUtils.translate("bookmark.remove_recipe"));
|
||||
|
||||
if (slot.isIngredient()) {
|
||||
if (slot.getType() == BookmarkItemType.INGREDIENT) {
|
||||
hotkeys.put(
|
||||
NEIClientConfig.getKeyName("gui.bookmark"),
|
||||
NEIClientUtils.translate("bookmark.remove_item"));
|
||||
@@ -497,7 +513,8 @@ public abstract class ShortcutInputHandler {
|
||||
|
||||
if (ItemPanels.bookmarkPanel.getGrid().createChainItems(groupId).values().stream()
|
||||
.noneMatch(
|
||||
m -> !m.isIngredient && !m.equals(item) && item.equalsRecipe(m))) {
|
||||
m -> m.type == BookmarkItemType.RESULT && !m.equals(item)
|
||||
&& item.equalsRecipe(m))) {
|
||||
hotkeys.put(
|
||||
NEIClientConfig.getKeyName("gui.bookmark"),
|
||||
NEIClientUtils.translate("bookmark.remove_recipe"));
|
||||
@@ -647,7 +664,7 @@ public abstract class ShortcutInputHandler {
|
||||
BookmarksGridSlot slot) {
|
||||
|
||||
if (slot != null) {
|
||||
return slot.isIngredient() ? null : slot.getRecipeId();
|
||||
return slot.getType() == BookmarkItemType.INGREDIENT ? null : slot.getRecipeId();
|
||||
}
|
||||
|
||||
ItemsGridSlot itemSlot = ItemPanels.itemPanel.getSlotMouseOver(mousex, mousey);
|
||||
|
||||
@@ -30,6 +30,7 @@ import codechicken.nei.ItemsGrid.MouseContext;
|
||||
import codechicken.nei.LayoutManager;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.bookmark.BookmarkItem.BookmarkItemType;
|
||||
import codechicken.nei.recipe.Recipe;
|
||||
import codechicken.nei.recipe.Recipe.RecipeId;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
@@ -367,19 +368,26 @@ public class BookmarkGrid extends ItemsGrid<BookmarksGridSlot, BookmarkGrid.Book
|
||||
}
|
||||
|
||||
for (BookmarkItem item : this.bookmarkItems) {
|
||||
if (item.groupId == groupId && item.recipeId != null) {
|
||||
if (item.recipeId == null && item.type != BookmarkItemType.ITEM) {
|
||||
item.type = BookmarkItemType.ITEM;
|
||||
} else if (item.groupId == groupId && item.recipeId != null && item.type != BookmarkItemType.ITEM) {
|
||||
recipeState.put(
|
||||
item.recipeId,
|
||||
recipeState.getOrDefault(item.recipeId, 0) | (item.isIngredient ? 1 : 2));
|
||||
recipeState.getOrDefault(item.recipeId, 0)
|
||||
| (item.type == BookmarkItemType.INGREDIENT ? 1 : 2));
|
||||
}
|
||||
}
|
||||
|
||||
for (BookmarkItem item : this.bookmarkItems) {
|
||||
if (item.groupId == groupId && item.isIngredient
|
||||
&& (item.recipeId == null || recipeState.getOrDefault(item.recipeId, 1) == 1)) {
|
||||
if (item.groupId == groupId && item.type != BookmarkItemType.ITEM
|
||||
&& recipeState.getOrDefault(item.recipeId, 0) != 3) {
|
||||
|
||||
if (item.type == BookmarkItemType.INGREDIENT) {
|
||||
item.recipeId = null;
|
||||
}
|
||||
|
||||
recipeState.remove(item.recipeId);
|
||||
item.isIngredient = false;
|
||||
item.recipeId = null;
|
||||
item.type = BookmarkItemType.ITEM;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,7 +413,8 @@ public class BookmarkGrid extends ItemsGrid<BookmarksGridSlot, BookmarkGrid.Book
|
||||
|
||||
for (int index = itemIndex; index < size; index++) {
|
||||
if (item.equalsRecipe(this.bookmarkItems.get(index))) {
|
||||
sortingRank.put(index, this.bookmarkItems.get(index).isIngredient ? 1 : -1);
|
||||
sortingRank
|
||||
.put(index, this.bookmarkItems.get(index).type == BookmarkItemType.INGREDIENT ? 1 : -1);
|
||||
items.add(index);
|
||||
}
|
||||
}
|
||||
@@ -632,6 +641,7 @@ public class BookmarkGrid extends ItemsGrid<BookmarksGridSlot, BookmarkGrid.Book
|
||||
|
||||
if (group.crafting == null) {
|
||||
for (BookmarkItem item : chainItems) {
|
||||
item.type = BookmarkItemType.ITEM;
|
||||
item.recipeId = null;
|
||||
}
|
||||
}
|
||||
@@ -761,6 +771,25 @@ public class BookmarkGrid extends ItemsGrid<BookmarksGridSlot, BookmarkGrid.Book
|
||||
int absoluteSlotIndex = absoluteRowIndex * this.columns;
|
||||
int overGroupId = getRowGroupId(overRowIndex);
|
||||
|
||||
// move group to same grid
|
||||
if (this != sortableGroup.grid) {
|
||||
final BookmarkGroup sourceGroup = sortableGroup.grid.getGroup(sortableGroup.groupId);
|
||||
final List<BookmarkItem> itemsToMove = sortableGroup.getBookmarkItems();
|
||||
|
||||
sortableGroup.grid.removeGroup(sortableGroup.groupId);
|
||||
|
||||
final int groupId = this.addGroup(sourceGroup);
|
||||
for (BookmarkItem item : itemsToMove) {
|
||||
item.groupId = groupId;
|
||||
this.bookmarkItems.add(item);
|
||||
}
|
||||
|
||||
sortableGroup.grid = this;
|
||||
sortableGroup.groupId = groupId;
|
||||
this.onItemsChanged();
|
||||
this.getMask();// force generate grid
|
||||
}
|
||||
|
||||
if (sortableGroup.groupId == overGroupId) {
|
||||
return;
|
||||
}
|
||||
@@ -820,7 +849,7 @@ public class BookmarkGrid extends ItemsGrid<BookmarksGridSlot, BookmarkGrid.Book
|
||||
|
||||
for (int itemIndex = 0; itemIndex < this.bookmarkItems.size(); itemIndex++) {
|
||||
final BookmarkItem item = this.bookmarkItems.get(itemIndex);
|
||||
if (item.groupId == groupId && item.isIngredient == ingredient
|
||||
if (item.groupId == groupId && ingredient == (item.type == BookmarkItemType.INGREDIENT)
|
||||
&& (recipeId == item.recipeId || recipeId != null && recipeId.equals(item.recipeId))
|
||||
&& StackInfo.equalItemAndNBT(stackA, item.itemStack, true)) {
|
||||
return itemIndex;
|
||||
@@ -876,7 +905,12 @@ public class BookmarkGrid extends ItemsGrid<BookmarksGridSlot, BookmarkGrid.Book
|
||||
for (ItemStack stack : ItemStackAmount.of(results).values()) {
|
||||
long factor = StackInfo.getAmount(stack);
|
||||
this.addItem(
|
||||
BookmarkItem.of(groupId, StackInfo.withAmount(stack, factor * multiplier), factor, recipeId, false),
|
||||
BookmarkItem.of(
|
||||
groupId,
|
||||
StackInfo.withAmount(stack, factor * multiplier),
|
||||
factor,
|
||||
recipeId,
|
||||
BookmarkItemType.RESULT),
|
||||
true);
|
||||
}
|
||||
|
||||
@@ -888,7 +922,7 @@ public class BookmarkGrid extends ItemsGrid<BookmarksGridSlot, BookmarkGrid.Book
|
||||
StackInfo.withAmount(stack, factor * multiplier),
|
||||
factor,
|
||||
recipeId,
|
||||
true,
|
||||
BookmarkItemType.INGREDIENT,
|
||||
BookmarkItem.generatePermutations(stack, recipe)),
|
||||
true);
|
||||
}
|
||||
@@ -901,12 +935,12 @@ public class BookmarkGrid extends ItemsGrid<BookmarksGridSlot, BookmarkGrid.Book
|
||||
return;
|
||||
}
|
||||
|
||||
if (!removeFullRecipe && item.recipeId != null && !item.isIngredient) {
|
||||
if (!removeFullRecipe && item.recipeId != null && item.type == BookmarkItemType.RESULT) {
|
||||
removeFullRecipe = this.bookmarkItems.stream()
|
||||
.noneMatch(m -> !m.isIngredient && !m.equals(item) && item.equalsRecipe(m));
|
||||
.noneMatch(m -> m.type == BookmarkItemType.RESULT && !m.equals(item) && item.equalsRecipe(m));
|
||||
}
|
||||
|
||||
if (item.recipeId != null && removeFullRecipe) {
|
||||
if (item.recipeId != null && item.type != BookmarkItemType.ITEM && removeFullRecipe) {
|
||||
removeRecipe(item.recipeId, item.groupId);
|
||||
} else if (itemIndex >= 0) {
|
||||
this.bookmarkItems.remove(itemIndex);
|
||||
@@ -925,7 +959,8 @@ public class BookmarkGrid extends ItemsGrid<BookmarksGridSlot, BookmarkGrid.Book
|
||||
}
|
||||
|
||||
public boolean existsRecipe(RecipeId recipeId, int groupId) {
|
||||
return this.bookmarkItems.stream().anyMatch(item -> item.equalsRecipe(recipeId, groupId));
|
||||
return this.bookmarkItems.stream()
|
||||
.anyMatch(item -> item.type != BookmarkItemType.ITEM && item.equalsRecipe(recipeId, groupId));
|
||||
}
|
||||
|
||||
public RecipeId getRecipeId(int itemIndex) {
|
||||
@@ -1028,8 +1063,14 @@ public class BookmarkGrid extends ItemsGrid<BookmarksGridSlot, BookmarkGrid.Book
|
||||
}
|
||||
|
||||
if (bookmarkItem != null && (group.crafting != null && group.viewMode == BookmarkViewMode.DEFAULT
|
||||
|| group.viewMode == BookmarkViewMode.TODO_LIST && !sortableItem.bookmarkItem.isIngredient)) {
|
||||
while (sortIndex > 0 && bookmarkItem.equalsRecipe(getCalculatedItem(sortedIndexes.get(sortIndex - 1)))) {
|
||||
|| group.viewMode == BookmarkViewMode.TODO_LIST
|
||||
&& sortableItem.bookmarkItem.type == BookmarkItemType.RESULT)) {
|
||||
BookmarkItem prevBookmarkItem = sortIndex > 1 ? getCalculatedItem(sortedIndexes.get(sortIndex - 1)) : null;
|
||||
|
||||
while (sortIndex > 0 && prevBookmarkItem != null
|
||||
&& prevBookmarkItem.type != BookmarkItemType.ITEM
|
||||
&& bookmarkItem.equalsRecipe(prevBookmarkItem)) {
|
||||
prevBookmarkItem = sortIndex > 1 ? getCalculatedItem(sortedIndexes.get(sortIndex - 1)) : null;
|
||||
sortIndex--;
|
||||
}
|
||||
|
||||
@@ -1058,7 +1099,7 @@ public class BookmarkGrid extends ItemsGrid<BookmarksGridSlot, BookmarkGrid.Book
|
||||
if (nextSortIndex < sortedIndexes.size()) {
|
||||
final int nextItemIndex = sortedIndexes.get(nextSortIndex);
|
||||
|
||||
if (group.viewMode == BookmarkViewMode.TODO_LIST && !target.isIngredient
|
||||
if (group.viewMode == BookmarkViewMode.TODO_LIST && target.type == BookmarkItemType.RESULT
|
||||
&& target.equalsRecipe(getCalculatedItem(nextItemIndex))) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1149,7 +1190,7 @@ public class BookmarkGrid extends ItemsGrid<BookmarksGridSlot, BookmarkGrid.Book
|
||||
|
||||
if (group.collapsed) {
|
||||
shiftGroupAmount(targetItem.groupId, shift);
|
||||
} else if (targetItem.recipeId != null) {
|
||||
} else if (targetItem.recipeId != null && targetItem.type != BookmarkItemType.ITEM) {
|
||||
final RecipeId recipeId = this.gridGenerator.itemToRecipe
|
||||
.getOrDefault(targetItemIndex, targetItem.recipeId);
|
||||
final boolean recipeInMiddle = group.crafting != null && group.crafting.recipeInMiddle.contains(recipeId);
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import codechicken.nei.BookmarkPanel.BookmarkViewMode;
|
||||
import codechicken.nei.ItemSorter;
|
||||
import codechicken.nei.bookmark.BookmarkItem.BookmarkItemType;
|
||||
import codechicken.nei.bookmark.RecipeChainDetails.BookmarkChainItem;
|
||||
import codechicken.nei.bookmark.RecipeChainDetails.CalculatedType;
|
||||
import codechicken.nei.recipe.Recipe.RecipeId;
|
||||
@@ -165,7 +166,7 @@ public class BookmarkGridGenerator {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!bookmarkItem.isIngredient
|
||||
if (bookmarkItem.type != BookmarkItemType.INGREDIENT
|
||||
&& (group.crafting == null || group.crafting.calculatedItems.containsKey(itemIndex))) {
|
||||
results.add(itemIndex);
|
||||
}
|
||||
@@ -193,7 +194,7 @@ public class BookmarkGridGenerator {
|
||||
bookmarkItem.itemStack,
|
||||
1,
|
||||
bookmarkItem.recipeId,
|
||||
isIngredient,
|
||||
isIngredient ? BookmarkItemType.INGREDIENT : BookmarkItemType.RESULT,
|
||||
Collections.emptyMap());
|
||||
|
||||
if ((absoluteSlotIndex = nextSlotIndex(
|
||||
@@ -238,17 +239,21 @@ public class BookmarkGridGenerator {
|
||||
return index;
|
||||
} else if (isFirstColumn && (meta.recipeId == null || previousMeta == null
|
||||
|| previousMeta.groupId != meta.groupId
|
||||
|| meta.type == BookmarkItemType.ITEM
|
||||
|| !meta.recipeId.equals(previousMeta.recipeId)
|
||||
|| index + 1 < maxIndex && this.grid.isInvalidSlot((index + 1) % maxIndex))) {
|
||||
// In first column must be an item without recipe, a recipe result, or an ingredient
|
||||
// if the second column is occupied
|
||||
return index;
|
||||
} else
|
||||
if (!isFirstColumn && meta.recipeId != null && meta.recipeId.equals(previousMeta.recipeId)) {
|
||||
return index;
|
||||
} else {
|
||||
index++;
|
||||
}
|
||||
if (!isFirstColumn && meta.type != BookmarkItemType.ITEM
|
||||
&& previousMeta.type != BookmarkItemType.ITEM
|
||||
&& meta.recipeId != null
|
||||
&& meta.recipeId.equals(previousMeta.recipeId)) {
|
||||
return index;
|
||||
} else {
|
||||
index++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,21 @@ import codechicken.nei.recipe.StackInfo;
|
||||
|
||||
public class BookmarkItem {
|
||||
|
||||
public enum BookmarkItemType {
|
||||
|
||||
INGREDIENT,
|
||||
RESULT,
|
||||
ITEM;
|
||||
|
||||
public static BookmarkItemType fromInt(int type) {
|
||||
return type == 0 ? ITEM : type == 1 ? RESULT : INGREDIENT;
|
||||
}
|
||||
|
||||
public int toInt() {
|
||||
return this == ITEM ? 0 : this == RESULT ? 1 : 2;
|
||||
}
|
||||
}
|
||||
|
||||
private static Map<ItemStack, String> fuzzyPermutations = new HashMap<>();
|
||||
|
||||
public int groupId;
|
||||
@@ -28,10 +43,10 @@ public class BookmarkItem {
|
||||
|
||||
public long factor;
|
||||
public RecipeId recipeId;
|
||||
public boolean isIngredient = false;
|
||||
public BookmarkItemType type = BookmarkItemType.ITEM;
|
||||
|
||||
protected BookmarkItem(int groupId, long amount, int fluidCellAmount, ItemStack itemStack,
|
||||
Map<String, ItemStack> permutations, long factor, RecipeId recipeId, boolean isIngredient) {
|
||||
Map<String, ItemStack> permutations, long factor, RecipeId recipeId, BookmarkItemType type) {
|
||||
this.groupId = groupId;
|
||||
|
||||
this.amount = amount;
|
||||
@@ -41,10 +56,10 @@ public class BookmarkItem {
|
||||
|
||||
this.factor = factor;
|
||||
this.recipeId = recipeId;
|
||||
this.isIngredient = isIngredient;
|
||||
this.type = type == null ? BookmarkItemType.ITEM : type;
|
||||
}
|
||||
|
||||
public static BookmarkItem of(int groupId, ItemStack stack, long factor, RecipeId recipeId, boolean isIngredient,
|
||||
public static BookmarkItem of(int groupId, ItemStack stack, long factor, RecipeId recipeId, BookmarkItemType type,
|
||||
Map<String, ItemStack> permutations) {
|
||||
final FluidStack fluidStack = StackInfo.getFluid(stack);
|
||||
int fluidCellAmount = 1;
|
||||
@@ -65,18 +80,29 @@ public class BookmarkItem {
|
||||
permutations,
|
||||
factor * fluidCellAmount,
|
||||
recipeId,
|
||||
isIngredient);
|
||||
type);
|
||||
}
|
||||
|
||||
public static BookmarkItem of(int groupId, ItemStack stack, long factor, RecipeId recipeId, boolean isIngredient) {
|
||||
return of(groupId, stack, factor, recipeId, isIngredient, generatePermutations(stack, recipeId, isIngredient));
|
||||
public static BookmarkItem of(int groupId, ItemStack stack, long factor, RecipeId recipeId, BookmarkItemType type) {
|
||||
return of(
|
||||
groupId,
|
||||
stack,
|
||||
factor,
|
||||
recipeId,
|
||||
type,
|
||||
generatePermutations(stack, recipeId, type == BookmarkItemType.INGREDIENT));
|
||||
}
|
||||
|
||||
public static BookmarkItem of(int groupId, ItemStack stack) {
|
||||
final NBTTagCompound nbTag = StackInfo.itemStackToNBT(stack);
|
||||
final long factor = nbTag.hasKey("gtFluidName") ? Math.min(144, nbTag.getInteger("Count")) : 1;
|
||||
return BookmarkItem
|
||||
.of(groupId, stack, factor, null, false, Collections.singletonMap(getItemGUID(stack), stack));
|
||||
return BookmarkItem.of(
|
||||
groupId,
|
||||
stack,
|
||||
factor,
|
||||
null,
|
||||
BookmarkItemType.ITEM,
|
||||
Collections.singletonMap(getItemGUID(stack), stack));
|
||||
}
|
||||
|
||||
public BookmarkItem copyWithAmount(long amount) {
|
||||
@@ -88,7 +114,7 @@ public class BookmarkItem {
|
||||
this.permutations,
|
||||
this.factor,
|
||||
this.recipeId,
|
||||
this.isIngredient);
|
||||
this.type);
|
||||
}
|
||||
|
||||
public BookmarkItem copy() {
|
||||
@@ -186,14 +212,14 @@ public class BookmarkItem {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.groupId, this.fluidCellAmount, this.isIngredient, this.recipeId);
|
||||
return Objects.hash(this.groupId, this.fluidCellAmount, this.type.toInt(), this.recipeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
|
||||
if (object instanceof BookmarkItem item) {
|
||||
return this.groupId == item.groupId && this.isIngredient == item.isIngredient
|
||||
return this.groupId == item.groupId && this.type == item.type
|
||||
&& this.fluidCellAmount == item.fluidCellAmount
|
||||
&& StackInfo.equalItemAndNBT(this.itemStack, item.itemStack, true)
|
||||
&& (this.recipeId == item.recipeId || this.recipeId != null && this.recipeId.equals(item.recipeId));
|
||||
|
||||
@@ -7,7 +7,6 @@ import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -16,6 +15,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
@@ -25,6 +25,7 @@ import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import codechicken.nei.BookmarkPanel.BookmarkViewMode;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.bookmark.BookmarkItem.BookmarkItemType;
|
||||
import codechicken.nei.recipe.Recipe.RecipeId;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import codechicken.nei.util.NBTJson;
|
||||
@@ -136,6 +137,7 @@ public class BookmarkStorage {
|
||||
NBTTagCompound navigation = new NBTTagCompound();
|
||||
namespaces.add(new BookmarkGrid());
|
||||
BookmarkGrid grid = namespaces.get(0);
|
||||
boolean wasError = false;
|
||||
|
||||
if (NEIClientConfig.world.nbt.hasKey("bookmark")) {
|
||||
navigation = NEIClientConfig.world.nbt.getCompoundTag("bookmark");
|
||||
@@ -150,17 +152,19 @@ public class BookmarkStorage {
|
||||
}
|
||||
|
||||
if (itemStr.startsWith("; ")) {
|
||||
JsonObject settings = parser.parse(itemStr.substring(2)).getAsJsonObject();
|
||||
|
||||
if (grid.size() > 0) {
|
||||
// do not create empty namespaces
|
||||
grid = new BookmarkGrid();
|
||||
|
||||
if (navigation.hasKey("namespacePage." + namespaces.size())) {
|
||||
grid.setPage(navigation.getInteger("namespacePage." + namespaces.size()));
|
||||
}
|
||||
|
||||
namespaces.add(grid);
|
||||
}
|
||||
|
||||
if (navigation.hasKey("namespacePage." + (namespaces.size() - 1))) {
|
||||
grid.setPage(navigation.getInteger("namespacePage." + (namespaces.size() - 1)));;
|
||||
}
|
||||
final JsonObject settings = parser.parse(itemStr.substring(2)).getAsJsonObject();
|
||||
|
||||
if (settings.get("viewmode") != null) {
|
||||
grid.groups.get(BookmarkGrid.DEFAULT_GROUP_ID).viewMode = BookmarkViewMode
|
||||
@@ -195,17 +199,28 @@ public class BookmarkStorage {
|
||||
}
|
||||
|
||||
if (!addItemToGrid(grid, parser.parse(itemStr).getAsJsonObject())) {
|
||||
wasError = true;
|
||||
NEIClientConfig.logger.warn(
|
||||
"Failed to load bookmarked ItemStack from json string, the item no longer exists:\n{}",
|
||||
itemStr);
|
||||
}
|
||||
|
||||
} catch (IllegalArgumentException | JsonSyntaxException | IllegalStateException e) {
|
||||
} catch (Exception e) {
|
||||
wasError = true;
|
||||
NEIClientConfig.logger.error("Failed to load bookmarked ItemStack from json string:\n{}", itemStr);
|
||||
}
|
||||
}
|
||||
|
||||
prepareOldRecipeFormat(namespaces);
|
||||
if (wasError) {
|
||||
try {
|
||||
Files.copy(
|
||||
bookmarkFile,
|
||||
new File(bookmarkFile.getAbsolutePath() + ".backup-" + System.currentTimeMillis()));
|
||||
NEIClientConfig.logger.info("Backed up invalid bookmark file to {}", bookmarkFile);
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Failed to backup invalid bookmark file to {}", bookmarkFile, e);
|
||||
}
|
||||
}
|
||||
|
||||
for (BookmarkGrid gr : namespaces) {
|
||||
gr.onItemsChanged();
|
||||
@@ -239,7 +254,15 @@ public class BookmarkStorage {
|
||||
int groupId = jsonObject.has("groupId") ? jsonObject.get("groupId").getAsInt()
|
||||
: BookmarkGrid.DEFAULT_GROUP_ID;
|
||||
int factor = jsonObject.has("factor") ? Math.abs(jsonObject.get("factor").getAsInt()) : (isFluid ? 144 : 1);
|
||||
boolean isIngredient = jsonObject.has("ingredient") && jsonObject.get("ingredient").getAsBoolean();
|
||||
BookmarkItemType type = jsonObject.has("type") ? BookmarkItemType.fromInt(jsonObject.get("type").getAsInt())
|
||||
: null;
|
||||
|
||||
if (type == null) {
|
||||
// old format
|
||||
type = jsonObject.has("ingredient") && jsonObject.get("ingredient").getAsBoolean()
|
||||
? BookmarkItemType.INGREDIENT
|
||||
: BookmarkItemType.RESULT;
|
||||
}
|
||||
|
||||
if (jsonObject.get("recipeId") instanceof JsonObject recipeJson) {
|
||||
recipeId = RecipeId.of(recipeJson);
|
||||
@@ -249,51 +272,12 @@ public class BookmarkStorage {
|
||||
groupId = BookmarkGrid.DEFAULT_GROUP_ID;
|
||||
}
|
||||
|
||||
grid.addItem(BookmarkItem.of(groupId, itemStack, factor, recipeId, isIngredient), false);
|
||||
grid.addItem(BookmarkItem.of(groupId, itemStack, factor, recipeId, type), false);
|
||||
}
|
||||
|
||||
return itemStack != null;
|
||||
}
|
||||
|
||||
private void prepareOldRecipeFormat(List<BookmarkGrid> namespaces) {
|
||||
|
||||
for (BookmarkGrid grid : namespaces) {
|
||||
if (grid.bookmarkItems.stream()
|
||||
.noneMatch(item -> item.recipeId != null && item.recipeId.getResult() == null)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final Map<String, RecipeId> recipes = new HashMap<>();
|
||||
|
||||
for (BookmarkItem item : grid.bookmarkItems) {
|
||||
if (item.recipeId != null && !item.isIngredient && item.recipeId.getResult() == null) {
|
||||
final JsonObject recipeJson = item.recipeId.toJsonObject();
|
||||
final String recipeGUID = item.groupId + ":" + NBTJson.toJson(recipeJson);
|
||||
|
||||
if (!recipes.containsKey(recipeGUID)) {
|
||||
recipeJson.add("result", NBTJson.toJsonObject(StackInfo.itemStackToNBT(item.itemStack)));
|
||||
recipes.put(recipeGUID, item.recipeId = RecipeId.of(recipeJson));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (BookmarkItem item : grid.bookmarkItems) {
|
||||
if (item.recipeId != null && item.recipeId.getResult() == null) {
|
||||
final JsonObject recipeJson = item.recipeId.toJsonObject();
|
||||
final String recipeGUID = item.groupId + ":" + NBTJson.toJson(recipeJson);
|
||||
|
||||
if (recipes.containsKey(recipeGUID)) {
|
||||
item.recipeId = recipes.get(recipeGUID).copy();
|
||||
item.permutations = BookmarkItem
|
||||
.generatePermutations(item.itemStack, item.recipeId, item.isIngredient);
|
||||
} else {
|
||||
item.recipeId = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
|
||||
if (this.bookmarkFile == null) {
|
||||
@@ -338,7 +322,7 @@ public class BookmarkStorage {
|
||||
|
||||
row.add("item", NBTJson.toJsonObject(StackInfo.itemStackToNBT(item.getItemStack())));
|
||||
row.add("factor", new JsonPrimitive(item.getFactor()));
|
||||
row.add("ingredient", new JsonPrimitive(item.isIngredient));
|
||||
row.add("type", new JsonPrimitive(item.type.toInt()));
|
||||
|
||||
if (item.groupId != BookmarkGrid.DEFAULT_GROUP_ID) {
|
||||
row.add("groupId", new JsonPrimitive(item.groupId));
|
||||
|
||||
@@ -15,6 +15,7 @@ import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.NEIClientUtils.Alignment;
|
||||
import codechicken.nei.bookmark.BookmarkGrid.BookmarkMouseContext;
|
||||
import codechicken.nei.bookmark.BookmarkItem.BookmarkItemType;
|
||||
import codechicken.nei.bookmark.RecipeChainDetails.CalculatedType;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.recipe.GuiRecipeTab;
|
||||
@@ -89,7 +90,7 @@ public class BookmarksGridSlot extends ItemsGridSlot {
|
||||
this.realType = this.group.crafting.calculatedItems.get(this.itemIndex).calculatedType
|
||||
== CalculatedType.INGREDIENT ? CalculatedType.INGREDIENT : CalculatedType.RESULT;
|
||||
} else {
|
||||
this.realType = this.bookmarkItem.isIngredient
|
||||
this.realType = this.bookmarkItem.type == BookmarkItemType.INGREDIENT
|
||||
|| this.group.crafting != null && this.bookmarkItem.recipeId == null ? CalculatedType.INGREDIENT
|
||||
: CalculatedType.RESULT;
|
||||
}
|
||||
@@ -97,9 +98,10 @@ public class BookmarksGridSlot extends ItemsGridSlot {
|
||||
final BookmarkGrid grid = ItemPanels.bookmarkPanel.getGrid();
|
||||
final BookmarkItem prevItem = grid.getCalculatedItem(
|
||||
grid.gridGenerator.slotToItem.getOrDefault(grid.gridGenerator.itemToSlot.get(this.itemIndex) - 1, -1));
|
||||
this.isFirstOutput = this.itemIndex >= 0 && !this.bookmarkItem.isIngredient
|
||||
this.isFirstOutput = this.itemIndex >= 0 && this.bookmarkItem.type == BookmarkItemType.RESULT
|
||||
&& ((this.slotIndex % grid.getColumns()) == 0 || group.viewMode == BookmarkViewMode.DEFAULT)
|
||||
&& (prevItem == null || prevItem.isIngredient || !this.bookmarkItem.equalsRecipe(prevItem));
|
||||
&& (prevItem == null || prevItem.type == BookmarkItemType.INGREDIENT
|
||||
|| !this.bookmarkItem.equalsRecipe(prevItem));
|
||||
this.rowIndex = this.slotIndex / grid.getColumns();
|
||||
}
|
||||
|
||||
@@ -116,8 +118,8 @@ public class BookmarksGridSlot extends ItemsGridSlot {
|
||||
return this.bookmarkItem.recipeId;
|
||||
}
|
||||
|
||||
public boolean isIngredient() {
|
||||
return this.bookmarkItem.isIngredient;
|
||||
public BookmarkItemType getType() {
|
||||
return this.bookmarkItem.type;
|
||||
}
|
||||
|
||||
public BookmarkGroup getGroup() {
|
||||
@@ -151,11 +153,17 @@ public class BookmarksGridSlot extends ItemsGridSlot {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.group.crafting != null) {
|
||||
if (this.slotIndex == mouseContext.slotIndex || this.group.crafting != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return this.bookmarkItem.equalsRecipe(mouseContext.recipeId, mouseContext.groupId);
|
||||
if (this.bookmarkItem.type == BookmarkItemType.ITEM && this.group.viewMode == BookmarkViewMode.TODO_LIST
|
||||
&& mouseContext.rowIndex == this.rowIndex) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return this.bookmarkItem.type != BookmarkItemType.ITEM
|
||||
&& this.bookmarkItem.equalsRecipe(mouseContext.recipeId, mouseContext.groupId);
|
||||
}
|
||||
|
||||
protected boolean showRealItem(BookmarkMouseContext mouseContext) {
|
||||
@@ -173,7 +181,8 @@ public class BookmarksGridSlot extends ItemsGridSlot {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.bookmarkItem.equalsRecipe(mouseContext.recipeId, mouseContext.groupId)) {
|
||||
if (this.bookmarkItem.type != BookmarkItemType.ITEM
|
||||
&& this.bookmarkItem.equalsRecipe(mouseContext.recipeId, mouseContext.groupId)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -212,7 +221,7 @@ public class BookmarksGridSlot extends ItemsGridSlot {
|
||||
|
||||
}
|
||||
|
||||
if (!this.bookmarkItem.isIngredient && this.bookmarkItem.recipeId != null
|
||||
if (this.bookmarkItem.type != BookmarkItemType.INGREDIENT && this.bookmarkItem.recipeId != null
|
||||
&& calculatedType == null
|
||||
&& showMarker
|
||||
&& (mouseContext == null || mouseContext.slotIndex != this.slotIndex)) {
|
||||
@@ -259,7 +268,7 @@ public class BookmarksGridSlot extends ItemsGridSlot {
|
||||
|
||||
drawStackSize(rect, shownItemType);
|
||||
|
||||
if (this.bookmarkItem.isIngredient || this.bookmarkItem.recipeId == null) {
|
||||
if (this.bookmarkItem.type == BookmarkItemType.INGREDIENT || this.bookmarkItem.recipeId == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -283,18 +292,17 @@ public class BookmarksGridSlot extends ItemsGridSlot {
|
||||
NEIClientConfig.getSetting("inventory.bookmarks.recipeMarkerColor").getHexValue(),
|
||||
Alignment.TopLeft);
|
||||
}
|
||||
}
|
||||
|
||||
if (NEIClientConfig.getBooleanSetting("inventory.bookmarks.showRecipeHandlerIcon")
|
||||
&& getHandlerInfo() != null) {
|
||||
drawHandlerIcon(rect);
|
||||
} else if (NEIClientConfig.showRecipeMarkerMode() == 1) {
|
||||
drawMarker(
|
||||
rect,
|
||||
"R",
|
||||
NEIClientConfig.getSetting("inventory.bookmarks.recipeMarkerColor").getHexValue(),
|
||||
Alignment.TopRight);
|
||||
}
|
||||
if (this.isFirstOutput || NEIClientConfig.showRecipeMarkerMode() == 1) {
|
||||
drawRecipeMarker(rect);
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawRecipeMarker(Rectangle4i rect) {
|
||||
if (NEIClientConfig.getBooleanSetting("inventory.bookmarks.showRecipeHandlerIcon")
|
||||
&& getHandlerInfo() != null) {
|
||||
drawHandlerIcon(rect);
|
||||
} else if (NEIClientConfig.showRecipeMarkerMode() == 1) {
|
||||
drawMarker(
|
||||
rect,
|
||||
@@ -302,7 +310,6 @@ public class BookmarksGridSlot extends ItemsGridSlot {
|
||||
NEIClientConfig.getSetting("inventory.bookmarks.recipeMarkerColor").getHexValue(),
|
||||
Alignment.TopRight);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void drawHandlerIcon(Rectangle4i rect) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import codechicken.nei.BookmarkPanel.BookmarkViewMode;
|
||||
import codechicken.nei.bookmark.BookmarkItem.BookmarkItemType;
|
||||
import codechicken.nei.recipe.Recipe.RecipeId;
|
||||
|
||||
public class GroupingItem {
|
||||
@@ -124,7 +125,7 @@ public class GroupingItem {
|
||||
|
||||
final BookmarkItem item = this.grid.getCalculatedItem(itemIndex);
|
||||
|
||||
if (item.recipeId != null) {
|
||||
if (item.recipeId != null && item.type != BookmarkItemType.ITEM) {
|
||||
final List<Integer> sortedItems = this.grid.getSortedItems();
|
||||
final BookmarkGroup group = this.grid.getGroup(item.groupId);
|
||||
final boolean isCollapsedGroup = group.collapsed
|
||||
@@ -139,7 +140,8 @@ public class GroupingItem {
|
||||
for (Integer rItemIndex : sortedItems) {
|
||||
final BookmarkItem rItem = this.grid.getCalculatedItem(rItemIndex);
|
||||
|
||||
if (rItem.groupId == item.groupId && (isCollapsedGroup || recipeRelations.contains(rItem.recipeId))) {
|
||||
if (rItem.groupId == item.groupId && (isCollapsedGroup
|
||||
|| rItem.type != BookmarkItemType.ITEM && recipeRelations.contains(rItem.recipeId))) {
|
||||
return this.grid.getAbsoluteSlotIndex(rItemIndex) / this.grid.getColumns();
|
||||
}
|
||||
}
|
||||
@@ -160,7 +162,7 @@ public class GroupingItem {
|
||||
|
||||
final BookmarkItem item = this.grid.getCalculatedItem(itemIndex);
|
||||
|
||||
if (item.recipeId != null) {
|
||||
if (item.recipeId != null && item.type != BookmarkItemType.ITEM) {
|
||||
final List<Integer> sortedItems = this.grid.getSortedItems();
|
||||
final BookmarkGroup group = this.grid.getGroup(item.groupId);
|
||||
final boolean isCollapsedGroup = group.collapsed
|
||||
@@ -176,7 +178,8 @@ public class GroupingItem {
|
||||
final int rItemIndex = sortedItems.get(index);
|
||||
final BookmarkItem rItem = this.grid.getCalculatedItem(rItemIndex);
|
||||
|
||||
if (rItem.groupId == item.groupId && (isCollapsedGroup || recipeRelations.contains(rItem.recipeId))) {
|
||||
if (rItem.groupId == item.groupId && (isCollapsedGroup
|
||||
|| rItem.type != BookmarkItemType.ITEM && recipeRelations.contains(rItem.recipeId))) {
|
||||
return this.grid.getAbsoluteSlotIndex(rItemIndex) / this.grid.getColumns();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import codechicken.nei.bookmark.BookmarkItem.BookmarkItemType;
|
||||
import codechicken.nei.recipe.Recipe.RecipeId;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import codechicken.nei.recipe.chain.RecipeChainMath;
|
||||
@@ -69,7 +70,7 @@ public class RecipeChainDetails {
|
||||
item,
|
||||
item.amount,
|
||||
item.amount,
|
||||
item.isIngredient ? CalculatedType.INGREDIENT : CalculatedType.RESULT);
|
||||
item.type == BookmarkItemType.INGREDIENT ? CalculatedType.INGREDIENT : CalculatedType.RESULT);
|
||||
}
|
||||
|
||||
public ItemStack getItemStack(long amount) {
|
||||
@@ -217,11 +218,12 @@ public class RecipeChainDetails {
|
||||
for (BookmarkChainItem value : items) {
|
||||
int itemIndex = sortingChainItems.get(value.getItem());
|
||||
|
||||
if (value.getItem().isIngredient || !recipeId.equals(value.getItem().recipeId)) {
|
||||
if (value.getItem().type == BookmarkItemType.INGREDIENT || !recipeId.equals(value.getItem().recipeId)) {
|
||||
itemIndex *= -1;
|
||||
}
|
||||
|
||||
if (!value.getItem().isIngredient && !math.outputRecipes.containsKey(value.getItem().recipeId)) {
|
||||
if (value.getItem().type == BookmarkItemType.RESULT
|
||||
&& !math.outputRecipes.containsKey(value.getItem().recipeId)) {
|
||||
value.calculatedType = CalculatedType.REMAINDER;
|
||||
}
|
||||
|
||||
@@ -251,7 +253,7 @@ public class RecipeChainDetails {
|
||||
for (BookmarkChainItem value : items) {
|
||||
int itemIndex = sortingChainItems.get(value.getItem());
|
||||
|
||||
if (value.getItem().isIngredient || !recipeId.equals(value.getItem().recipeId)) {
|
||||
if (value.getItem().type == BookmarkItemType.INGREDIENT || !recipeId.equals(value.getItem().recipeId)) {
|
||||
itemIndex *= -1;
|
||||
}
|
||||
|
||||
@@ -348,22 +350,20 @@ public class RecipeChainDetails {
|
||||
private Set<RecipeId> getRecipeParents(RecipeChainMath math, RecipeId recipeId, Set<RecipeId> parents,
|
||||
Set<RecipeId> visited) {
|
||||
final Set<RecipeId> recipeIds = math.preferredItems.entrySet().stream()
|
||||
.filter(
|
||||
entry -> entry.getValue() != null && recipeId.equals(entry.getValue().recipeId)
|
||||
&& !visited.contains(entry.getKey().recipeId))
|
||||
.filter(entry -> entry.getValue() != null && recipeId.equals(entry.getValue().recipeId))
|
||||
.map(entry -> entry.getKey().recipeId).collect(Collectors.toSet());
|
||||
|
||||
visited.addAll(recipeIds);
|
||||
|
||||
if (recipeIds.isEmpty()) {
|
||||
parents.add(recipeId);
|
||||
} else {
|
||||
|
||||
for (RecipeId ingrRecipeId : recipeIds) {
|
||||
if (math.outputRecipes.containsKey(ingrRecipeId)) {
|
||||
parents.add(ingrRecipeId);
|
||||
} else {
|
||||
getRecipeParents(math, ingrRecipeId, parents, visited);
|
||||
if (visited.add(ingrRecipeId)) {
|
||||
if (math.outputRecipes.containsKey(ingrRecipeId)) {
|
||||
parents.add(ingrRecipeId);
|
||||
} else {
|
||||
getRecipeParents(math, ingrRecipeId, parents, visited);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.util.Map;
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.BookmarkPanel.BookmarkViewMode;
|
||||
import codechicken.nei.ItemsGrid;
|
||||
import codechicken.nei.bookmark.BookmarkItem.BookmarkItemType;
|
||||
import codechicken.nei.bookmark.RecipeChainDetails.BookmarkChainItem;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.recipe.Recipe.RecipeId;
|
||||
@@ -30,10 +31,10 @@ public class SortableItem {
|
||||
|
||||
this.grid = grid;
|
||||
this.bookmarkItem = bookmarkItem.copy();
|
||||
this.moveRecipe = bookmarkItem.recipeId != null && !bookmarkItem.isIngredient
|
||||
this.moveRecipe = bookmarkItem.recipeId != null && bookmarkItem.type == BookmarkItemType.RESULT
|
||||
&& (group.viewMode == BookmarkViewMode.TODO_LIST || group.crafting != null);
|
||||
this.crossGroup = !group.collapsed && group.viewMode == BookmarkViewMode.TODO_LIST
|
||||
&& !this.bookmarkItem.isIngredient;
|
||||
&& bookmarkItem.type != BookmarkItemType.INGREDIENT;
|
||||
this.isCollapsedRecipe = group.crafting != null && group.crafting.itemToRecipe.values().stream()
|
||||
.anyMatch(recipeId -> this.bookmarkItem.equalsRecipe(recipeId, this.bookmarkItem.groupId));
|
||||
|
||||
|
||||
@@ -86,13 +86,14 @@ public class IMCHandler {
|
||||
info.setYShift(yShift);
|
||||
|
||||
try {
|
||||
final int imageHeight = tag.hasKey("handlerHeight") ? tag.getInteger("handlerHeight")
|
||||
final int handlerHeight = tag.hasKey("handlerHeight") ? tag.getInteger("handlerHeight")
|
||||
: HandlerInfo.DEFAULT_HEIGHT;
|
||||
final int imageWidth = tag.hasKey("handlerWidth") ? tag.getInteger("handlerWidth")
|
||||
final int handlerWidth = tag.hasKey("handlerWidth") ? tag.getInteger("handlerWidth")
|
||||
: HandlerInfo.DEFAULT_WIDTH;
|
||||
final int maxRecipesPerPage = tag.hasKey("maxRecipesPerPage") ? tag.getInteger("maxRecipesPerPage")
|
||||
: HandlerInfo.DEFAULT_MAX_PER_PAGE;
|
||||
info.setHandlerDimensions(imageHeight, imageWidth, maxRecipesPerPage);
|
||||
final boolean multipleWidgetsAllowed = tag.hasKey("multipleWidgetsAllowed")
|
||||
? tag.getBoolean("multipleWidgetsAllowed")
|
||||
: tag.hasKey("maxRecipesPerPage") && tag.getInteger("maxRecipesPerPage") > 1;
|
||||
info.setHandlerDimensions(handlerWidth, handlerHeight, multipleWidgetsAllowed);
|
||||
} catch (NumberFormatException ignored) {
|
||||
NEIClientConfig.logger.info("Error setting handler dimensions for {}", handler);
|
||||
}
|
||||
|
||||
@@ -664,12 +664,12 @@ public class GuiContainerManager {
|
||||
}
|
||||
}
|
||||
|
||||
hotkeys.remove(null);
|
||||
hotkeys.remove("");
|
||||
|
||||
if (!hotkeys.isEmpty()) {
|
||||
List<String> hotkeystips = new ArrayList<>();
|
||||
|
||||
Map<String, List<String>> messages = new HashMap<>();
|
||||
hotkeys.remove(null);
|
||||
hotkeys.remove("");
|
||||
|
||||
for (Map.Entry<String, String> entry : hotkeys.entrySet()) {
|
||||
messages.computeIfAbsent(entry.getValue(), m -> new ArrayList<>()).add(entry.getKey());
|
||||
@@ -704,13 +704,19 @@ public class GuiContainerManager {
|
||||
}
|
||||
|
||||
} else if (NEIClientConfig.getBooleanSetting("inventory.hotkeysHelpText")) {
|
||||
Map<String, String> hotkeys = new HashMap<>();
|
||||
boolean existsHotkeys = false;
|
||||
|
||||
synchronized (instanceTooltipHandlers) {
|
||||
for (IContainerTooltipHandler handler : instanceTooltipHandlers) {
|
||||
if (!handler.handleHotkeys(window, mousex, mousey, new HashMap<>()).isEmpty()) {
|
||||
existsHotkeys = true;
|
||||
break;
|
||||
if (!(hotkeys = handler.handleHotkeys(window, mousex, mousey, hotkeys)).isEmpty()) {
|
||||
hotkeys.remove("");
|
||||
hotkeys.remove(null);
|
||||
|
||||
if (!hotkeys.isEmpty()) {
|
||||
existsHotkeys = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,12 +19,12 @@ import java.util.stream.Stream;
|
||||
*
|
||||
* @param <E>
|
||||
*/
|
||||
final class HideousLinkedList<E> extends LinkedList<E> {
|
||||
public final class HideousLinkedList<E> extends LinkedList<E> {
|
||||
|
||||
private static final long serialVersionUID = -8504433551965776915L;
|
||||
private final List<E> backing;
|
||||
|
||||
HideousLinkedList(List<E> backing) {
|
||||
public HideousLinkedList(List<E> backing) {
|
||||
this.backing = backing;
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ public class DebugHandlerWidget extends Widget implements IContainerInputHandler
|
||||
private IntegerField yShift;
|
||||
private IntegerField handlerHeight;
|
||||
private IntegerField handlerWidth;
|
||||
private IntegerField maxRecipesPerPage;
|
||||
private Button multipleWidgetsAllowed;
|
||||
private Button useCustomScroll;
|
||||
|
||||
private Point dragPoint = null;
|
||||
@@ -166,15 +166,27 @@ public class DebugHandlerWidget extends Widget implements IContainerInputHandler
|
||||
}
|
||||
};
|
||||
|
||||
this.maxRecipesPerPage = new IntegerField("maxRecipesPerPage", HandlerInfo.DEFAULT_MAX_PER_PAGE) {
|
||||
this.multipleWidgetsAllowed = new Button() {
|
||||
|
||||
{
|
||||
this.h = LINE_HEIGHT;
|
||||
this.z = 2;
|
||||
}
|
||||
|
||||
public String getRenderLabel() {
|
||||
return handlerInfo.isMultipleWidgetsAllowed() ? "On" : "Off";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChange(String oldText) {
|
||||
if (getInteger() != handlerInfo.getMaxRecipesPerPage()) {
|
||||
handlerInfo.setHandlerDimensions(handlerInfo.getHeight(), handlerInfo.getWidth(), getInteger());
|
||||
updatePatch(4, getInteger(), this.defaultValue);
|
||||
}
|
||||
public boolean onButtonPress(boolean rightclick) {
|
||||
handlerInfo.setHandlerDimensions(
|
||||
handlerInfo.getWidth(),
|
||||
handlerInfo.getHeight(),
|
||||
!handlerInfo.isMultipleWidgetsAllowed());
|
||||
updatePatch(4, handlerInfo.isMultipleWidgetsAllowed() ? 1 : 0, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.handlerHeight = new IntegerField("handlerHeight", HandlerInfo.DEFAULT_HEIGHT) {
|
||||
@@ -189,9 +201,9 @@ public class DebugHandlerWidget extends Widget implements IContainerInputHandler
|
||||
public void onTextChange(String oldText) {
|
||||
if (getInteger() != handlerInfo.getHeight()) {
|
||||
handlerInfo.setHandlerDimensions(
|
||||
getInteger(),
|
||||
handlerInfo.getWidth(),
|
||||
handlerInfo.getMaxRecipesPerPage());
|
||||
getInteger(),
|
||||
handlerInfo.isMultipleWidgetsAllowed());
|
||||
updatePatch(2, getInteger(), this.defaultValue);
|
||||
}
|
||||
}
|
||||
@@ -203,9 +215,9 @@ public class DebugHandlerWidget extends Widget implements IContainerInputHandler
|
||||
public void onTextChange(String oldText) {
|
||||
if (getInteger() != handlerInfo.getWidth()) {
|
||||
handlerInfo.setHandlerDimensions(
|
||||
handlerInfo.getHeight(),
|
||||
getInteger(),
|
||||
handlerInfo.getMaxRecipesPerPage());
|
||||
handlerInfo.getHeight(),
|
||||
handlerInfo.isMultipleWidgetsAllowed());
|
||||
updatePatch(3, getInteger(), this.defaultValue);
|
||||
}
|
||||
}
|
||||
@@ -327,7 +339,7 @@ public class DebugHandlerWidget extends Widget implements IContainerInputHandler
|
||||
drawControl("yShift", this.yShift, topShift, spaceWidth);
|
||||
topShift += LINE_HEIGHT;
|
||||
|
||||
drawControl("Per Page", this.maxRecipesPerPage, topShift, spaceWidth);
|
||||
drawControl("Multi Widgets", this.multipleWidgetsAllowed, topShift, spaceWidth);
|
||||
topShift += LINE_HEIGHT;
|
||||
|
||||
drawControl("Height", this.handlerHeight, topShift, spaceWidth);
|
||||
@@ -364,7 +376,7 @@ public class DebugHandlerWidget extends Widget implements IContainerInputHandler
|
||||
LayoutManager.addWidget(this.yShift);
|
||||
LayoutManager.addWidget(this.handlerHeight);
|
||||
LayoutManager.addWidget(this.handlerWidth);
|
||||
LayoutManager.addWidget(this.maxRecipesPerPage);
|
||||
LayoutManager.addWidget(this.multipleWidgetsAllowed);
|
||||
LayoutManager.addWidget(this.useCustomScroll);
|
||||
}
|
||||
}
|
||||
@@ -383,7 +395,6 @@ public class DebugHandlerWidget extends Widget implements IContainerInputHandler
|
||||
this.yShift.setText(String.valueOf(this.handlerInfo.getYShift()));
|
||||
this.handlerHeight.setText(String.valueOf(this.handlerInfo.getHeight()));
|
||||
this.handlerWidth.setText(String.valueOf(this.handlerInfo.getWidth()));
|
||||
this.maxRecipesPerPage.setText(String.valueOf(this.handlerInfo.getMaxRecipesPerPage()));
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -467,8 +478,7 @@ public class DebugHandlerWidget extends Widget implements IContainerInputHandler
|
||||
} else if (this.handler != null) {
|
||||
return this.order.focused() || this.yShift.focused()
|
||||
|| this.handlerHeight.focused()
|
||||
|| this.handlerWidth.focused()
|
||||
|| this.maxRecipesPerPage.focused();
|
||||
|| this.handlerWidth.focused();
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -528,6 +538,10 @@ public class DebugHandlerWidget extends Widget implements IContainerInputHandler
|
||||
widget.h,
|
||||
COLORS[widget.handlerRef.recipeIndex % COLORS.length]);
|
||||
|
||||
// center cross
|
||||
GuiDraw.drawRect(widget.x + widget.w / 2 - 1, widget.y, 1, widget.h, 0x88ffffff);
|
||||
GuiDraw.drawRect(widget.x, widget.y + widget.h / 2 - 1, widget.w, 1, 0x88ffffff);
|
||||
|
||||
// blue-line-top (grid-top)
|
||||
GuiDraw.drawRect(widget.x + 14, widget.y + 5, widget.w - 38, 1, 0xff0000aa);
|
||||
|
||||
@@ -592,12 +606,14 @@ public class DebugHandlerWidget extends Widget implements IContainerInputHandler
|
||||
final int yShift = intOrDefault(parts[1], info.getYShift());
|
||||
final int height = intOrDefault(parts[2], info.getHeight());
|
||||
final int width = intOrDefault(parts[3], info.getWidth());
|
||||
final int maxRecipesPerPage = intOrDefault(parts[4], info.getMaxRecipesPerPage());
|
||||
final boolean isMultipleWidgetsAllowed = intOrDefault(
|
||||
parts[4],
|
||||
info.isMultipleWidgetsAllowed() ? 1 : 0) == 1;
|
||||
final int order = intOrDefault(parts[5], NEIClientConfig.handlerOrdering.getOrDefault(handler, 0));
|
||||
final boolean useCustomScroll = intOrDefault(parts[6], info.getUseCustomScroll() ? 1 : 0) == 1;
|
||||
|
||||
info.setYShift(yShift);
|
||||
info.setHandlerDimensions(height, width, maxRecipesPerPage);
|
||||
info.setHandlerDimensions(width, height, isMultipleWidgetsAllowed);
|
||||
info.setUseCustomScroll(useCustomScroll);
|
||||
NEIClientConfig.handlerOrdering.put(handler, order);
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.SlotCrafting;
|
||||
@@ -50,17 +50,17 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
public Slot[] slots;
|
||||
}
|
||||
|
||||
public DefaultOverlayHandler(int x, int y) {
|
||||
offsetx = x;
|
||||
offsety = y;
|
||||
}
|
||||
public int offsetx;
|
||||
public int offsety;
|
||||
|
||||
public DefaultOverlayHandler() {
|
||||
this(5, 11);
|
||||
}
|
||||
|
||||
public int offsetx;
|
||||
public int offsety;
|
||||
public DefaultOverlayHandler(int x, int y) {
|
||||
this.offsetx = x;
|
||||
this.offsety = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void overlayRecipe(GuiContainer gui, IRecipeHandler handler, int recipeIndex, boolean maxTransfer) {
|
||||
@@ -72,7 +72,7 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
final List<PositionedStack> ingredients = handler.getIngredientStacks(recipeIndex);
|
||||
final List<DistributedIngred> ingredStacks = getPermutationIngredients(ingredients);
|
||||
|
||||
if (!clearIngredients(gui)) return 0;
|
||||
if (!clearIngredients(gui, handler)) return 0;
|
||||
|
||||
findInventoryQuantities(gui, ingredStacks);
|
||||
|
||||
@@ -99,12 +99,17 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean craft(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, int multiplier) {
|
||||
final EntityClientPlayerMP thePlayer = NEIClientUtils.mc().thePlayer;
|
||||
boolean craft = false;
|
||||
public boolean craft(GuiContainer firstGui, IRecipeHandler handler, int recipeIndex, int multiplier) {
|
||||
final Slot craftingSlot = firstGui.inventorySlots.inventorySlots.stream()
|
||||
.filter(slot -> slot instanceof SlotCrafting).findFirst().orElse(null);
|
||||
|
||||
if (craftingSlot == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean craft = false;
|
||||
while (multiplier > 0) {
|
||||
final int transfer = transferRecipe(firstGui, recipe, recipeIndex, multiplier);
|
||||
final int transfer = transferRecipe(firstGui, handler, recipeIndex, multiplier);
|
||||
|
||||
if (transfer <= 0) {
|
||||
break;
|
||||
@@ -112,43 +117,88 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
|
||||
multiplier -= transfer;
|
||||
|
||||
for (Slot slot : firstGui.inventorySlots.inventorySlots) {
|
||||
if (slot.getHasStack() && slot instanceof SlotCrafting && slot.canTakeStack(thePlayer)) {
|
||||
FastTransferManager.clickSlot(firstGui, slot.slotNumber, 0, 1);
|
||||
craft = true;
|
||||
break;
|
||||
}
|
||||
if (craftingSlot.getHasStack() && craftingSlot.canTakeStack(firstGui.mc.thePlayer)) {
|
||||
FastTransferManager.clickSlot(firstGui, craftingSlot.slotNumber, 0, 1);
|
||||
craft = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
clearIngredients(firstGui);
|
||||
clearIngredients(firstGui, handler);
|
||||
|
||||
return craft;
|
||||
}
|
||||
|
||||
private boolean clearIngredients(GuiContainer gui) {
|
||||
final EntityClientPlayerMP thePlayer = NEIClientUtils.mc().thePlayer;
|
||||
protected boolean clearIngredients(GuiContainer gui, IRecipeHandler handler) {
|
||||
|
||||
for (Slot slot : gui.inventorySlots.inventorySlots) {
|
||||
if (slot.getHasStack() && !canMoveFrom(slot, gui)
|
||||
&& !(slot instanceof SlotCrafting)
|
||||
&& slot.canTakeStack(thePlayer)) {
|
||||
for (Slot slot : getCraftMatrixSlots(gui, handler)) {
|
||||
if (slot.canTakeStack(gui.mc.thePlayer)) {
|
||||
FastTransferManager.clickSlot(gui, slot.slotNumber, 0, 1);
|
||||
if (slot.getHasStack()) return false;
|
||||
}
|
||||
}
|
||||
|
||||
return dropOffMouseStack(thePlayer, gui);
|
||||
FastTransferManager.dropHeldItem(gui);
|
||||
|
||||
return gui.mc.thePlayer.inventory.getItemStack() == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the slots in the crafting matrix for the given GUI and recipe handler.
|
||||
*
|
||||
* @param gui
|
||||
* @param handler
|
||||
* @return
|
||||
*/
|
||||
protected Set<Slot> getCraftMatrixSlots(GuiContainer gui, IRecipeHandler handler) {
|
||||
final PositionedStack firstIngr = handler.getIngredientStacks(0).get(0);
|
||||
final Map<Integer, Slot> grid = new HashMap<>();
|
||||
final Set<Slot> ingredSlots = new HashSet<>();
|
||||
|
||||
for (Slot slot : gui.inventorySlots.inventorySlots) {
|
||||
final int key = (slot.xDisplayPosition - this.offsetx) * 10_000 + (slot.yDisplayPosition - this.offsety);
|
||||
grid.put(key, slot);
|
||||
}
|
||||
|
||||
int left = firstIngr.relx;
|
||||
int top = firstIngr.rely;
|
||||
int right = left;
|
||||
int bottom = top;
|
||||
|
||||
while (grid.containsKey((left - 18) * 10_000 + firstIngr.rely)) {
|
||||
left -= 18;
|
||||
}
|
||||
|
||||
while (grid.containsKey((right + 18) * 10_000 + firstIngr.rely)) {
|
||||
right += 18;
|
||||
}
|
||||
|
||||
while (grid.containsKey(firstIngr.relx * 10_000 + (top - 18))) {
|
||||
top -= 18;
|
||||
}
|
||||
|
||||
while (grid.containsKey(firstIngr.relx * 10_000 + (bottom + 18))) {
|
||||
bottom += 18;
|
||||
}
|
||||
|
||||
for (int x = left; x <= right; x += 18) {
|
||||
for (int y = top; y <= bottom; y += 18) {
|
||||
final Slot slot = grid.get(x * 10_000 + y);
|
||||
if (slot != null && !(slot.inventory instanceof InventoryPlayer)) {
|
||||
ingredSlots.add(slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ingredSlots;
|
||||
}
|
||||
|
||||
private void moveIngredients(GuiContainer gui, List<IngredientDistribution> assignedIngredients, int multiplier) {
|
||||
final EntityClientPlayerMP thePlayer = NEIClientUtils.mc().thePlayer;
|
||||
|
||||
for (Slot slot : gui.inventorySlots.inventorySlots) {
|
||||
if (slot instanceof SlotCrafting || !slot.getHasStack()
|
||||
|| !canMoveFrom(slot, gui)
|
||||
|| !slot.canTakeStack(thePlayer))
|
||||
|| !slot.canTakeStack(gui.mc.thePlayer))
|
||||
continue;
|
||||
ItemStack stack = slot.getStack();
|
||||
int slotTransferCap = stack.getMaxStackSize();
|
||||
@@ -186,7 +236,7 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
|
||||
}
|
||||
|
||||
if (thePlayer.inventory.getItemStack() != null) {
|
||||
if (gui.mc.thePlayer.inventory.getItemStack() != null) {
|
||||
FastTransferManager.clickSlot(gui, slot.slotNumber);
|
||||
}
|
||||
}
|
||||
@@ -194,33 +244,6 @@ public class DefaultOverlayHandler implements IOverlayHandler {
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean dropOffMouseStack(EntityPlayer entityPlayer, GuiContainer gui) {
|
||||
|
||||
if (entityPlayer.inventory.getItemStack() == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < gui.inventorySlots.inventorySlots.size(); i++) {
|
||||
Slot slot = gui.inventorySlots.inventorySlots.get(i);
|
||||
|
||||
if (slot.inventory == entityPlayer.inventory) {
|
||||
ItemStack mouseItem = entityPlayer.inventory.getItemStack();
|
||||
ItemStack slotStack = slot.getStack();
|
||||
|
||||
if (slotStack == null || NEIClientUtils.areStacksSameType(mouseItem, slotStack)) {
|
||||
FastTransferManager.clickSlot(gui, i, 0, 0);
|
||||
}
|
||||
|
||||
if (entityPlayer.inventory.getItemStack() == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return entityPlayer.inventory.getItemStack() == null;
|
||||
}
|
||||
|
||||
private int calculateRecipeQuantity(List<IngredientDistribution> assignedIngredients) {
|
||||
int quantity = Integer.MAX_VALUE;
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ 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;
|
||||
import codechicken.nei.recipe.stackinfo.GTFluidStackStringifyHandler;
|
||||
|
||||
public class GuiCraftingRecipe extends GuiRecipe<ICraftingHandler> {
|
||||
|
||||
@@ -36,10 +36,13 @@ public class GuiCraftingRecipe extends GuiRecipe<ICraftingHandler> {
|
||||
final Minecraft mc = NEIClientUtils.mc();
|
||||
final RecipeId recipeId;
|
||||
|
||||
if ("item".equals(outputId)) {
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
results[i] = normalizeItemStack((ItemStack) results[i]);
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
if (results[i] instanceof ItemStack stack) {
|
||||
results[i] = StackInfo.normalizeRecipeQueryStack(stack.copy());
|
||||
}
|
||||
}
|
||||
|
||||
if ("item".equals(outputId)) {
|
||||
recipeId = getRecipeId(mc.currentScreen, (ItemStack) results[0]);
|
||||
} else if ("recipeId".equals(outputId)) {
|
||||
recipeId = (RecipeId) results[1];
|
||||
@@ -105,13 +108,6 @@ public class GuiCraftingRecipe extends GuiRecipe<ICraftingHandler> {
|
||||
return GuiRecipeTab.getHandlerInfo(handler).getHandlerName();
|
||||
}
|
||||
|
||||
private static ItemStack normalizeItemStack(ItemStack stack) {
|
||||
GTFluidStackStringifyHandler.replaceAE2FCFluidDrop = true;
|
||||
stack = StackInfo.loadFromNBT(StackInfo.itemStackToNBT(stack));
|
||||
GTFluidStackStringifyHandler.replaceAE2FCFluidDrop = false;
|
||||
return stack;
|
||||
}
|
||||
|
||||
public static RecipeId getRecipeId(GuiScreen gui, ItemStack stackover) {
|
||||
|
||||
if (gui instanceof GuiRecipe guiRecipe) {
|
||||
@@ -126,7 +122,8 @@ public class GuiCraftingRecipe extends GuiRecipe<ICraftingHandler> {
|
||||
final BookmarksGridSlot panelSlot = ItemPanels.bookmarkPanel.getSlotMouseOver(mouseover.x, mouseover.y);
|
||||
|
||||
if (panelSlot != null) {
|
||||
return panelSlot.isIngredient() || panelSlot.getRecipeId() == null ? FavoriteRecipes.getFavorite(stackover)
|
||||
return panelSlot.getType() == BookmarkItemType.INGREDIENT || panelSlot.getRecipeId() == null
|
||||
? FavoriteRecipes.getFavorite(stackover)
|
||||
: panelSlot.getRecipeId();
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ public class GuiFavoriteButton extends GuiRecipeButton {
|
||||
}
|
||||
|
||||
public boolean isFavorite() {
|
||||
return favorite;
|
||||
return this.favorite;
|
||||
}
|
||||
|
||||
public void toggleFavorite() {
|
||||
@@ -86,6 +86,11 @@ public class GuiFavoriteButton extends GuiRecipeButton {
|
||||
.setFavorite(this.favoriteResult.getItemStack(), this.favorite ? this.recipe.getRecipeId() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
this.favorite = this.favorite && FavoriteRecipes.getFavorite(this.recipe.getRecipeId()) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawContent(Minecraft minecraft, int y, int x, boolean mouseOver) {
|
||||
final DrawableResource icon = isFavorite() ? ICON_STATE_ON : ICON_STATE_OFF;
|
||||
|
||||
@@ -313,8 +313,11 @@ public class GuiOverlayButton extends GuiRecipeButton {
|
||||
final Recipe recipe = getRecipe();
|
||||
|
||||
if (!ItemPanels.bookmarkPanel.removeRecipe(recipe.getRecipeId(), BookmarkGrid.DEFAULT_GROUP_ID)) {
|
||||
ItemPanels.bookmarkPanel
|
||||
.addRecipe(recipe, NEIClientUtils.controlKey() ? 1 : 0, BookmarkGrid.DEFAULT_GROUP_ID);
|
||||
ItemPanels.bookmarkPanel.addRecipe(
|
||||
recipe,
|
||||
NEIClientUtils.controlKey()
|
||||
|| NEIClientConfig.getBooleanSetting("inventory.bookmarks.bookmarkRecipeWithCount") ? 1 : 0,
|
||||
BookmarkGrid.DEFAULT_GROUP_ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,6 @@ import codechicken.nei.scroll.ScrollBar;
|
||||
import codechicken.nei.scroll.ScrollBar.OverflowType;
|
||||
import codechicken.nei.scroll.ScrollBar.ScrollPlace;
|
||||
import codechicken.nei.scroll.ScrollContainer;
|
||||
import codechicken.nei.util.NEIMouseUtils;
|
||||
import codechicken.nei.util.SlotInaccessible;
|
||||
|
||||
public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer implements IGuiContainerOverlay,
|
||||
@@ -65,16 +64,14 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
private static final int BUTTON_WIDTH = 13;
|
||||
private static final int BUTTON_HEIGHT = 12;
|
||||
|
||||
protected static final ScrollBar VERTICAL_SCROLLBAR = new ScrollBar().setScrollbarSize(14)
|
||||
.setOverflowType(OverflowType.AUTO).setScrollPlace(ScrollPlace.OUTSIDE)
|
||||
protected static final ScrollBar VERTICAL_SCROLLBAR = new ScrollBar().setTrackWidth(14)
|
||||
.setOverflowType(OverflowType.AUTO).setScrollPlace(ScrollPlace.END)
|
||||
.setTrackTexture(new DrawableBuilder("nei:textures/nei_sprites.png", 42, 90, 13, 21).build(), 9, 9)
|
||||
.setThumbTexture(new DrawableBuilder("nei:textures/nei_sprites.png", 21, 96, 8, 9).build(), 3, 2)
|
||||
.setThumbPadding(6);
|
||||
.setThumbTexture(new DrawableBuilder("nei:textures/nei_sprites.png", 22, 96, 6, 9).build(), 3, 2)
|
||||
.setThumbPadding(1, 6, 0, 6);
|
||||
|
||||
public static final List<IRecipeFilterProvider> recipeFilterers = new LinkedList<>();
|
||||
|
||||
protected AcceptsFollowingTooltipLineHandler acceptsFollowingTooltipLineHandler;
|
||||
|
||||
// some mods reflect this properties
|
||||
public ArrayList<H> currenthandlers = new ArrayList<>();
|
||||
public int page;
|
||||
@@ -89,12 +86,12 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
private GuiButton prevtype;
|
||||
private GuiButton nexttype;
|
||||
|
||||
protected String recipePageCacheKey = "";
|
||||
|
||||
private int lastPage = -1;
|
||||
private final GuiRecipeTabs recipeTabs;
|
||||
private final GuiRecipeCatalyst recipeCatalyst;
|
||||
private SearchRecipeHandler<H> handler;
|
||||
private HandlerInfo handlerInfo;
|
||||
private RecipePageManager handlerPages;
|
||||
|
||||
protected static final RestartableTask updateFilter = new RestartableTask("NEI Recipe Filtering") {
|
||||
|
||||
@@ -109,7 +106,6 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
|
||||
if (GuiRecipe.searchField.text().isEmpty()) {
|
||||
searchHandler.setSearchIndices(null);
|
||||
guiRecipe.changePage(0);
|
||||
} else {
|
||||
final IRecipeFilter filter = GuiRecipe.searchField.getRecipeFilter();
|
||||
final List<Integer> filtered = searchHandler.getSearchResult(filter);
|
||||
@@ -120,10 +116,8 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
|
||||
if (interrupted()) return;
|
||||
searchHandler.setSearchIndices(filtered);
|
||||
guiRecipe.changePage(0);
|
||||
}
|
||||
|
||||
guiRecipe.recipePageCacheKey = "";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -137,7 +131,8 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
@Override
|
||||
protected boolean noResults() {
|
||||
final GuiScreen currentScreen = NEIClientUtils.mc().currentScreen;
|
||||
return !(currentScreen instanceof GuiRecipe) || ((GuiRecipe<?>) currentScreen).numRecipes() > 0;
|
||||
return !(currentScreen instanceof GuiRecipe)
|
||||
|| ((GuiRecipe<?>) currentScreen).handlerPages.getNumRecipes() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -199,6 +194,36 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
this.firstGui = gui.getFirstScreen();
|
||||
this.firstGuiGeneral = gui.getFirstScreenGeneral();
|
||||
}
|
||||
|
||||
this.prevtype = new GuiNEIButton(0, 0, 0, BUTTON_WIDTH, BUTTON_HEIGHT, "<") {
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int mouseX, int mouseY) {
|
||||
prevType();
|
||||
}
|
||||
};
|
||||
this.nexttype = new GuiNEIButton(1, 0, 0, BUTTON_WIDTH, BUTTON_HEIGHT, ">") {
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int mouseX, int mouseY) {
|
||||
nextType();
|
||||
}
|
||||
};
|
||||
|
||||
this.prevpage = new GuiNEIButton(2, 0, 0, BUTTON_WIDTH, BUTTON_HEIGHT, "<") {
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int mouseX, int mouseY) {
|
||||
prevPage();
|
||||
}
|
||||
};
|
||||
this.nextpage = new GuiNEIButton(3, 0, 0, BUTTON_WIDTH, BUTTON_HEIGHT, ">") {
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int mouseX, int mouseY) {
|
||||
nextPage();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -272,7 +297,19 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
}
|
||||
}
|
||||
|
||||
private ScrollContainer container = new ScrollContainer();
|
||||
private ScrollContainer container = new ScrollContainer() {
|
||||
|
||||
@Override
|
||||
public Widget getWidgetUnderMouse(int mousex, int mousey) {
|
||||
|
||||
if (handlerInfo.getUseCustomScroll() && !this.widgets.isEmpty()) {
|
||||
return this.widgets.get(0);
|
||||
}
|
||||
|
||||
return super.getWidgetUnderMouse(mousex, mousey);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
@@ -292,35 +329,18 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
final int rightButtonX = this.guiLeft + this.xSize - BORDER_PADDING - BUTTON_WIDTH + 1;
|
||||
final int leftButtonX = this.guiLeft + BORDER_PADDING;
|
||||
|
||||
this.prevtype = new GuiNEIButton(0, leftButtonX, guiTop + 3, BUTTON_WIDTH, BUTTON_HEIGHT, "<") {
|
||||
this.prevtype.xPosition = leftButtonX;
|
||||
this.prevtype.yPosition = guiTop + 3;
|
||||
this.nexttype.xPosition = rightButtonX;
|
||||
this.nexttype.yPosition = guiTop + 3;
|
||||
this.prevpage.xPosition = leftButtonX;
|
||||
this.prevpage.yPosition = guiTop + 17;
|
||||
this.nextpage.xPosition = rightButtonX;
|
||||
this.nextpage.yPosition = guiTop + 17;
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int mouseX, int mouseY) {
|
||||
prevType();
|
||||
}
|
||||
};
|
||||
this.nexttype = new GuiNEIButton(1, rightButtonX, guiTop + 3, BUTTON_WIDTH, BUTTON_HEIGHT, ">") {
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int mouseX, int mouseY) {
|
||||
nextType();
|
||||
}
|
||||
};
|
||||
|
||||
this.prevpage = new GuiNEIButton(2, leftButtonX, guiTop + 17, BUTTON_WIDTH, BUTTON_HEIGHT, "<") {
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int mouseX, int mouseY) {
|
||||
prevPage();
|
||||
}
|
||||
};
|
||||
this.nextpage = new GuiNEIButton(3, rightButtonX, guiTop + 17, BUTTON_WIDTH, BUTTON_HEIGHT, ">") {
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int mouseX, int mouseY) {
|
||||
nextPage();
|
||||
}
|
||||
};
|
||||
this.container.x = this.guiLeft + 3;
|
||||
this.container.y = this.guiTop + 32;
|
||||
this.container.h = this.ySize - 32 - 5;
|
||||
|
||||
GuiRecipe.toggleSearch.icon = new DrawableBuilder("nei:textures/nei_sprites.png", 0, 76, 10, 10).build();
|
||||
GuiRecipe.toggleSearch.w = GuiRecipe.toggleSearch.h = 12;
|
||||
@@ -333,9 +353,8 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
GuiRecipe.searchField.h = 14;
|
||||
|
||||
this.buttonList.addAll(Arrays.asList(this.prevtype, this.nexttype, this.prevpage, this.nextpage));
|
||||
this.recipePageCacheKey = "";
|
||||
|
||||
if (currenthandlers.size() == 1) {
|
||||
if (this.currenthandlers.size() == 1) {
|
||||
this.prevtype.visible = false;
|
||||
this.nexttype.visible = false;
|
||||
}
|
||||
@@ -343,34 +362,11 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
this.recipeTabs.update(this);
|
||||
}
|
||||
|
||||
private void updateRecipePage() {
|
||||
final List<Integer> indices = getRecipeIndices();
|
||||
final String cacheKey = indices.isEmpty() ? "empty"
|
||||
: handlerInfo.getHandlerName() + ":" + indices.get(0) + ":" + indices.get(indices.size() - 1);
|
||||
protected void refreshContainer() {
|
||||
|
||||
if (!cacheKey.equals(this.recipePageCacheKey)) {
|
||||
this.recipePageCacheKey = cacheKey;
|
||||
|
||||
final boolean expandVertically = this.handlerInfo.expandVertically();
|
||||
final List<Widget> widgets = new ArrayList<>();
|
||||
int shiftY = 0;
|
||||
|
||||
for (int recipeIndex : indices) {
|
||||
final NEIRecipeWidget widget = RecipeHandlerRef.of(this.handler.original, recipeIndex)
|
||||
.getRecipeWidget();
|
||||
widget.setLocation(Math.max(0, (this.container.w - widget.w) / 2), shiftY);
|
||||
|
||||
if (expandVertically) {
|
||||
widget.h = Math.min(
|
||||
this.handlerInfo.getHeight() + this.handlerInfo.getYShift(),
|
||||
this.container.getVisibleHeight());
|
||||
}
|
||||
|
||||
widgets.add(widget);
|
||||
shiftY += widget.h;
|
||||
}
|
||||
|
||||
this.container.setWidgets(widgets);
|
||||
if (this.handlerPages.rebuildPages() || this.lastPage != this.handlerPages.getCurrentPageIndex()) {
|
||||
this.lastPage = this.handlerPages.getCurrentPageIndex();
|
||||
this.container.setWidgets(this.handlerPages.getCurrentPageWidgets());
|
||||
|
||||
if (this.handlerInfo.getUseCustomScroll()) {
|
||||
this.container.setVerticalScroll(null);
|
||||
@@ -379,10 +375,12 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
} else {
|
||||
this.container.setVerticalScroll(
|
||||
ScrollBar.defaultVerticalBar().setOverflowType(OverflowType.OVERLAY)
|
||||
.setScrollPlace(ScrollPlace.OUTSIDE));
|
||||
.setTrackPadding(-8, 0, 0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
this.recipeCatalyst.setCatalysts(RecipeCatalysts.getRecipeCatalysts(this.handler.original));
|
||||
this.container.update();
|
||||
}
|
||||
|
||||
public static IRecipeFilter getRecipeListFilter() {
|
||||
@@ -408,24 +406,20 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
return GuiRecipe.searchField.getFilter();
|
||||
}
|
||||
|
||||
public void setRecipePage(int idx) {
|
||||
setRecipePage(idx, 0);
|
||||
}
|
||||
|
||||
public void setRecipePage(int idx, int refIndex) {
|
||||
protected void setRecipePage(int idx) {
|
||||
this.recipetype = (this.currenthandlers.size() + idx) % this.currenthandlers.size();
|
||||
this.handler = new SearchRecipeHandler<>(this.currenthandlers.get(this.recipetype));
|
||||
this.handlerInfo = GuiRecipeTab.getHandlerInfo(this.handler.original);
|
||||
this.container.w = Math.max(this.xSize - 6, this.handlerInfo.getWidth());
|
||||
this.handlerPages = new RecipePageManager(this.handler, this.handlerInfo, this.container);
|
||||
this.prevpage.enabled = this.nextpage.enabled = this.handlerPages.getNumPages() > 1;
|
||||
this.lastPage = -1;
|
||||
|
||||
GuiRecipe.searchField.setText("");
|
||||
GuiRecipe.searchField.setVisible(false);
|
||||
GuiRecipe.toggleSearch.state = 0;
|
||||
|
||||
this.container.setVerticalScrollOffset(0);
|
||||
this.container.setHorizontalScrollOffset(0);
|
||||
this.page = Math.min(Math.max(0, refIndex), this.numRecipes() - 1) / getRecipesPerPage();
|
||||
changePage(0);
|
||||
|
||||
this.recipeTabs.update(this);
|
||||
}
|
||||
|
||||
@@ -455,7 +449,8 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
}
|
||||
}
|
||||
|
||||
setRecipePage(recipetype, Math.max(0, refIndex));
|
||||
setRecipePage(recipetype);
|
||||
this.handlerPages.gotoRefIndex(Math.max(0, refIndex));
|
||||
|
||||
return refIndex;
|
||||
}
|
||||
@@ -520,20 +515,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
}
|
||||
|
||||
public List<Integer> getRecipeIndices() {
|
||||
final int recipesPerPage = getRecipesPerPage();
|
||||
final int minIndex = this.page * recipesPerPage;
|
||||
final int maxIndex = Math.min(this.numRecipes(), (this.page + 1) * recipesPerPage);
|
||||
final List<Integer> range = new ArrayList<>();
|
||||
|
||||
for (int index = minIndex; index < maxIndex; index++) {
|
||||
range.add(this.handler.ref(index));
|
||||
}
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
private int numRecipes() {
|
||||
return this.handler == null ? 0 : this.handler.numRecipes();
|
||||
return this.handlerPages.getRecipeIndices();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -699,20 +681,13 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
public void updateScreen() {
|
||||
super.updateScreen();
|
||||
|
||||
this.container.x = this.guiLeft + 3;
|
||||
this.container.y = this.guiTop + 32;
|
||||
|
||||
this.container.w = Math.max(this.xSize - 6, this.handlerInfo.getWidth());
|
||||
this.container.h = this.ySize - 32 - 5;
|
||||
|
||||
this.handler.original.onUpdate();
|
||||
refreshPage();
|
||||
this.container.update();
|
||||
refreshContainer();
|
||||
|
||||
this.recipeCatalyst.setAvailableHeight(this.container.h);
|
||||
this.recipeCatalyst.update();
|
||||
this.recipeCatalyst.setAvailableHeight(this.ySize - 5);
|
||||
this.recipeCatalyst.y = this.guiTop;
|
||||
this.recipeCatalyst.x = this.guiLeft - this.recipeCatalyst.w + 6;
|
||||
this.recipeCatalyst.x = this.guiLeft - this.recipeCatalyst.w + 4;
|
||||
this.recipeCatalyst.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -733,7 +708,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
.contains(mousex - this.guiLeft, mousey - this.guiTop)) {
|
||||
|
||||
final String pageInfo = String
|
||||
.format("%d/%d", page + 1, Math.max(1, this.numRecipes() - 1) / getRecipesPerPage() + 1);
|
||||
.format("%d/%d", this.handlerPages.getCurrentPageIndex() + 1, this.handlerPages.getNumPages());
|
||||
|
||||
if (this.fontRendererObj.getStringWidth(pageInfo) >= 45) {
|
||||
currenttip.add(pageInfo);
|
||||
@@ -752,30 +727,6 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
currenttip = recipeWidget.handleItemTooltip(itemstack, mousex, mousey, currenttip);
|
||||
}
|
||||
|
||||
if (NEIClientConfig.showCycledIngredientsTooltip() && itemstack != null) {
|
||||
PositionedStack hovered = null;
|
||||
|
||||
if (activeWidget instanceof NEIRecipeWidget recipeWidget) {
|
||||
hovered = recipeWidget.getPositionedStackMouseOver(mousex, mousey);
|
||||
}
|
||||
|
||||
if (hovered == null || hovered.items.length <= 1) {
|
||||
this.acceptsFollowingTooltipLineHandler = null;
|
||||
} else if (this.acceptsFollowingTooltipLineHandler == null
|
||||
|| this.acceptsFollowingTooltipLineHandler.tooltipGUID != hovered) {
|
||||
this.acceptsFollowingTooltipLineHandler = AcceptsFollowingTooltipLineHandler
|
||||
.of(hovered, hovered.getFilteredPermutations(), hovered.item);
|
||||
}
|
||||
} else if (this.acceptsFollowingTooltipLineHandler != null) {
|
||||
this.acceptsFollowingTooltipLineHandler = null;
|
||||
}
|
||||
|
||||
if (this.acceptsFollowingTooltipLineHandler != null) {
|
||||
this.acceptsFollowingTooltipLineHandler
|
||||
.setActiveStack(((PositionedStack) this.acceptsFollowingTooltipLineHandler.tooltipGUID).item);
|
||||
currenttip.add(GuiDraw.TOOLTIP_HANDLER + GuiDraw.getTipLineId(this.acceptsFollowingTooltipLineHandler));
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@@ -790,23 +741,15 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
hotkeys = this.container.handleHotkeys(mousex, mousey, hotkeys);
|
||||
}
|
||||
|
||||
if (this.acceptsFollowingTooltipLineHandler != null) {
|
||||
hotkeys.put(
|
||||
NEIClientUtils.getKeyName(
|
||||
NEIClientUtils.SHIFT_HASH,
|
||||
NEIMouseUtils.MOUSE_BTN_NONE + NEIMouseUtils.MOUSE_SCROLL),
|
||||
NEIClientUtils.translate("recipe.accepts.scroll"));
|
||||
}
|
||||
|
||||
return hotkeys;
|
||||
}
|
||||
|
||||
private void nextPage() {
|
||||
changePage(1);
|
||||
this.handlerPages.changePage(1);
|
||||
}
|
||||
|
||||
private void prevPage() {
|
||||
changePage(-1);
|
||||
this.handlerPages.changePage(-1);
|
||||
}
|
||||
|
||||
protected void nextType() {
|
||||
@@ -817,53 +760,29 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
setRecipePage(--recipetype);
|
||||
}
|
||||
|
||||
protected void changePage(int shift) {
|
||||
final int recipesPerPage = getRecipesPerPage();
|
||||
final int numRecipes = this.numRecipes();
|
||||
final int oldPage = this.page;
|
||||
|
||||
if (numRecipes > 0) {
|
||||
final int numPages = (int) Math.ceil(numRecipes / (float) recipesPerPage);
|
||||
this.page = Math.min(Math.max(0, this.page), numPages);
|
||||
this.page = (numPages + this.page + shift) % numPages;
|
||||
} else {
|
||||
this.page = 0;
|
||||
}
|
||||
|
||||
if (this.page != oldPage) {
|
||||
this.container.setVerticalScrollOffset(0);
|
||||
this.container.setHorizontalScrollOffset(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public GuiRecipeCatalyst getRecipeCatalystWidget() {
|
||||
return this.recipeCatalyst;
|
||||
}
|
||||
|
||||
public void forceRefreshPage() {
|
||||
this.buttonList.removeIf(Arrays.asList(this.overlayButtons)::contains);
|
||||
this.overlayButtons = new GuiOverlayButton[0];
|
||||
protected void forceRefreshPage() {
|
||||
this.currenthandlers.sort(NEIClientConfig.HANDLER_COMPARATOR);
|
||||
this.recipePageCacheKey = "";
|
||||
refreshPage();
|
||||
}
|
||||
|
||||
public void refreshPage() {
|
||||
changePage(0);
|
||||
final int recipesPerPage = getRecipesPerPage();
|
||||
final boolean multiplepages = this.numRecipes() > recipesPerPage;
|
||||
final int currentPage = this.handlerPages.getCurrentPageIndex();
|
||||
setRecipePage(this.recipetype);
|
||||
this.handlerPages.changePage(currentPage);
|
||||
|
||||
this.prevpage.enabled = this.nextpage.enabled = multiplepages;
|
||||
this.recipeCatalyst.setCatalysts(RecipeCatalysts.getRecipeCatalysts(this.handler.original));
|
||||
|
||||
updateRecipePage();
|
||||
refreshContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
GL11.glTranslatef(-guiLeft, -guiTop, 0);
|
||||
this.container.draw(mouseX, mouseY);
|
||||
|
||||
if (NEIClientConfig.getJEIStyleRecipeCatalysts() != 0 && this.recipeCatalyst.isShowWidget()) {
|
||||
this.recipeCatalyst.draw(mouseX, mouseY);
|
||||
}
|
||||
|
||||
GL11.glTranslatef(guiLeft, guiTop, 0);
|
||||
}
|
||||
|
||||
@@ -883,7 +802,6 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
}
|
||||
|
||||
private void drawJEITabs(int mouseX, int mouseY) {
|
||||
final int recipesPerPage = getRecipesPerPage();
|
||||
final int textMiddle = (BUTTON_WIDTH - this.fontRendererObj.FONT_HEIGHT) / 2;
|
||||
|
||||
drawRect(
|
||||
@@ -917,7 +835,10 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
if (GuiRecipe.searchField.isVisible()) {
|
||||
final String recipePage = NEIClientUtils.cropText(
|
||||
this.fontRendererObj,
|
||||
String.format("%d/%d", this.page + 1, Math.max(0, numRecipes() - 1) / recipesPerPage + 1),
|
||||
String.format(
|
||||
"%d/%d",
|
||||
this.handlerPages.getCurrentPageIndex() + 1,
|
||||
this.handlerPages.getNumPages()),
|
||||
45);
|
||||
drawCenteredString(
|
||||
this.fontRendererObj,
|
||||
@@ -926,8 +847,10 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
this.prevpage.yPosition + textMiddle,
|
||||
0xffffff);
|
||||
} else {
|
||||
final String recipePage = NEIClientUtils
|
||||
.translate("recipe.page", this.page + 1, Math.max(0, numRecipes() - 1) / recipesPerPage + 1);
|
||||
final String recipePage = NEIClientUtils.translate(
|
||||
"recipe.page",
|
||||
this.handlerPages.getCurrentPageIndex() + 1,
|
||||
this.handlerPages.getNumPages());
|
||||
drawCenteredString(
|
||||
this.fontRendererObj,
|
||||
recipePage,
|
||||
@@ -940,11 +863,6 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f);
|
||||
this.recipeTabs.draw(mouseX, mouseY);
|
||||
|
||||
if (NEIClientConfig.areJEIStyleRecipeCatalystsVisible()) {
|
||||
this.recipeCatalyst.draw(mouseX, mouseY);
|
||||
}
|
||||
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
}
|
||||
}
|
||||
@@ -959,19 +877,6 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
return this.firstGuiGeneral;
|
||||
}
|
||||
|
||||
private int getRecipesPerPage() {
|
||||
|
||||
if (this.handlerInfo.getMaxRecipesPerPage() <= 1) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (NEIClientConfig.getBooleanSetting("inventory.guirecipe.infiniteScroll")) {
|
||||
return Math.max(1, this.handler.numRecipes());
|
||||
}
|
||||
|
||||
return Math.max(this.container.h / (this.handlerInfo.getHeight() + this.handlerInfo.getYShift()), 1);
|
||||
}
|
||||
|
||||
public Point getRecipePosition(int recipe) {
|
||||
return getRefIndexPosition(getRecipeIndices().indexOf(recipe));
|
||||
}
|
||||
@@ -1027,20 +932,16 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
final Rectangle4i rect = new Rectangle4i(x, y, w, h);
|
||||
// Because some of the handlers *cough avaritia* are oversized
|
||||
|
||||
if (this.recipeCatalyst.isShowWidget() && this.recipeCatalyst.bounds().intersects(rect)) {
|
||||
if (this.recipeCatalyst.isShowWidget() && this.recipeCatalyst.boundsOutside().intersects(rect)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (getRecipesPerPage() == 1 && !this.container.getWidgets().isEmpty()) {
|
||||
return this.container.getWidgets().get(0).bounds().intersects(rect);
|
||||
}
|
||||
|
||||
return this.container.boundsOutside().intersects(rect);
|
||||
}
|
||||
|
||||
protected static RecipeId getCurrentRecipeId(GuiScreen gui) {
|
||||
|
||||
if (gui instanceof GuiRecipe<?>gRecipe && gRecipe.handler.numRecipes() > 0) {
|
||||
if (gui instanceof GuiRecipe<?>gRecipe && gRecipe.handlerPages.getNumRecipes() > 0) {
|
||||
final List<Integer> indices = gRecipe.getRecipeIndices();
|
||||
final int curRecipe = indices.isEmpty() ? 0 : indices.get(0);
|
||||
final Recipe recipe = Recipe.of(gRecipe.handler.original, curRecipe);
|
||||
|
||||
@@ -61,6 +61,10 @@ public abstract class GuiRecipeButton extends GuiNEIButton {
|
||||
|
||||
public abstract void drawItemOverlay();
|
||||
|
||||
public void update() {
|
||||
|
||||
}
|
||||
|
||||
public boolean mouseScrolled(int scroll) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3,13 +3,10 @@ package codechicken.nei.recipe;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
@@ -18,8 +15,37 @@ import codechicken.nei.api.ShortcutInputHandler;
|
||||
import codechicken.nei.drawable.DrawableBuilder;
|
||||
import codechicken.nei.drawable.DrawableResource;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.scroll.ScrollBar;
|
||||
import codechicken.nei.scroll.ScrollContainer;
|
||||
|
||||
public class GuiRecipeCatalyst extends Widget {
|
||||
public class GuiRecipeCatalyst extends ScrollContainer {
|
||||
|
||||
protected static class ItemStackWidget extends Widget {
|
||||
|
||||
private final PositionedStack pStack;
|
||||
|
||||
public ItemStackWidget(PositionedStack pStack) {
|
||||
this.pStack = pStack;
|
||||
this.x = pStack.relx;
|
||||
this.y = pStack.rely;
|
||||
this.w = SLOT_SIZE;
|
||||
this.h = SLOT_SIZE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int mx, int my) {
|
||||
GuiContainerManager.drawItem(this.x, this.y, this.pStack.item);
|
||||
|
||||
if (contains(mx, my)) {
|
||||
NEIClientUtils.gl2DRenderContext(() -> GuiDraw.drawRect(this.x, this.y, this.w, this.h, 0x80FFFFFF));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleClick(int mx, int my, int button) {
|
||||
return ShortcutInputHandler.handleMouseClick(this.pStack.item);
|
||||
}
|
||||
}
|
||||
|
||||
private static final int SLOT_SIZE = 16;
|
||||
private static final int BORDER_PADDING = 6;
|
||||
@@ -33,17 +59,28 @@ public class GuiRecipeCatalyst extends Widget {
|
||||
private static final DrawableResource FG_TEXTURE = new DrawableBuilder("nei:textures/slot.png", 0, 0, 18, 18)
|
||||
.setTextureSize(18, 18).build();
|
||||
|
||||
private final List<PositionedStack> items = new ArrayList<>();
|
||||
private int availableHeight = 0;
|
||||
private static final ScrollBar VERTICAL_SCROLLBAR = ScrollBar.defaultVerticalBar()
|
||||
.setOverflowType(ScrollBar.OverflowType.AUTO).setTrackPadding(0, BORDER_PADDING, -13, BORDER_PADDING)
|
||||
.setScrollPlace(ScrollBar.ScrollPlace.START);
|
||||
|
||||
private PositionedStack[] items = new PositionedStack[0];
|
||||
private boolean showWidget = false;
|
||||
private int availableHeight = 0;
|
||||
|
||||
public GuiRecipeCatalyst() {
|
||||
setPaddingBlock(BORDER_PADDING + 1, BORDER_PADDING + 1);
|
||||
}
|
||||
|
||||
public void setCatalysts(List<PositionedStack> items) {
|
||||
this.items.clear();
|
||||
this.items.addAll(items);
|
||||
this.items = items.toArray(new PositionedStack[0]);
|
||||
createWidgets();
|
||||
}
|
||||
|
||||
public void setAvailableHeight(int height) {
|
||||
this.availableHeight = height;
|
||||
if (this.availableHeight != height) {
|
||||
this.availableHeight = height;
|
||||
createWidgets();
|
||||
}
|
||||
}
|
||||
|
||||
public int getAvailableHeight() {
|
||||
@@ -55,106 +92,87 @@ public class GuiRecipeCatalyst extends Widget {
|
||||
}
|
||||
|
||||
public int getColumnCount() {
|
||||
final int maxItemsPerColumn = Math.max(0, this.availableHeight - 2 - BORDER_PADDING * 2) / SLOT_SIZE;
|
||||
return maxItemsPerColumn > 0 ? NEIServerUtils.divideCeil(this.items.size(), maxItemsPerColumn) : 0;
|
||||
if (NEIClientConfig.getJEIStyleRecipeCatalysts() == 1) {
|
||||
final int maxItemsPerColumn = Math.max(0, this.availableHeight - 2 - BORDER_PADDING * 2) / SLOT_SIZE;
|
||||
return maxItemsPerColumn > 0 ? NEIServerUtils.divideCeil(this.items.length, maxItemsPerColumn) : 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int getRowCount() {
|
||||
final int columnCount = getColumnCount();
|
||||
return columnCount > 0 ? NEIServerUtils.divideCeil(this.items.size(), columnCount) : 0;
|
||||
return columnCount > 0 ? NEIServerUtils.divideCeil(this.items.length, columnCount) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
protected void createWidgets() {
|
||||
final int columns = getColumnCount();
|
||||
final int rows = getRowCount();
|
||||
|
||||
setVerticalScroll(null);
|
||||
setPaddingInline(BORDER_PADDING + 1, BORDER_PADDING - 3);
|
||||
|
||||
this.h = rows * SLOT_SIZE + this.paddingBlockStart + this.paddingBlockEnd;
|
||||
this.w = columns * SLOT_SIZE + this.paddingInlineStart + this.paddingInlineEnd;
|
||||
|
||||
if (NEIClientConfig.getJEIStyleRecipeCatalysts() == 2
|
||||
&& rows * SLOT_SIZE + this.paddingBlockStart + this.paddingBlockEnd > this.availableHeight) {
|
||||
this.h = Math.min(this.h, this.availableHeight);
|
||||
this.w += VERTICAL_SCROLLBAR.getTrackWidth();
|
||||
|
||||
setVerticalScroll(VERTICAL_SCROLLBAR);
|
||||
setPaddingInline(BORDER_PADDING + 1 + VERTICAL_SCROLLBAR.getTrackWidth(), this.paddingInlineEnd);
|
||||
}
|
||||
|
||||
this.showWidget = rows * columns > 0;
|
||||
this.w = columns * SLOT_SIZE + 2 + BORDER_PADDING * 2;
|
||||
this.h = rows * SLOT_SIZE + 2 + BORDER_PADDING * 2;
|
||||
|
||||
if (rows == 0 || columns == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int visibleWidth = getVisibleWidth();
|
||||
final List<Widget> widgets = new ArrayList<>();
|
||||
int index = 0;
|
||||
|
||||
for (PositionedStack pStack : this.items) {
|
||||
|
||||
if (pStack.items.length > 1) {
|
||||
final int stackIndex = (pStack.items.length + pStack.getPermutationIndex(pStack.item) + 1)
|
||||
% pStack.items.length;
|
||||
pStack.setPermutationToRender(stackIndex);
|
||||
}
|
||||
|
||||
pStack.relx = this.w - BORDER_PADDING - 1 - SLOT_SIZE - (index / rows) * SLOT_SIZE;
|
||||
pStack.rely = BORDER_PADDING + 1 + (index % rows) * SLOT_SIZE;
|
||||
pStack.relx = visibleWidth - SLOT_SIZE - (index / rows) * SLOT_SIZE;
|
||||
pStack.rely = (index % rows) * SLOT_SIZE;
|
||||
index++;
|
||||
|
||||
widgets.add(new ItemStackWidget(pStack));
|
||||
}
|
||||
|
||||
setWidgets(widgets);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int mx, int my) {
|
||||
if (!this.showWidget) return;
|
||||
|
||||
GL11.glTranslatef(this.x, this.y, 0);
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
|
||||
BG_TEXTURE.draw(0, 0, this.w, this.h, BORDER_PADDING, BORDER_PADDING, BORDER_PADDING, BORDER_PADDING);
|
||||
BG_TEXTURE.draw(this.x, this.y, this.w, this.h, BORDER_PADDING, BORDER_PADDING, BORDER_PADDING, BORDER_PADDING);
|
||||
FG_TEXTURE.draw(
|
||||
BORDER_PADDING,
|
||||
BORDER_PADDING,
|
||||
this.w - BORDER_PADDING * 2,
|
||||
this.h - BORDER_PADDING * 2,
|
||||
this.x + this.paddingInlineStart - 1,
|
||||
this.y + this.paddingBlockStart - 1,
|
||||
this.w - this.paddingInlineStart - this.paddingInlineEnd + 2,
|
||||
this.h - this.paddingBlockStart - this.paddingBlockEnd + 2,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1);
|
||||
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_LIGHTING_BIT);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
|
||||
for (PositionedStack pStack : this.items) {
|
||||
GuiContainerManager.drawItem(pStack.relx, pStack.rely, pStack.item);
|
||||
|
||||
if (pStack.contains(mx - this.x, my - this.y)) {
|
||||
NEIClientUtils.gl2DRenderContext(
|
||||
() -> GuiDraw.drawRect(pStack.relx, pStack.rely, SLOT_SIZE, SLOT_SIZE, -2130706433));
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glPopAttrib();
|
||||
GL11.glTranslatef(-this.x, -this.y, 0);
|
||||
super.draw(mx, my);
|
||||
}
|
||||
|
||||
public PositionedStack getPositionedStackMouseOver(int mx, int my) {
|
||||
final Widget widget = getWidgetUnderMouse(mx, my);
|
||||
|
||||
for (PositionedStack pStack : this.items) {
|
||||
if (pStack.contains(mx - this.x, my - this.y)) {
|
||||
return pStack;
|
||||
}
|
||||
if (widget instanceof ItemStackWidget stackWidget) {
|
||||
return stackWidget.pStack;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackMouseOver(int mx, int my) {
|
||||
final PositionedStack pStack = getPositionedStackMouseOver(mx, my);
|
||||
|
||||
if (pStack != null) {
|
||||
return pStack.item;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleClick(int mx, int my, int button) {
|
||||
return ShortcutInputHandler.handleMouseClick(getStackMouseOver(mx, my));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static final int ingredientSize = 16;
|
||||
@Deprecated
|
||||
|
||||
@@ -255,12 +255,10 @@ public abstract class GuiRecipeTab extends Widget {
|
||||
if (yShift != null && !yShift.equals("")) info.setYShift(Integer.parseInt(yShift));
|
||||
|
||||
try {
|
||||
final int imageHeight = intOrDefault(record.get("handlerHeight"), HandlerInfo.DEFAULT_HEIGHT);
|
||||
final int imageWidth = intOrDefault(record.get("handlerWidth"), HandlerInfo.DEFAULT_WIDTH);
|
||||
final int maxRecipesPerPage = intOrDefault(
|
||||
record.get("maxRecipesPerPage"),
|
||||
HandlerInfo.DEFAULT_MAX_PER_PAGE);
|
||||
info.setHandlerDimensions(imageHeight, imageWidth, maxRecipesPerPage);
|
||||
final int handlerHeight = intOrDefault(record.get("handlerHeight"), HandlerInfo.DEFAULT_HEIGHT);
|
||||
final int handlerWidth = intOrDefault(record.get("handlerWidth"), HandlerInfo.DEFAULT_WIDTH);
|
||||
final boolean multipleWidgetsAllowed = intOrDefault(record.get("maxRecipesPerPage"), 1) > 1;
|
||||
info.setHandlerDimensions(handlerWidth, handlerHeight, multipleWidgetsAllowed);
|
||||
} catch (NumberFormatException ignored) {
|
||||
NEIClientConfig.logger.info("Error setting handler dimensions for " + handler);
|
||||
}
|
||||
@@ -298,10 +296,7 @@ public abstract class GuiRecipeTab extends Widget {
|
||||
|
||||
private static HandlerInfo getDefaultHandlerInfo() {
|
||||
final HandlerInfo info = new HandlerInfo("Unknown", "Unknown", "Unknown", false, "");
|
||||
info.setHandlerDimensions(
|
||||
HandlerInfo.DEFAULT_HEIGHT,
|
||||
HandlerInfo.DEFAULT_WIDTH,
|
||||
HandlerInfo.DEFAULT_MAX_PER_PAGE);
|
||||
info.setHandlerDimensions(HandlerInfo.DEFAULT_WIDTH, HandlerInfo.DEFAULT_HEIGHT, false);
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import codechicken.nei.ItemPanels;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.recipe.Recipe.RecipeId;
|
||||
import codechicken.nei.recipe.stackinfo.GTFluidStackStringifyHandler;
|
||||
|
||||
public class GuiUsageRecipe extends GuiRecipe<IUsageHandler> {
|
||||
|
||||
@@ -22,9 +21,9 @@ public class GuiUsageRecipe extends GuiRecipe<IUsageHandler> {
|
||||
|
||||
public static boolean openRecipeGui(String inputId, Object... ingredients) {
|
||||
|
||||
if ("item".equals(inputId)) {
|
||||
for (int i = 0; i < ingredients.length; i++) {
|
||||
ingredients[i] = normalizeItemStack((ItemStack) ingredients[i]);
|
||||
for (int i = 0; i < ingredients.length; i++) {
|
||||
if (ingredients[i] instanceof ItemStack stack) {
|
||||
ingredients[i] = StackInfo.normalizeRecipeQueryStack(stack.copy());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,13 +65,6 @@ public class GuiUsageRecipe extends GuiRecipe<IUsageHandler> {
|
||||
return recipeQuery.runWithProfiling(NEIClientUtils.translate("recipe.concurrent.usage"));
|
||||
}
|
||||
|
||||
private static ItemStack normalizeItemStack(ItemStack stack) {
|
||||
GTFluidStackStringifyHandler.replaceAE2FCFluidDrop = true;
|
||||
stack = StackInfo.loadFromNBT(StackInfo.itemStackToNBT(stack));
|
||||
GTFluidStackStringifyHandler.replaceAE2FCFluidDrop = false;
|
||||
return stack;
|
||||
}
|
||||
|
||||
public static void registerUsageHandler(IUsageHandler handler) {
|
||||
final String handlerId = handler.getHandlerId();
|
||||
|
||||
@@ -99,7 +91,7 @@ public class GuiUsageRecipe extends GuiRecipe<IUsageHandler> {
|
||||
private static IUsageHandler getUsageOrCatalystHandler(IUsageHandler handler, String inputId,
|
||||
Object... ingredients) {
|
||||
boolean skipCatalyst = NEIClientUtils.controlKey();
|
||||
if (NEIClientConfig.areJEIStyleRecipeCatalystsVisible() && !skipCatalyst) {
|
||||
if (NEIClientConfig.getJEIStyleRecipeCatalysts() != 0 && !skipCatalyst) {
|
||||
return handler.getUsageAndCatalystHandler(inputId, ingredients);
|
||||
} else {
|
||||
return handler.getUsageHandler(inputId, ingredients);
|
||||
|
||||
@@ -12,6 +12,8 @@ public class HandlerInfo {
|
||||
|
||||
public static int DEFAULT_HEIGHT = 65;
|
||||
public static int DEFAULT_WIDTH = 166;
|
||||
|
||||
@Deprecated
|
||||
public static int DEFAULT_MAX_PER_PAGE = 1;
|
||||
|
||||
private String handlerName;
|
||||
@@ -24,7 +26,8 @@ public class HandlerInfo {
|
||||
private int yShift = 0;
|
||||
private int height = DEFAULT_HEIGHT;
|
||||
private int width = DEFAULT_WIDTH;
|
||||
private int maxRecipesPerPage = DEFAULT_MAX_PER_PAGE;
|
||||
|
||||
private boolean multipleWidgetsAllowed = false;
|
||||
private boolean showFavoritesButton = true;
|
||||
private boolean showOverlayButton = true;
|
||||
private boolean useCustomScroll = false;
|
||||
@@ -40,10 +43,15 @@ public class HandlerInfo {
|
||||
this.excludedModId = excludedModId;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setHandlerDimensions(int height, int width, int maxRecipesPerPage) {
|
||||
setHandlerDimensions(width, height, maxRecipesPerPage > 1);
|
||||
}
|
||||
|
||||
public void setHandlerDimensions(int width, int height, boolean multipleWidgetsAllowed) {
|
||||
this.height = height;
|
||||
this.width = width;
|
||||
this.maxRecipesPerPage = maxRecipesPerPage;
|
||||
this.multipleWidgetsAllowed = multipleWidgetsAllowed;
|
||||
}
|
||||
|
||||
public boolean setItem(String itemId, String nbtString) {
|
||||
@@ -89,8 +97,13 @@ public class HandlerInfo {
|
||||
return this.width;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getMaxRecipesPerPage() {
|
||||
return Math.max(this.maxRecipesPerPage, 1);
|
||||
return this.multipleWidgetsAllowed ? Integer.MAX_VALUE : 1;
|
||||
}
|
||||
|
||||
public boolean isMultipleWidgetsAllowed() {
|
||||
return this.multipleWidgetsAllowed;
|
||||
}
|
||||
|
||||
public int getYShift() {
|
||||
@@ -133,10 +146,6 @@ public class HandlerInfo {
|
||||
this.useCustomScroll = useCustomScroll;
|
||||
}
|
||||
|
||||
public boolean expandVertically() {
|
||||
return this.useCustomScroll && this.maxRecipesPerPage <= 1;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private final HandlerInfo info;
|
||||
@@ -150,52 +159,72 @@ public class HandlerInfo {
|
||||
this(handlerClazz.getName(), modName, modId);
|
||||
}
|
||||
|
||||
public Builder setDisplayStack(String itemId, String nbtString) {
|
||||
return setDisplayStack(NEIServerUtils.getModdedItem(itemId, nbtString));
|
||||
}
|
||||
|
||||
public Builder setDisplayStack(ItemStack stack) {
|
||||
info.image = null;
|
||||
info.itemStack = stack;
|
||||
this.info.image = null;
|
||||
this.info.itemStack = stack;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setDisplayImage(DrawableResource drawable) {
|
||||
info.itemStack = null;
|
||||
info.image = drawable;
|
||||
this.info.itemStack = null;
|
||||
this.info.image = drawable;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setDisplayImage(ResourceLocation location, int imageX, int imageY, int imageWidth,
|
||||
int imageHeight) {
|
||||
info.itemStack = null;
|
||||
info.setImage(location.toString(), imageX, imageY, imageWidth, imageHeight);
|
||||
this.info.itemStack = null;
|
||||
this.info.setImage(location.toString(), imageX, imageY, imageWidth, imageHeight);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setUseCustomScroll(boolean useCustomScroll) {
|
||||
info.setUseCustomScroll(useCustomScroll);
|
||||
this.info.setUseCustomScroll(useCustomScroll);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setShiftY(int shiftY) {
|
||||
info.setYShift(shiftY);
|
||||
this.info.setYShift(shiftY);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setWidth(int width) {
|
||||
info.setHandlerDimensions(info.height, width, info.maxRecipesPerPage);
|
||||
this.info.width = width;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setHeight(int height) {
|
||||
info.setHandlerDimensions(height, info.width, info.maxRecipesPerPage);
|
||||
this.info.height = height;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setShowOverlayButton(boolean showOverlayButton) {
|
||||
this.info.showOverlayButton = showOverlayButton;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setShowFavoritesButton(boolean showFavoritesButton) {
|
||||
this.info.showFavoritesButton = showFavoritesButton;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Builder setMaxRecipesPerPage(int maxRecipesPerPage) {
|
||||
info.setHandlerDimensions(info.height, info.width, maxRecipesPerPage);
|
||||
this.info.multipleWidgetsAllowed = maxRecipesPerPage > 1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setMultipleWidgetsAllowed(boolean multipleWidgetsAllowed) {
|
||||
this.info.multipleWidgetsAllowed = multipleWidgetsAllowed;
|
||||
return this;
|
||||
}
|
||||
|
||||
public HandlerInfo build() {
|
||||
return info;
|
||||
return this.info;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,13 +34,12 @@ public class InformationHandler extends TemplateRecipeHandler {
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipe) {
|
||||
CachedInfoPage page = (CachedInfoPage) this.arecipes.get(recipe);
|
||||
drawWrappedText(StatCollector.translateToLocal(page.getPage().info).replace("\\n", "\n"), 4, 24);
|
||||
final CachedInfoPage page = (CachedInfoPage) this.arecipes.get(recipe);
|
||||
drawWrappedText(page.getLines(), 4, 24);
|
||||
}
|
||||
|
||||
private void drawWrappedText(String text, int x, int y) {
|
||||
FontRenderer font = Minecraft.getMinecraft().fontRenderer;
|
||||
List<String> lines = font.listFormattedStringToWidth(text, 156);
|
||||
private void drawWrappedText(List<String> lines, int x, int y) {
|
||||
final FontRenderer font = Minecraft.getMinecraft().fontRenderer;
|
||||
for (String line : lines) {
|
||||
font.drawString(line, x, y, 0);
|
||||
y += 10;
|
||||
@@ -82,14 +81,23 @@ public class InformationHandler extends TemplateRecipeHandler {
|
||||
return "nei:textures/gui/recipebg.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeHeight(int recipe) {
|
||||
final CachedInfoPage page = (CachedInfoPage) this.arecipes.get(recipe);
|
||||
return 24 + page.getLines().size() * 10;
|
||||
}
|
||||
|
||||
private class CachedInfoPage extends CachedRecipe {
|
||||
|
||||
private final InformationPage page;
|
||||
private final PositionedStack stack;
|
||||
private final List<String> lines;
|
||||
|
||||
public CachedInfoPage(InformationPage page) {
|
||||
this.page = page;
|
||||
stack = new PositionedStack(page.items, 75, 2);
|
||||
final FontRenderer font = Minecraft.getMinecraft().fontRenderer;
|
||||
final String info = StatCollector.translateToLocal(page.info).replace("\\n", "\n");
|
||||
|
||||
this.lines = font.listFormattedStringToWidth(info, 156);
|
||||
this.stack = new PositionedStack(page.items, 75, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -102,8 +110,8 @@ public class InformationHandler extends TemplateRecipeHandler {
|
||||
return Collections.singletonList(this.stack);
|
||||
}
|
||||
|
||||
public InformationPage getPage() {
|
||||
return page;
|
||||
public List<String> getLines() {
|
||||
return lines;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package codechicken.nei.recipe;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -23,19 +24,22 @@ import codechicken.nei.FavoriteRecipes;
|
||||
import codechicken.nei.LayoutManager;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.Widget;
|
||||
import codechicken.nei.api.IGuiContainerOverlay;
|
||||
import codechicken.nei.api.ShortcutInputHandler;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.recipe.GuiRecipeButton.UpdateRecipeButtonsEvent;
|
||||
import codechicken.nei.util.NEIMouseUtils;
|
||||
|
||||
public class NEIRecipeWidget extends Widget {
|
||||
|
||||
protected AcceptsFollowingTooltipLineHandler acceptsFollowingTooltipLineHandler;
|
||||
protected final WeakHashMap<PositionedStack, List<ItemStack>> permutations = new WeakHashMap<>();
|
||||
protected boolean needUpdate = true;
|
||||
protected boolean update = true;
|
||||
protected int cycleticks = 0;
|
||||
protected int lastcycle = 0;
|
||||
protected int lastcycle = -1;
|
||||
|
||||
protected final RecipeHandlerRef handlerRef;
|
||||
protected final HandlerInfo handlerInfo;
|
||||
@@ -55,25 +59,21 @@ public class NEIRecipeWidget extends Widget {
|
||||
}
|
||||
|
||||
public void update() {
|
||||
this.w = Math.max(166, this.handlerInfo.getWidth());
|
||||
|
||||
if (this.showAsWidget || !this.handlerInfo.expandVertically()) {
|
||||
if (this.showAsWidget || !this.handlerInfo.getUseCustomScroll()) {
|
||||
final int recipeHeight = this.handlerRef.handler.getRecipeHeight(this.handlerRef.recipeIndex);
|
||||
this.w = Math.max(166, this.handlerInfo.getWidth());
|
||||
this.h = recipeHeight > 0 ? recipeHeight : this.handlerInfo.getHeight();
|
||||
this.h += this.handlerInfo.getYShift();
|
||||
}
|
||||
|
||||
if (!this.needUpdate && !NEIClientUtils.shiftKey() && (this.cycleticks++) / 20 != this.lastcycle) {
|
||||
this.lastcycle = this.cycleticks / 20;
|
||||
this.needUpdate = true;
|
||||
}
|
||||
this.update = true;
|
||||
}
|
||||
|
||||
public List<GuiRecipeButton> getRecipeButtons() {
|
||||
|
||||
if (this.recipeButtons == null) {
|
||||
if (this.handlerRef.handler.getResultStack(this.handlerRef.recipeIndex) != null
|
||||
|| !this.handlerRef.handler.getOtherStacks(this.handlerRef.recipeIndex).isEmpty()) {
|
||||
if (!getOutputs().isEmpty()) {
|
||||
this.recipeButtons = initButtons();
|
||||
} else {
|
||||
this.recipeButtons = Collections.emptyList();
|
||||
@@ -162,9 +162,17 @@ public class NEIRecipeWidget extends Widget {
|
||||
public void draw(int mouseX, int mouseY) {
|
||||
final int yShift = this.handlerInfo.getYShift();
|
||||
|
||||
if (this.needUpdate) {
|
||||
this.needUpdate = false;
|
||||
updatePermutations();
|
||||
if (this.update) {
|
||||
this.update = false;
|
||||
|
||||
if (!NEIClientUtils.shiftKey() && (this.cycleticks++) / 20 != this.lastcycle || this.lastcycle == -1) {
|
||||
this.lastcycle = this.cycleticks / 20;
|
||||
updatePermutations();
|
||||
}
|
||||
|
||||
for (GuiRecipeButton button : getRecipeButtons()) {
|
||||
button.update();
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_LIGHTING_BIT);
|
||||
@@ -178,28 +186,27 @@ public class NEIRecipeWidget extends Widget {
|
||||
|
||||
GuiContainerManager.enableMatrixStackLogging();
|
||||
|
||||
for (PositionedStack pStack : this.handlerRef.handler.getIngredientStacks(this.handlerRef.recipeIndex)) {
|
||||
for (PositionedStack pStack : getInputs()) {
|
||||
GuiContainerManager.drawItem(pStack.relx, pStack.rely, pStack.item);
|
||||
|
||||
if (pStack.contains(mouseX - this.x, mouseY - this.y - yShift)) {
|
||||
NEIClientUtils.gl2DRenderContext(() -> GuiDraw.drawRect(pStack.relx, pStack.rely, 16, 16, -2130706433));
|
||||
NEIClientUtils.gl2DRenderContext(() -> GuiDraw.drawRect(pStack.relx, pStack.rely, 16, 16, 0x80FFFFFF));
|
||||
}
|
||||
}
|
||||
|
||||
for (PositionedStack pStack : this.handlerRef.handler.getOtherStacks(this.handlerRef.recipeIndex)) {
|
||||
for (PositionedStack pStack : getCatalysts()) {
|
||||
GuiContainerManager.drawItem(pStack.relx, pStack.rely, pStack.item);
|
||||
|
||||
if (pStack.contains(mouseX - this.x, mouseY - this.y - yShift)) {
|
||||
NEIClientUtils.gl2DRenderContext(() -> GuiDraw.drawRect(pStack.relx, pStack.rely, 16, 16, -2130706433));
|
||||
NEIClientUtils.gl2DRenderContext(() -> GuiDraw.drawRect(pStack.relx, pStack.rely, 16, 16, 0x80FFFFFF));
|
||||
}
|
||||
}
|
||||
|
||||
final PositionedStack pStackResult = this.handlerRef.handler.getResultStack(this.handlerRef.recipeIndex);
|
||||
if (pStackResult != null) {
|
||||
GuiContainerManager.drawItem(pStackResult.relx, pStackResult.rely, pStackResult.item);
|
||||
if (pStackResult.contains(mouseX - this.x, mouseY - this.y - yShift)) {
|
||||
NEIClientUtils.gl2DRenderContext(
|
||||
() -> GuiDraw.drawRect(pStackResult.relx, pStackResult.rely, 16, 16, -2130706433));
|
||||
for (PositionedStack pStack : getOutputs()) {
|
||||
GuiContainerManager.drawItem(pStack.relx, pStack.rely, pStack.item);
|
||||
|
||||
if (pStack.contains(mouseX - this.x, mouseY - this.y - yShift)) {
|
||||
NEIClientUtils.gl2DRenderContext(() -> GuiDraw.drawRect(pStack.relx, pStack.rely, 16, 16, 0x80FFFFFF));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,14 +318,60 @@ public class NEIRecipeWidget extends Widget {
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
return this.handlerRef.handler.handleItemTooltip(guiRecipe, itemstack, tooltip, this.handlerRef.recipeIndex);
|
||||
tooltip = this.handlerRef.handler.handleItemTooltip(guiRecipe, itemstack, tooltip, this.handlerRef.recipeIndex);
|
||||
|
||||
if (NEIClientConfig.showCycledIngredientsTooltip() && itemstack != null) {
|
||||
final int yShift = this.handlerInfo.getYShift();
|
||||
PositionedStack hovered = null;
|
||||
|
||||
for (PositionedStack pStack : getInputs()) {
|
||||
if (pStack.contains(mousex - this.x, mousey - this.y - yShift)) {
|
||||
hovered = pStack;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hovered == null) {
|
||||
for (PositionedStack pStack : getCatalysts()) {
|
||||
if (pStack.contains(mousex - this.x, mousey - this.y - yShift)) {
|
||||
hovered = pStack;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hovered == null || hovered.items.length <= 1) {
|
||||
this.acceptsFollowingTooltipLineHandler = null;
|
||||
} else if (this.acceptsFollowingTooltipLineHandler == null
|
||||
|| this.acceptsFollowingTooltipLineHandler.tooltipGUID != hovered) {
|
||||
this.acceptsFollowingTooltipLineHandler = AcceptsFollowingTooltipLineHandler
|
||||
.of(hovered, hovered.getFilteredPermutations(), hovered.item);
|
||||
}
|
||||
} else if (this.acceptsFollowingTooltipLineHandler != null) {
|
||||
this.acceptsFollowingTooltipLineHandler = null;
|
||||
}
|
||||
|
||||
if (this.acceptsFollowingTooltipLineHandler != null) {
|
||||
tooltip.add(GuiDraw.TOOLTIP_HANDLER + GuiDraw.getTipLineId(this.acceptsFollowingTooltipLineHandler));
|
||||
}
|
||||
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> handleHotkeys(int mouseX, int mouseY, Map<String, String> hotkeys) {
|
||||
return forEachButtons(
|
||||
final Map<String, String> buttonHotkeys = forEachButtons(
|
||||
button -> button.contains(mouseX, mouseY) ? button.handleHotkeys(mouseX, mouseY, hotkeys) : null,
|
||||
hotkeys);
|
||||
|
||||
if (this.acceptsFollowingTooltipLineHandler != null) {
|
||||
buttonHotkeys.put(
|
||||
NEIClientUtils.getKeyName(
|
||||
NEIClientUtils.SHIFT_HASH,
|
||||
NEIMouseUtils.MOUSE_BTN_NONE + NEIMouseUtils.MOUSE_SCROLL),
|
||||
NEIClientUtils.translate("recipe.accepts.scroll"));
|
||||
}
|
||||
|
||||
return buttonHotkeys;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -344,21 +397,32 @@ public class NEIRecipeWidget extends Widget {
|
||||
|
||||
if (overStack != null && overStack.items.length > 1) {
|
||||
final List<ItemStack> items = overStack.getFilteredPermutations();
|
||||
final int stackIndex = overStack.getPermutationIndex(overStack.item);
|
||||
final int stackIndex = indexOf(items, overStack.item);
|
||||
final ItemStack stack = items.get((items.size() - scroll + stackIndex) % items.size());
|
||||
|
||||
Stream.concat(
|
||||
this.handlerRef.handler.getIngredientStacks(this.handlerRef.recipeIndex).stream(),
|
||||
this.handlerRef.handler.getOtherStacks(this.handlerRef.recipeIndex).stream())
|
||||
.filter(pStack -> pStack.containsWithNBT(stack))
|
||||
Stream.concat(getInputs().stream(), getCatalysts().stream()).filter(pStack -> pStack.containsWithNBT(stack))
|
||||
.forEach(pStack -> pStack.setPermutationToRender(stack));
|
||||
|
||||
if (this.acceptsFollowingTooltipLineHandler != null) {
|
||||
this.acceptsFollowingTooltipLineHandler
|
||||
.setActiveStack(((PositionedStack) this.acceptsFollowingTooltipLineHandler.tooltipGUID).item);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected int indexOf(List<ItemStack> list, ItemStack stack) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (NEIServerUtils.areStacksSameTypeCraftingWithNBT(list.get(i), stack)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected <R> R forEachButtons(Function<GuiRecipeButton, R> callback, R defaultValue) {
|
||||
|
||||
for (GuiRecipeButton button : getRecipeButtonsIfInit()) {
|
||||
@@ -381,12 +445,7 @@ public class NEIRecipeWidget extends Widget {
|
||||
public boolean isFocusedRecipe(int mx, int my) {
|
||||
final int yShift = this.handlerInfo.getYShift();
|
||||
|
||||
final PositionedStack pStackResult = this.handlerRef.handler.getResultStack(this.handlerRef.recipeIndex);
|
||||
if (pStackResult != null && pStackResult.contains(mx - this.x, my - this.y - yShift)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (PositionedStack pStackOver : this.handlerRef.handler.getOtherStacks(this.handlerRef.recipeIndex)) {
|
||||
for (PositionedStack pStackOver : getOutputs()) {
|
||||
if (pStackOver.contains(mx - this.x, my - this.y - yShift)) {
|
||||
return true;
|
||||
}
|
||||
@@ -398,21 +457,22 @@ public class NEIRecipeWidget extends Widget {
|
||||
public PositionedStack getPositionedStackMouseOver(int mx, int my) {
|
||||
final int yShift = this.handlerInfo.getYShift();
|
||||
|
||||
for (PositionedStack pStack : this.handlerRef.handler.getIngredientStacks(this.handlerRef.recipeIndex)) {
|
||||
for (PositionedStack pStack : getInputs()) {
|
||||
if (pStack.contains(mx - this.x, my - this.y - yShift)) {
|
||||
return pStack;
|
||||
}
|
||||
}
|
||||
|
||||
for (PositionedStack pStack : this.handlerRef.handler.getOtherStacks(this.handlerRef.recipeIndex)) {
|
||||
for (PositionedStack pStack : getCatalysts()) {
|
||||
if (pStack.contains(mx - this.x, my - this.y - yShift)) {
|
||||
return pStack;
|
||||
}
|
||||
}
|
||||
|
||||
final PositionedStack pStackResult = this.handlerRef.handler.getResultStack(this.handlerRef.recipeIndex);
|
||||
if (pStackResult != null && pStackResult.contains(mx - this.x, my - this.y - yShift)) {
|
||||
return pStackResult;
|
||||
for (PositionedStack pStack : getOutputs()) {
|
||||
if (pStack.contains(mx - this.x, my - this.y - yShift)) {
|
||||
return pStack;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -446,7 +506,7 @@ public class NEIRecipeWidget extends Widget {
|
||||
|
||||
protected void updatePermutations() {
|
||||
|
||||
for (PositionedStack pStack : this.handlerRef.handler.getIngredientStacks(this.handlerRef.recipeIndex)) {
|
||||
for (PositionedStack pStack : getInputs()) {
|
||||
if (pStack.items.length > 1) {
|
||||
final List<ItemStack> permutations = this.permutations
|
||||
.computeIfAbsent(pStack, stack -> stack.getFilteredPermutations(FavoriteRecipes::contains));
|
||||
@@ -454,7 +514,7 @@ public class NEIRecipeWidget extends Widget {
|
||||
}
|
||||
}
|
||||
|
||||
for (PositionedStack pStack : this.handlerRef.handler.getOtherStacks(this.handlerRef.recipeIndex)) {
|
||||
for (PositionedStack pStack : getCatalysts()) {
|
||||
if (pStack.items.length > 1) {
|
||||
final List<ItemStack> permutations = this.permutations
|
||||
.computeIfAbsent(pStack, stack -> stack.getFilteredPermutations(FavoriteRecipes::contains));
|
||||
@@ -462,13 +522,28 @@ public class NEIRecipeWidget extends Widget {
|
||||
}
|
||||
}
|
||||
|
||||
final PositionedStack pStackResult = this.handlerRef.handler.getResultStack(this.handlerRef.recipeIndex);
|
||||
if (pStackResult != null && pStackResult.items.length > 1) {
|
||||
final List<ItemStack> permutations = this.permutations
|
||||
.computeIfAbsent(pStackResult, stack -> stack.getFilteredPermutations(FavoriteRecipes::contains));
|
||||
pStackResult.setPermutationToRender(permutations.get(this.lastcycle % permutations.size()));
|
||||
if (this.acceptsFollowingTooltipLineHandler != null) {
|
||||
this.acceptsFollowingTooltipLineHandler
|
||||
.setActiveStack(((PositionedStack) this.acceptsFollowingTooltipLineHandler.tooltipGUID).item);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected List<PositionedStack> getInputs() {
|
||||
return this.handlerRef.handler.getIngredientStacks(this.handlerRef.recipeIndex);
|
||||
}
|
||||
|
||||
protected List<PositionedStack> getOutputs() {
|
||||
final PositionedStack pStackResult = this.handlerRef.handler.getResultStack(this.handlerRef.recipeIndex);
|
||||
return pStackResult != null ? Arrays.asList(pStackResult)
|
||||
: this.handlerRef.handler.getOtherStacks(this.handlerRef.recipeIndex);
|
||||
}
|
||||
|
||||
protected List<PositionedStack> getCatalysts() {
|
||||
if (this.handlerRef.handler.getResultStack(this.handlerRef.recipeIndex) == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return this.handlerRef.handler.getOtherStacks(this.handlerRef.recipeIndex);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -236,7 +236,8 @@ public class Recipe {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.result != null && anRecipeId.result != null
|
||||
if (isShapedRecipe() && this.result != null
|
||||
&& anRecipeId.result != null
|
||||
&& !StackInfo.equalItemAndNBT(this.result, anRecipeId.result, true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ 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;
|
||||
@@ -81,7 +82,7 @@ public class RecipeItemInputHandler implements IContainerInputHandler, IContaine
|
||||
final BookmarksGridSlot slot = ItemPanels.bookmarkPanel.getSlotMouseOver(mousex, mousey);
|
||||
|
||||
if (slot != null && slot.getRecipeId() != null
|
||||
&& !slot.isIngredient()
|
||||
&& slot.getType() != BookmarkItemType.INGREDIENT
|
||||
&& NEIClientConfig.getRecipeTooltipsMode() != 0) {
|
||||
final int tooltipMode = NEIClientConfig.getRecipeTooltipsMode();
|
||||
final BookmarkViewMode viewMode = slot.getGroup().viewMode;
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
package codechicken.nei.recipe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.Widget;
|
||||
import codechicken.nei.scroll.ScrollContainer;
|
||||
|
||||
public class RecipePageManager {
|
||||
|
||||
private SearchRecipeHandler<?> handler;
|
||||
private ScrollContainer container;
|
||||
private HandlerInfo handlerInfo;
|
||||
|
||||
private String cacheKey = "";
|
||||
private int currentPageIndex = -1;
|
||||
private List<Integer> recipeIndices = new ArrayList<>();
|
||||
private List<List<Widget>> pageWidgets = new ArrayList<>();
|
||||
|
||||
public RecipePageManager(SearchRecipeHandler<?> handler, HandlerInfo handlerInfo, ScrollContainer container) {
|
||||
this.handler = handler;
|
||||
this.handlerInfo = handlerInfo;
|
||||
this.container = container;
|
||||
|
||||
rebuildPages();
|
||||
}
|
||||
|
||||
public boolean rebuildPages() {
|
||||
final String cacheKey = handlerInfo.getHandlerName() + ":"
|
||||
+ getNumRecipes()
|
||||
+ ":"
|
||||
+ this.container.getVisibleHeight()
|
||||
+ ":"
|
||||
+ GuiRecipe.searchField.text();
|
||||
|
||||
if (cacheKey.equals(this.cacheKey)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.cacheKey = cacheKey;
|
||||
this.pageWidgets.clear();
|
||||
|
||||
final boolean useCustomScroll = this.handlerInfo.getUseCustomScroll();
|
||||
final int handlerHeight = this.handlerInfo.getHeight() + this.handlerInfo.getYShift();
|
||||
final boolean multipleWidgetsAllowed = !useCustomScroll && handlerInfo.isMultipleWidgetsAllowed();
|
||||
final boolean infiniteScroll = !useCustomScroll
|
||||
&& NEIClientConfig.getBooleanSetting("inventory.guirecipe.infiniteScroll");
|
||||
|
||||
final int heightAvailable = this.container.getVisibleHeight();
|
||||
final int width = Math.max(166, this.handlerInfo.getWidth());
|
||||
final int numRecipes = getNumRecipes();
|
||||
List<Widget> widgets = new ArrayList<>();
|
||||
int shiftY = 0;
|
||||
|
||||
for (int i = 0; i < numRecipes; i++) {
|
||||
final int recipeIndex = this.handler.ref(i);
|
||||
final NEIRecipeWidget widget = RecipeHandlerRef.of(this.handler.original, recipeIndex).getRecipeWidget();
|
||||
widget.w = width;
|
||||
|
||||
if (useCustomScroll) {
|
||||
widget.h = Math.min(handlerHeight, heightAvailable);
|
||||
}
|
||||
|
||||
if (!widgets.isEmpty()
|
||||
&& (!multipleWidgetsAllowed || !infiniteScroll && shiftY + widget.h > heightAvailable)) {
|
||||
this.pageWidgets.add(widgets);
|
||||
widgets = new ArrayList<>();
|
||||
shiftY = 0;
|
||||
}
|
||||
|
||||
widgets.add(widget);
|
||||
shiftY += widget.h;
|
||||
}
|
||||
|
||||
if (!widgets.isEmpty()) {
|
||||
this.pageWidgets.add(widgets);
|
||||
}
|
||||
|
||||
changePage(0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isMultipleWidgetsAllowed() {
|
||||
return !this.handlerInfo.getUseCustomScroll() && this.handlerInfo.isMultipleWidgetsAllowed();
|
||||
}
|
||||
|
||||
public int getNumRecipes() {
|
||||
return this.handler.numRecipes();
|
||||
}
|
||||
|
||||
public int getCurrentPageIndex() {
|
||||
return this.currentPageIndex;
|
||||
}
|
||||
|
||||
public int getNumPages() {
|
||||
return this.pageWidgets.size();
|
||||
}
|
||||
|
||||
public void changePage(int delta) {
|
||||
final int numPages = getNumPages();
|
||||
final int page = numPages > 0 ? (numPages + Math.max(0, this.currentPageIndex) + delta) % numPages : 0;
|
||||
|
||||
if (this.currentPageIndex == page) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.currentPageIndex = page;
|
||||
this.recipeIndices = new ArrayList<>();
|
||||
|
||||
for (Widget widget : getCurrentPageWidgets()) {
|
||||
if (widget instanceof NEIRecipeWidget recipeWidget) {
|
||||
this.recipeIndices.add(recipeWidget.getRecipeHandlerRef().recipeIndex);
|
||||
}
|
||||
}
|
||||
|
||||
this.container.setVerticalScrollOffset(0);
|
||||
}
|
||||
|
||||
public void gotoRefIndex(int refIndex) {
|
||||
int page = 0;
|
||||
|
||||
for (int i = 0; i < this.pageWidgets.size(); i++) {
|
||||
refIndex -= this.pageWidgets.get(i).size();
|
||||
if (refIndex < 0) {
|
||||
page = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
changePage(page);
|
||||
}
|
||||
|
||||
public List<Widget> getCurrentPageWidgets() {
|
||||
if (this.pageWidgets.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<Widget> currentWidgets = this.pageWidgets.get(this.currentPageIndex);
|
||||
int shiftY = 0;
|
||||
|
||||
for (Widget widget : currentWidgets) {
|
||||
if (widget instanceof NEIRecipeWidget recipeWidget) {
|
||||
recipeWidget.setLocation(0, shiftY);
|
||||
}
|
||||
shiftY += widget.h;
|
||||
}
|
||||
|
||||
return currentWidgets;
|
||||
}
|
||||
|
||||
public List<Integer> getRecipeIndices() {
|
||||
return this.recipeIndices;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -76,6 +76,16 @@ public class StackInfo {
|
||||
return stack;
|
||||
}
|
||||
|
||||
public static ItemStack normalizeRecipeQueryStack(ItemStack stack) {
|
||||
ItemStack result = null;
|
||||
|
||||
for (int i = stackStringifyHandlers.size() - 1; i >= 0 && result == null; i--) {
|
||||
result = stackStringifyHandlers.get(i).normalizeRecipeQueryStack(stack);
|
||||
}
|
||||
|
||||
return result == null ? stack : result;
|
||||
}
|
||||
|
||||
public static void pauseItemDamageSound(boolean pause) {
|
||||
if (isPausedItemDamageSound != (isPausedItemDamageSound = pause)) {
|
||||
for (IStackStringifyHandler handler : stackStringifyHandlers) {
|
||||
|
||||
@@ -16,6 +16,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import codechicken.nei.ItemStackAmount;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.bookmark.BookmarkItem;
|
||||
import codechicken.nei.bookmark.BookmarkItem.BookmarkItemType;
|
||||
import codechicken.nei.recipe.Recipe;
|
||||
import codechicken.nei.recipe.Recipe.RecipeId;
|
||||
import codechicken.nei.recipe.Recipe.RecipeIngredient;
|
||||
@@ -52,20 +53,12 @@ public class RecipeChainMath {
|
||||
private final List<ItemStack> containerItemsBlacklist = new ArrayList<>();
|
||||
|
||||
private RecipeChainMath(List<BookmarkItem> recipeItems, Set<RecipeId> collapsedRecipes) {
|
||||
final Map<RecipeId, Integer> recipeState = new HashMap<>();
|
||||
final Map<RecipeId, Long> multipliers = new HashMap<>();
|
||||
|
||||
for (BookmarkItem item : recipeItems) {
|
||||
if (item.recipeId != null) {
|
||||
recipeState
|
||||
.put(item.recipeId, recipeState.getOrDefault(item.recipeId, 0) | (item.isIngredient ? 1 : 2));
|
||||
}
|
||||
}
|
||||
|
||||
for (BookmarkItem item : recipeItems) {
|
||||
if (recipeState.getOrDefault(item.recipeId, 0) != 3) {
|
||||
if (item.recipeId == null || item.type == BookmarkItemType.ITEM) {
|
||||
this.initialItems.add(item.copy());
|
||||
} else if (item.isIngredient) {
|
||||
} else if (item.type == BookmarkItemType.INGREDIENT) {
|
||||
this.recipeIngredients.add(item.copyWithAmount(0));
|
||||
} else {
|
||||
this.recipeResults.add(item.copyWithAmount(0));
|
||||
@@ -209,7 +202,7 @@ public class RecipeChainMath {
|
||||
item.getItemStack(amount),
|
||||
item.getStackSize(amount),
|
||||
ROOT_RECIPE_ID,
|
||||
true,
|
||||
BookmarkItemType.INGREDIENT,
|
||||
BookmarkItem.generatePermutations(item.itemStack, null)));
|
||||
}
|
||||
}
|
||||
@@ -217,7 +210,7 @@ public class RecipeChainMath {
|
||||
this.outputRecipes.clear();
|
||||
this.outputRecipes.put(ROOT_RECIPE_ID, 1L);
|
||||
this.recipeResults.removeIf(item -> ROOT_RECIPE_ID.equals(item.recipeId));
|
||||
this.recipeResults.add(BookmarkItem.of(-1, ROOT_ITEM, 1, ROOT_RECIPE_ID, false));
|
||||
this.recipeResults.add(BookmarkItem.of(-1, ROOT_ITEM, 1, ROOT_RECIPE_ID, BookmarkItemType.RESULT));
|
||||
this.recipeIngredients.addAll(rootIngredients);
|
||||
|
||||
return ROOT_RECIPE_ID;
|
||||
@@ -236,7 +229,7 @@ public class RecipeChainMath {
|
||||
final RecipeId recipeId = recipe.getRecipeId();
|
||||
final ItemStack result = recipe.getResult();
|
||||
|
||||
chainItems.add(BookmarkItem.of(-1, result, StackInfo.getAmount(result), recipeId, false));
|
||||
chainItems.add(BookmarkItem.of(-1, result, StackInfo.getAmount(result), recipeId, BookmarkItemType.RESULT));
|
||||
|
||||
for (RecipeIngredient ingr : recipe.getIngredients()) {
|
||||
chainItems.add(
|
||||
@@ -245,7 +238,7 @@ public class RecipeChainMath {
|
||||
ingr.getItemStack(),
|
||||
ingr.getAmount(),
|
||||
recipeId,
|
||||
true,
|
||||
BookmarkItemType.INGREDIENT,
|
||||
BookmarkItem.generatePermutations(ingr.getItemStack(), recipe)));
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
|
||||
protected ItemsTooltipLineHandler inputs;
|
||||
protected ItemsTooltipLineHandler outputs;
|
||||
protected ItemsTooltipLineHandler remainder;
|
||||
protected ItemsTooltipLineHandler craftingNeeded;
|
||||
protected boolean lastShiftKey = false;
|
||||
protected boolean lastControlKey = false;
|
||||
|
||||
@@ -54,6 +55,7 @@ public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
|
||||
final List<ItemStack> inputs = new ArrayList<>();
|
||||
final List<ItemStack> outputs = new ArrayList<>();
|
||||
final List<ItemStack> remainder = new ArrayList<>();
|
||||
final List<ItemStack> craftingNeeded = new ArrayList<>();
|
||||
final ItemStackAmount inventory = new ItemStackAmount();
|
||||
final GuiContainer currentGui = NEIClientUtils.getGuiContainer();
|
||||
|
||||
@@ -167,6 +169,12 @@ public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
|
||||
}
|
||||
|
||||
}
|
||||
if (this.lastShiftKey) {
|
||||
for (Map.Entry<BookmarkItem, Long> item : this.math.requiredAmount.entrySet()) {
|
||||
if (item.getKey().type == BookmarkItem.BookmarkItemType.RESULT && item.getValue() != 0)
|
||||
craftingNeeded.add(item.getKey().getItemStack(item.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
inputs.sort(
|
||||
Comparator.comparing((ItemStack stack) -> StackInfo.getFluid(stack) != null)
|
||||
@@ -203,11 +211,20 @@ public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
|
||||
true,
|
||||
Integer.MAX_VALUE);
|
||||
|
||||
this.craftingNeeded = new ItemsTooltipLineHandler(
|
||||
NEIClientUtils.translate("bookmark.crafting_chain.needed"),
|
||||
craftingNeeded,
|
||||
true,
|
||||
Integer.MAX_VALUE);
|
||||
|
||||
if (this.lastShiftKey) {
|
||||
this.inputs.setLabelColor(EnumChatFormatting.RED);
|
||||
this.available.setLabelColor(EnumChatFormatting.GREEN);
|
||||
this.craftingNeeded.setLabelColor(EnumChatFormatting.BLUE);
|
||||
}
|
||||
|
||||
this.size.height = this.size.width = 0;
|
||||
|
||||
if (!this.inputs.isEmpty() || !this.outputs.isEmpty()
|
||||
|| !this.remainder.isEmpty()
|
||||
|| !this.available.isEmpty()) {
|
||||
@@ -215,18 +232,18 @@ public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
|
||||
if (!this.math.outputRecipes.isEmpty()) {
|
||||
this.size.height = 2 + GuiDraw.fontRenderer.FONT_HEIGHT;
|
||||
}
|
||||
|
||||
this.size.width = Math.max(
|
||||
this.inputs.getSize().width,
|
||||
Math.max(
|
||||
this.outputs.getSize().width,
|
||||
Math.max(this.remainder.getSize().width, this.available.getSize().width)));
|
||||
Math.max(
|
||||
this.remainder.getSize().width,
|
||||
Math.max(this.available.getSize().width, this.craftingNeeded.getSize().width))));
|
||||
|
||||
this.size.height += this.inputs.getSize().height + this.outputs.getSize().height
|
||||
+ this.remainder.getSize().height
|
||||
+ this.available.getSize().height;
|
||||
} else {
|
||||
this.size.height = this.size.width = 0;
|
||||
+ this.available.getSize().height
|
||||
+ this.craftingNeeded.getSize().height;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -258,7 +275,6 @@ public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
|
||||
}
|
||||
|
||||
if (NEIClientConfig.recipeChainDir() == 0) {
|
||||
|
||||
if (!this.inputs.isEmpty()) {
|
||||
this.inputs.draw(x, y);
|
||||
y += this.inputs.getSize().height;
|
||||
@@ -269,6 +285,11 @@ public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
|
||||
y += this.available.getSize().height;
|
||||
}
|
||||
|
||||
if (!this.craftingNeeded.isEmpty()) {
|
||||
this.craftingNeeded.draw(x, y);
|
||||
y += this.craftingNeeded.getSize().height;
|
||||
}
|
||||
|
||||
if (!this.outputs.isEmpty()) {
|
||||
this.outputs.draw(x, y);
|
||||
y += this.outputs.getSize().height;
|
||||
@@ -286,6 +307,11 @@ public class RecipeChainTooltipLineHandler implements ITooltipLineHandler {
|
||||
y += this.inputs.getSize().height;
|
||||
}
|
||||
|
||||
if (!this.craftingNeeded.isEmpty()) {
|
||||
this.craftingNeeded.draw(x, y);
|
||||
y += this.craftingNeeded.getSize().height;
|
||||
}
|
||||
|
||||
if (!this.available.isEmpty()) {
|
||||
this.available.draw(x, y);
|
||||
y += this.available.getSize().height;
|
||||
|
||||
@@ -19,9 +19,8 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
|
||||
protected static Class<?> itemFluidDisplay = null;
|
||||
protected static Method getFluidDisplayStack = null;
|
||||
protected static Method getFluidFromDisplayStack = null;
|
||||
public static boolean replaceAE2FCFluidDrop = false;
|
||||
private static Class<?> gtMetaGeneratedTool = null;
|
||||
private static Field playSound = null;
|
||||
protected static Class<?> gtMetaGeneratedTool = null;
|
||||
protected static Field playSound = null;
|
||||
|
||||
static {
|
||||
try {
|
||||
@@ -48,7 +47,7 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
|
||||
|
||||
public NBTTagCompound convertItemStackToNBT(ItemStack stack, boolean saveStackSize) {
|
||||
|
||||
if (replaceAE2FCFluidDrop || stack.getItem() != GameRegistry.findItem("ae2fc", "fluid_drop")) {
|
||||
if (stack.getItem() != GameRegistry.findItem("ae2fc", "fluid_drop")) {
|
||||
final FluidStack fluidStack = getFluid(stack);
|
||||
|
||||
if (fluidStack != null) {
|
||||
@@ -69,14 +68,11 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
|
||||
final Fluid fluid = FluidRegistry.getFluid(fluidName);
|
||||
final int amount = nbtTag.getInteger("Count");
|
||||
|
||||
try {
|
||||
final Object obj = getFluidDisplayStack.invoke(null, new FluidStack(fluid, amount), true);
|
||||
|
||||
if (obj != null) {
|
||||
return (ItemStack) obj;
|
||||
}
|
||||
|
||||
} catch (Exception e) {}
|
||||
if (fluid != null) {
|
||||
try {
|
||||
return (ItemStack) getFluidDisplayStack.invoke(null, new FluidStack(fluid, amount), true);
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -114,6 +110,22 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack normalizeRecipeQueryStack(ItemStack stack) {
|
||||
|
||||
if (stack.getItem() == GameRegistry.findItem("ae2fc", "fluid_drop")
|
||||
|| stack.getItem() == GameRegistry.findItem("ae2fc", "fluid_packet")) {
|
||||
final FluidStack fluidStack = getFluid(stack);
|
||||
|
||||
if (fluidStack != null) {
|
||||
try {
|
||||
return (ItemStack) getFluidDisplayStack.invoke(null, fluidStack, true);
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pauseItemDamageSound(boolean pause) {
|
||||
if (playSound != null) {
|
||||
|
||||
@@ -31,18 +31,26 @@ public class ScrollBar {
|
||||
}
|
||||
|
||||
public enum ScrollPlace {
|
||||
INSIDE,
|
||||
OUTSIDE
|
||||
START,
|
||||
END
|
||||
}
|
||||
|
||||
private ScrollType scrollType = ScrollType.VERTICAL;
|
||||
private OverflowType overflowType = OverflowType.SCROLL;
|
||||
private ScrollPlace scrollPlace = ScrollPlace.INSIDE;
|
||||
private ScrollPlace scrollPlace = ScrollPlace.END;
|
||||
private float handleClickOffset = -1;
|
||||
|
||||
private int scrollbarSize = 6;
|
||||
private int thumbPadding = 0;
|
||||
private int margin = 0;
|
||||
private int trackWidth = 6;
|
||||
|
||||
private int thumbPaddingLeft = 0;
|
||||
private int thumbPaddingRight = 0;
|
||||
private int thumbPaddingTop = 0;
|
||||
private int thumbPaddingBottom = 0;
|
||||
|
||||
private int trackPaddingLeft = 0;
|
||||
private int trackPaddingRight = 0;
|
||||
private int trackPaddingTop = 0;
|
||||
private int trackPaddingBottom = 0;
|
||||
|
||||
private DrawableResource thumbTexture;
|
||||
private int thumbSliceStart;
|
||||
@@ -57,41 +65,65 @@ public class ScrollBar {
|
||||
}
|
||||
|
||||
public static ScrollBar defaultVerticalBar() {
|
||||
return new ScrollBar().setScrollbarSize(8)
|
||||
.setTrackTexture(new DrawableBuilder("nei:textures/nei_sprites.png", 29, 95, 12, 11).build(), 3, 4)
|
||||
.setThumbTexture(new DrawableBuilder("nei:textures/nei_sprites.png", 21, 96, 8, 9).build(), 3, 2)
|
||||
.setThumbPadding(1);
|
||||
return new ScrollBar().setTrackWidth(8)
|
||||
.setTrackTexture(new DrawableBuilder("nei:textures/nei_sprites.png", 29, 95, 8, 11).build(), 3, 4)
|
||||
.setThumbTexture(new DrawableBuilder("nei:textures/nei_sprites.png", 22, 96, 6, 9).build(), 3, 2)
|
||||
.setThumbPadding(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
public static ScrollBar defaultHorizontalBar() {
|
||||
return new ScrollBar().setScrollbarSize(8).setOverflowType(OverflowType.SCROLL)
|
||||
.setScrollPlace(ScrollPlace.INSIDE)
|
||||
return new ScrollBar().setTrackWidth(8).setOverflowType(OverflowType.SCROLL)
|
||||
.setTrackTexture(new DrawableBuilder("nei:textures/nei_sprites.png", 0, 97, 11, 8).build(), 3, 4)
|
||||
.setThumbTexture(new DrawableBuilder("nei:textures/nei_sprites.png", 12, 97, 9, 7).build(), 3, 2)
|
||||
.setThumbPadding(1);
|
||||
.setThumbTexture(new DrawableBuilder("nei:textures/nei_sprites.png", 12, 98, 9, 6).build(), 3, 2)
|
||||
.setThumbPadding(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
public ScrollBar setScrollbarSize(int scrollbarSize) {
|
||||
this.scrollbarSize = scrollbarSize;
|
||||
/**
|
||||
* Sets the size of the scrollbar without texture in the non-scrolling axis (width for vertical, height for
|
||||
* horizontal).
|
||||
*
|
||||
* @param trackWidth
|
||||
* @return
|
||||
*/
|
||||
public ScrollBar setTrackWidth(int trackWidth) {
|
||||
this.trackWidth = trackWidth;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ScrollBar setThumbPadding(int thumbPadding) {
|
||||
this.thumbPadding = thumbPadding;
|
||||
public ScrollBar setTrackPadding(int left, int top, int right, int bottom) {
|
||||
this.trackPaddingLeft = left;
|
||||
this.trackPaddingRight = right;
|
||||
this.trackPaddingTop = top;
|
||||
this.trackPaddingBottom = bottom;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ScrollBar setMargin(int margin) {
|
||||
this.margin = margin;
|
||||
public ScrollBar setThumbPadding(int left, int top, int right, int bottom) {
|
||||
this.thumbPaddingLeft = left;
|
||||
this.thumbPaddingRight = right;
|
||||
this.thumbPaddingTop = top;
|
||||
this.thumbPaddingBottom = bottom;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getMargin() {
|
||||
return this.margin;
|
||||
public int getTrackWidth() {
|
||||
|
||||
if (this.trackTexture != null) {
|
||||
return this.scrollType == ScrollType.HORIZONTAL ? this.trackTexture.getHeight()
|
||||
: this.trackTexture.getWidth();
|
||||
}
|
||||
|
||||
return this.trackWidth;
|
||||
}
|
||||
|
||||
public int getScrollbarSize() {
|
||||
return this.scrollbarSize;
|
||||
protected int getThumbWidth() {
|
||||
|
||||
if (this.thumbTexture != null) {
|
||||
return this.scrollType == ScrollType.HORIZONTAL ? this.thumbTexture.getHeight()
|
||||
: this.thumbTexture.getWidth();
|
||||
}
|
||||
|
||||
return getTrackWidth();
|
||||
}
|
||||
|
||||
public ScrollBar setThumbTexture(DrawableResource texture, int sliceStart, int sliceEnd) {
|
||||
@@ -148,27 +180,18 @@ public class ScrollBar {
|
||||
}
|
||||
|
||||
private int getMaxThumbSize(ScrollContainer container) {
|
||||
return getMaxTrackSize(container) - this.thumbPadding * 2;
|
||||
if (this.scrollType == ScrollType.HORIZONTAL) {
|
||||
return getMaxTrackSize(container) - this.thumbPaddingLeft - this.thumbPaddingRight;
|
||||
} else {
|
||||
return getMaxTrackSize(container) - this.thumbPaddingTop - this.thumbPaddingBottom;
|
||||
}
|
||||
}
|
||||
|
||||
private int getMaxTrackSize(ScrollContainer container) {
|
||||
if (this.scrollType == ScrollType.HORIZONTAL) {
|
||||
int visibleSize = container.w;
|
||||
|
||||
if (container.canScrollVertical() && container.getVerticalScroll().getScrollPlace() == ScrollPlace.INSIDE) {
|
||||
visibleSize -= container.getVerticalScroll().getScrollbarSize();
|
||||
}
|
||||
|
||||
return visibleSize;
|
||||
return container.w - this.trackPaddingLeft - this.trackPaddingRight;
|
||||
} else {
|
||||
int visibleSize = container.h;
|
||||
|
||||
if (container.canScrollHorizontal()
|
||||
&& container.getHorizontalScroll().getScrollPlace() == ScrollPlace.INSIDE) {
|
||||
visibleSize -= container.getHorizontalScroll().getScrollbarSize();
|
||||
}
|
||||
|
||||
return visibleSize;
|
||||
return container.h - this.trackPaddingTop - this.trackPaddingBottom;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,23 +228,22 @@ public class ScrollBar {
|
||||
}
|
||||
|
||||
public Rectangle4i trackBounds(ScrollContainer container) {
|
||||
int trackWidth = getTrackWidth();
|
||||
|
||||
if (this.scrollType == ScrollType.HORIZONTAL) {
|
||||
return new Rectangle4i(
|
||||
container.x,
|
||||
container.y + container.h
|
||||
+ this.margin
|
||||
- (this.scrollPlace == ScrollPlace.INSIDE ? scrollbarSize : 0),
|
||||
getMaxTrackSize(container),
|
||||
scrollbarSize);
|
||||
final int y = this.scrollPlace == ScrollPlace.START ? container.y - trackWidth - this.trackPaddingBottom
|
||||
: container.y + container.h + this.trackPaddingTop;
|
||||
|
||||
return new Rectangle4i(container.x + this.trackPaddingLeft, y, getMaxTrackSize(container), trackWidth);
|
||||
|
||||
} else {
|
||||
return new Rectangle4i(
|
||||
container.x + container.w
|
||||
+ this.margin
|
||||
- (this.scrollPlace == ScrollPlace.INSIDE ? scrollbarSize : 0),
|
||||
container.y,
|
||||
scrollbarSize,
|
||||
getMaxTrackSize(container));
|
||||
final int x = this.scrollPlace == ScrollPlace.START ? container.x - trackWidth - this.trackPaddingRight
|
||||
: container.x + container.w + this.trackPaddingLeft;
|
||||
|
||||
return new Rectangle4i(x, container.y + this.trackPaddingTop, trackWidth, getMaxTrackSize(container));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Rectangle4i thumbBounds(ScrollContainer container) {
|
||||
@@ -230,9 +252,25 @@ public class ScrollBar {
|
||||
final Rectangle4i bounds = trackBounds(container);
|
||||
|
||||
if (this.scrollType == ScrollType.HORIZONTAL) {
|
||||
return new Rectangle4i(bounds.x + this.thumbPadding + offset, bounds.y, mainAxisSize, bounds.h);
|
||||
final int y = this.scrollPlace == ScrollPlace.START
|
||||
? bounds.y + bounds.h - getThumbWidth() - this.thumbPaddingBottom
|
||||
: bounds.y + this.thumbPaddingTop;
|
||||
|
||||
return new Rectangle4i(
|
||||
bounds.x + this.thumbPaddingLeft + offset,
|
||||
y,
|
||||
mainAxisSize,
|
||||
bounds.h - this.thumbPaddingTop - this.thumbPaddingBottom);
|
||||
} else {
|
||||
return new Rectangle4i(bounds.x, bounds.y + this.thumbPadding + offset, bounds.w, mainAxisSize);
|
||||
final int x = this.scrollPlace == ScrollPlace.START
|
||||
? bounds.x + bounds.w - getThumbWidth() - this.thumbPaddingRight
|
||||
: bounds.x + this.thumbPaddingLeft;
|
||||
|
||||
return new Rectangle4i(
|
||||
x,
|
||||
bounds.y + this.thumbPaddingTop + offset,
|
||||
bounds.w - this.thumbPaddingLeft - this.thumbPaddingRight,
|
||||
mainAxisSize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,7 +291,7 @@ public class ScrollBar {
|
||||
final Rectangle4i thumbBounds = thumbBounds(container);
|
||||
|
||||
if (this.scrollType == ScrollType.HORIZONTAL) {
|
||||
final int relativeX = mx - bounds.x - this.thumbPadding;
|
||||
final int relativeX = mx - bounds.x - this.thumbPaddingLeft;
|
||||
|
||||
if (mx < thumbBounds.x || mx > thumbBounds.x + thumbBounds.w) {
|
||||
this.handleClickOffset = mainAxisSize / 2;
|
||||
@@ -265,7 +303,7 @@ public class ScrollBar {
|
||||
* (container.getActualWidth() - container.getVisibleWidth())) / thumbSize;
|
||||
container.setHorizontalScrollOffset((int) newOffset);
|
||||
} else {
|
||||
final int relativeY = my - bounds.y - this.thumbPadding;
|
||||
final int relativeY = my - bounds.y - this.thumbPaddingTop;
|
||||
|
||||
if (my < thumbBounds.y || my > thumbBounds.y + thumbBounds.h) {
|
||||
this.handleClickOffset = mainAxisSize / 2f;
|
||||
@@ -293,12 +331,12 @@ public class ScrollBar {
|
||||
final float thumbSize = getMaxThumbSize(container) - mainAxisSize;
|
||||
|
||||
if (this.scrollType == ScrollType.HORIZONTAL) {
|
||||
final int relativeX = mx - bounds.x - this.thumbPadding;
|
||||
final int relativeX = mx - bounds.x - this.thumbPaddingLeft;
|
||||
final float newOffset = ((relativeX - this.handleClickOffset)
|
||||
* (container.getActualWidth() - container.getVisibleWidth())) / thumbSize;
|
||||
container.setHorizontalScrollOffset((int) newOffset);
|
||||
} else {
|
||||
int relativeY = my - bounds.y - this.thumbPadding;
|
||||
int relativeY = my - bounds.y - this.thumbPaddingTop;
|
||||
final float newOffset = ((relativeY - this.handleClickOffset)
|
||||
* (container.getActualHeight() - container.getVisibleHeight())) / thumbSize;
|
||||
|
||||
@@ -354,7 +392,7 @@ public class ScrollBar {
|
||||
}
|
||||
|
||||
private void drawTrackRect(ScrollContainer container, Rectangle4i bounds, float opacity) {
|
||||
final float trackSize = scrollbarSize / 3f;
|
||||
final float trackSize = this.trackWidth / 3f;
|
||||
final Color trackColor = new Color(
|
||||
BACKGROUND_COLOR.getRed(),
|
||||
BACKGROUND_COLOR.getGreen(),
|
||||
|
||||
@@ -14,7 +14,6 @@ import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.Widget;
|
||||
import codechicken.nei.WidgetContainer;
|
||||
import codechicken.nei.scroll.ScrollBar.OverflowType;
|
||||
import codechicken.nei.scroll.ScrollBar.ScrollPlace;
|
||||
import codechicken.nei.scroll.ScrollBar.ScrollType;
|
||||
|
||||
public class ScrollContainer extends WidgetContainer {
|
||||
@@ -34,8 +33,10 @@ public class ScrollContainer extends WidgetContainer {
|
||||
protected int actualWidth = 0;
|
||||
protected int actualHeight = 0;
|
||||
|
||||
protected int marginInline = 0;
|
||||
protected int marginBlock = 0;
|
||||
protected int paddingInlineStart = 0;
|
||||
protected int paddingInlineEnd = 0;
|
||||
protected int paddingBlockStart = 0;
|
||||
protected int paddingBlockEnd = 0;
|
||||
|
||||
protected final Map<Widget, Point> relativePostion = new HashMap<>();
|
||||
protected ScrollBar horizontalScrollBar;
|
||||
@@ -45,30 +46,36 @@ public class ScrollContainer extends WidgetContainer {
|
||||
public Rectangle4i boundsOutside() {
|
||||
int width = this.w;
|
||||
int height = this.h;
|
||||
int x = this.x;
|
||||
int y = this.y;
|
||||
|
||||
if (canScrollVertical() && (this.verticalScrollBar.getOverflowType() == OverflowType.SCROLL
|
||||
|| this.verticalScrollBar.getOverflowType() == OverflowType.AUTO)) {
|
||||
width += this.verticalScrollBar.getMargin();
|
||||
|
||||
if (this.verticalScrollBar.getScrollPlace() == ScrollPlace.OUTSIDE) {
|
||||
width += this.verticalScrollBar.getScrollbarSize();
|
||||
}
|
||||
final Rectangle4i trackBounds = this.verticalScrollBar.trackBounds(this);
|
||||
x = Math.min(x, trackBounds.x);
|
||||
y = Math.min(y, trackBounds.y);
|
||||
height = Math.max(this.y + height, trackBounds.y + trackBounds.h) - y;
|
||||
width = Math.max(this.x + width, trackBounds.x + trackBounds.w) - x;
|
||||
}
|
||||
|
||||
if (canScrollHorizontal() && (this.horizontalScrollBar.getOverflowType() == OverflowType.SCROLL
|
||||
|| this.horizontalScrollBar.getOverflowType() == OverflowType.AUTO)) {
|
||||
height += this.horizontalScrollBar.getMargin();
|
||||
|
||||
if (this.horizontalScrollBar.getScrollPlace() == ScrollPlace.OUTSIDE) {
|
||||
height += this.horizontalScrollBar.getScrollbarSize();
|
||||
}
|
||||
final Rectangle4i trackBounds = this.horizontalScrollBar.trackBounds(this);
|
||||
x = Math.min(x, trackBounds.x);
|
||||
y = Math.min(y, trackBounds.y);
|
||||
height = Math.max(this.y + height, trackBounds.y + trackBounds.h) - y;
|
||||
width = Math.max(this.x + width, trackBounds.x + trackBounds.w) - x;
|
||||
}
|
||||
|
||||
return new Rectangle4i(x, y, width, height);
|
||||
}
|
||||
|
||||
public Rectangle4i boundsInside() {
|
||||
return new Rectangle4i(x, y, getVisibleWidth(), getVisibleHeight());
|
||||
return new Rectangle4i(
|
||||
x + this.paddingInlineStart,
|
||||
y + this.paddingBlockStart,
|
||||
getVisibleWidth(),
|
||||
getVisibleHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,31 +99,18 @@ public class ScrollContainer extends WidgetContainer {
|
||||
return this.relativePostion.get(widget);
|
||||
}
|
||||
|
||||
public void setMarginInline(int marginInline) {
|
||||
this.marginInline = marginInline;
|
||||
public void setPaddingInline(int start, int end) {
|
||||
this.paddingInlineStart = start;
|
||||
this.paddingInlineEnd = end;
|
||||
}
|
||||
|
||||
public void setMarginBlock(int marginBlock) {
|
||||
this.marginBlock = marginBlock;
|
||||
}
|
||||
|
||||
public int getMarginInline() {
|
||||
return this.marginInline;
|
||||
}
|
||||
|
||||
public int getMarginBlock() {
|
||||
return this.marginBlock;
|
||||
public void setPaddingBlock(int start, int end) {
|
||||
this.paddingBlockStart = start;
|
||||
this.paddingBlockEnd = end;
|
||||
}
|
||||
|
||||
public int getVisibleWidth() {
|
||||
|
||||
if (canScrollVertical() && this.verticalScrollBar.getScrollPlace() == ScrollPlace.INSIDE
|
||||
&& (this.verticalScrollBar.getOverflowType() == OverflowType.SCROLL
|
||||
|| this.verticalScrollBar.getOverflowType() == OverflowType.AUTO)) {
|
||||
return this.w - this.verticalScrollBar.getScrollbarSize();
|
||||
}
|
||||
|
||||
return this.w;
|
||||
return this.w - this.paddingInlineStart - this.paddingInlineEnd;
|
||||
}
|
||||
|
||||
public int getActualWidth() {
|
||||
@@ -125,7 +119,7 @@ public class ScrollContainer extends WidgetContainer {
|
||||
|
||||
public boolean setHorizontalScrollOffset(int offset) {
|
||||
|
||||
if (!canScrollHorizontal() && this.w < getActualWidth()) {
|
||||
if (!canScrollHorizontal() && getVisibleWidth() < getActualWidth()) {
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
@@ -150,9 +144,9 @@ public class ScrollContainer extends WidgetContainer {
|
||||
}
|
||||
|
||||
public boolean canScrollHorizontal() {
|
||||
return this.horizontalScrollBar != null
|
||||
&& (this.horizontalScrollBar.getOverflowType() != OverflowType.NONE && this.w < getActualWidth()
|
||||
|| this.horizontalScrollBar.getOverflowType() == OverflowType.SCROLL);
|
||||
return this.horizontalScrollBar != null && (this.horizontalScrollBar.getOverflowType() != OverflowType.NONE
|
||||
&& getVisibleWidth() < getActualWidth()
|
||||
|| this.horizontalScrollBar.getOverflowType() == OverflowType.SCROLL);
|
||||
}
|
||||
|
||||
public ScrollBar getHorizontalScroll() {
|
||||
@@ -174,14 +168,7 @@ public class ScrollContainer extends WidgetContainer {
|
||||
}
|
||||
|
||||
public int getVisibleHeight() {
|
||||
|
||||
if (canScrollHorizontal() && this.horizontalScrollBar.getScrollPlace() == ScrollPlace.INSIDE
|
||||
&& (this.horizontalScrollBar.getOverflowType() == OverflowType.SCROLL
|
||||
|| this.horizontalScrollBar.getOverflowType() == OverflowType.AUTO)) {
|
||||
return this.h - this.horizontalScrollBar.getScrollbarSize();
|
||||
}
|
||||
|
||||
return this.h;
|
||||
return this.h - this.paddingBlockStart - this.paddingBlockEnd;
|
||||
}
|
||||
|
||||
public int getActualHeight() {
|
||||
@@ -190,7 +177,7 @@ public class ScrollContainer extends WidgetContainer {
|
||||
|
||||
public boolean setVerticalScrollOffset(int offset) {
|
||||
|
||||
if (!canScrollVertical() && this.h < getActualHeight()) {
|
||||
if (!canScrollVertical() && getVisibleHeight() < getActualHeight()) {
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
@@ -215,9 +202,9 @@ public class ScrollContainer extends WidgetContainer {
|
||||
}
|
||||
|
||||
public boolean canScrollVertical() {
|
||||
return this.verticalScrollBar != null
|
||||
&& (this.verticalScrollBar.getOverflowType() != OverflowType.NONE && this.h < getActualHeight()
|
||||
|| this.verticalScrollBar.getOverflowType() == OverflowType.SCROLL);
|
||||
return this.verticalScrollBar != null && (this.verticalScrollBar.getOverflowType() != OverflowType.NONE
|
||||
&& getVisibleHeight() < getActualHeight()
|
||||
|| this.verticalScrollBar.getOverflowType() == OverflowType.SCROLL);
|
||||
}
|
||||
|
||||
public ScrollBar getVerticalScroll() {
|
||||
@@ -245,10 +232,10 @@ public class ScrollContainer extends WidgetContainer {
|
||||
|
||||
if (canScrollVertical || canScrollHorizontal) {
|
||||
GuiHelper.useScissor(
|
||||
this.x,
|
||||
this.y,
|
||||
getVisibleWidth(),
|
||||
getVisibleHeight(),
|
||||
this.x + this.paddingInlineStart,
|
||||
this.y + this.paddingBlockStart,
|
||||
this.w - this.paddingInlineStart - this.paddingInlineEnd,
|
||||
this.h - this.paddingBlockStart - this.paddingBlockEnd,
|
||||
() -> drawContent(mousex, mousey));
|
||||
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_LIGHTING_BIT);
|
||||
@@ -295,12 +282,15 @@ public class ScrollContainer extends WidgetContainer {
|
||||
|
||||
super.update();
|
||||
|
||||
for (Widget widget : this.widgets) {
|
||||
this.actualWidth = Math.max(this.actualWidth, widget.x + widget.w + this.marginInline * 2);
|
||||
this.actualHeight = Math.max(this.actualHeight, widget.y + widget.h + this.marginBlock * 2);
|
||||
final int x = this.x + this.paddingInlineStart - this.xScroll;
|
||||
final int y = this.y + this.paddingBlockStart - this.yScroll;
|
||||
|
||||
widget.x += this.marginInline + this.x - this.xScroll;
|
||||
widget.y += this.marginBlock + this.y - this.yScroll;
|
||||
for (Widget widget : this.widgets) {
|
||||
this.actualWidth = Math.max(this.actualWidth, widget.x + widget.w);
|
||||
this.actualHeight = Math.max(this.actualHeight, widget.y + widget.h);
|
||||
|
||||
widget.x += x;
|
||||
widget.y += y;
|
||||
}
|
||||
|
||||
if (this.fade > 0) {
|
||||
|
||||
@@ -131,10 +131,6 @@ public class ItemUntranslator {
|
||||
private final Map<String, String> secondNames = new HashMap<>();
|
||||
private final Map<String, String> processedNames = new HashMap<>();
|
||||
|
||||
static {
|
||||
API.addSubset("Untranslated", item -> instance.getItemStackDisplayName(item).isEmpty());
|
||||
}
|
||||
|
||||
private ItemUntranslator() {}
|
||||
|
||||
public static ItemUntranslator getInstance() {
|
||||
@@ -363,12 +359,14 @@ public class ItemUntranslator {
|
||||
this.secondNames.clear();
|
||||
LanguageRegistryPatch.secondLanguageListCache = null;
|
||||
this.processedNames.clear();
|
||||
|
||||
SubsetWidget.removeTag("Untranslated");
|
||||
}
|
||||
|
||||
public void load() {
|
||||
unload();
|
||||
|
||||
this.secondNames.clear();
|
||||
LanguageRegistryPatch.secondLanguageListCache = null;
|
||||
this.processedNames.clear();
|
||||
|
||||
if (ClientHandler.loadSettingsFile(CONFIG_FILE, null, this::parseStream)
|
||||
|| ClientHandler.loadSettingsResource(CONFIG_FILE, this::parseStream)) {
|
||||
@@ -380,7 +378,7 @@ public class ItemUntranslator {
|
||||
this.secondNames.clear();
|
||||
}
|
||||
|
||||
SubsetWidget.updateHiddenItems();
|
||||
API.addSubset("Untranslated", item -> instance.getItemStackDisplayName(item).isEmpty());
|
||||
}
|
||||
|
||||
private void parseStream(Stream<String> lines) {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
# This file contains a list of GUIs that can use the DefaultBookmarkContainerHandler for bookmarks.
|
||||
# It serves as an alternative to API.registerBookmarkContainerHandler and is intended for cases
|
||||
# where you can't modify the mod itself and its GUI doesn't have custom slots.
|
||||
# Each line in this file should either be a comment (starting with '#') or a guiContainer class name.
|
||||
# If you delete this file, it will be regenerated with the default bookmark containers list.
|
||||
@@ -1,4 +1,5 @@
|
||||
# Each line in this file should either be a comment (line starts with '#'), handler name or handler id.
|
||||
# This file contains a list of GUIs for which craftable item panels will not work.
|
||||
# Each line in this file should either be a comment (line starts with '#'), or guiContainer class name.
|
||||
# If you delete this file, it will be regenerated with the default handlers list.
|
||||
appeng.client.gui.implementations.GuiPatternTerm
|
||||
appeng.client.gui.implementations.GuiPatternTermEx
|
||||
|
||||
@@ -47,6 +47,7 @@ nei.bookmark.crafting_chain.input=Ingredients
|
||||
nei.bookmark.crafting_chain.missing=Missing Items
|
||||
nei.bookmark.crafting_chain.output=Results
|
||||
nei.bookmark.crafting_chain.remainder=Remainders
|
||||
nei.bookmark.crafting_chain.needed=Required Crafts
|
||||
nei.bookmark.crafting_chain.available=Available Items
|
||||
nei.inventory.search.placeholder=Search...
|
||||
nei.itempanel.quantity.default=One stack
|
||||
@@ -247,6 +248,9 @@ nei.options.inventory.bookmarks.worldSpecific.false=No
|
||||
nei.options.inventory.bookmarks.bookmarkItemsWithRecipe=Bookmark items with recipe
|
||||
nei.options.inventory.bookmarks.bookmarkItemsWithRecipe.true=Yes
|
||||
nei.options.inventory.bookmarks.bookmarkItemsWithRecipe.false=No
|
||||
nei.options.inventory.bookmarks.bookmarkRecipeWithCount=Bookmark recipe with count
|
||||
nei.options.inventory.bookmarks.bookmarkRecipeWithCount.true=Yes
|
||||
nei.options.inventory.bookmarks.bookmarkRecipeWithCount.false=No
|
||||
nei.options.inventory.favorites=Favorites
|
||||
nei.options.inventory.favorites.enabled=Visibility
|
||||
nei.options.inventory.favorites.enabled.true=Visible
|
||||
@@ -282,12 +286,14 @@ nei.options.inventory.guirecipe.infiniteScroll=Use Infinite Scroll
|
||||
nei.options.inventory.guirecipe.infiniteScroll.true=Yes
|
||||
nei.options.inventory.guirecipe.infiniteScroll.false=No
|
||||
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst=JEI Style Recipe Catalysts
|
||||
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.true=Yes
|
||||
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.false=No
|
||||
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.0=None
|
||||
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.1=Grid
|
||||
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.2=Scroll
|
||||
nei.options.inventory.guirecipe.cycledIngredientsTooltip=Cycled Ingredients Tooltip
|
||||
nei.options.inventory.guirecipe.cycledIngredientsTooltip.true=Show
|
||||
nei.options.inventory.guirecipe.cycledIngredientsTooltip.false=Hide
|
||||
nei.options.inventory.guirecipe.handlerInfo=Handler Info Widget
|
||||
nei.options.inventory.guirecipe.handlerInfo.tip=Use shift+d while in the Recipes GUI
|
||||
nei.options.inventory.guirecipe.handlerInfo.true=Enabled
|
||||
nei.options.inventory.guirecipe.handlerInfo.false=Disabled
|
||||
nei.options.inventory.guirecipe.maxHeight=Max Height
|
||||
@@ -417,6 +423,9 @@ nei.options.inventory.craftables.enabled.true=Enabled
|
||||
nei.options.inventory.craftables.enabled.false=Disabled
|
||||
nei.options.inventory.craftables.color=Color
|
||||
nei.options.inventory.craftables.useRows=Rows
|
||||
nei.options.inventory.craftables.favoritesOnly=Show Favorites Only
|
||||
nei.options.inventory.craftables.favoritesOnly.true=Yes
|
||||
nei.options.inventory.craftables.favoritesOnly.false=No
|
||||
nei.options.inventory.subsets=Subsets Widget
|
||||
nei.options.inventory.subsets.enabled=Subsets Visibility
|
||||
nei.options.inventory.subsets.enabled.true=Enabled
|
||||
@@ -594,6 +603,7 @@ nei.subsets.Items.Tools.Shovels=Shovels
|
||||
nei.subsets.Items.Weapons=Weapons
|
||||
nei.subsets.Items.Weapons.Ranged=Ranged
|
||||
nei.subsets.Items.Weapons.Swords=Swords
|
||||
nei.subsets.Untranslated=Untranslated
|
||||
nei.subsets.Mod=Mod
|
||||
|
||||
nei.presets.new=New Preset
|
||||
|
||||
@@ -199,8 +199,9 @@ nei.options.inventory.guirecipe.slotHighlightPresent=Подсвечивать п
|
||||
nei.options.inventory.guirecipe.slotHighlightPresent.true=Да
|
||||
nei.options.inventory.guirecipe.slotHighlightPresent.false=Нет
|
||||
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst=Катализаторы рецептов в стиле JEI
|
||||
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.true=Да
|
||||
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.false=Нет
|
||||
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.0=Нет
|
||||
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.1=Грид
|
||||
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.2=Скролл
|
||||
nei.options.inventory.guirecipe.cycledIngredientsTooltip=Подсказка циклических ингредиентов
|
||||
nei.options.inventory.guirecipe.cycledIngredientsTooltip.true=Показывать
|
||||
nei.options.inventory.guirecipe.cycledIngredientsTooltip.false=Скрыть
|
||||
|
||||
@@ -136,8 +136,6 @@ nei.options.inventory.guirecipe.jeiStyleTabs=JEI标签页
|
||||
nei.options.inventory.guirecipe.jeiStyleTabs.true=是
|
||||
nei.options.inventory.guirecipe.jeiStyleTabs.false=否 [不会吧]
|
||||
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst=JEI风格可执行合成表机器显示[测试中]
|
||||
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.true=是
|
||||
nei.options.inventory.guirecipe.jeiStyleRecipeCatalyst.false=否
|
||||
nei.options.inventory.bookmarks.animation=REI风格书签动画
|
||||
nei.options.inventory.bookmarks.animation.true=是
|
||||
nei.options.inventory.bookmarks.animation.false=否
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.2 KiB |
Reference in new issue
Block a user