Compare commits

...
Author SHA1 Message Date
asdflj 4b247d08a5 add more api (#352) 2023-02-15 11:55:16 +01:00
Midnight145 8ecc8f20d5 add legacy handlers for botania,neiplugins (#349)
* add missing handlers for Blightfall

* update gitignore

* remove trailing commas

* add fluid registry handler

* readd missing quotes
2023-02-13 16:41:32 +00:00
miozune 74b9f8339a Require shift by default for moving items with overlaying recipe (#351) 2023-02-13 07:26:28 +01:00
miozune e20756a196 Don't require holding shift to move items when overlaying recipe (#348)
* updateBuildScript

* Remove redundant public modifier

* Don't require holding shift to move items when overlaying recipe
2023-02-09 11:21:30 +01:00
miozune 6d0f83c499 Make recipe query load all the uncrashed handlers instead of all-or-nothing if one of the handlers crashed (#347)
* Make recipe query load all the uncrashed handlers instead of all-or-nothing if one of the handlers crashed

* better error handling
2023-02-08 08:54:43 +01:00
miozune 8e219c06be Add JEI styled cycle ingredients (#346) 2023-02-05 16:57:09 +01:00
miozune 3fc576b6fc Add more error message for crash with recipe lookup (#345) 2023-02-05 11:27:52 +01:00
miozune 249cb2b308 Allow using hash for tooltip pagination keybind (#344) 2023-02-04 10:35:36 +01:00
miozune e8d8c1994b Add tooltip pagination (#343) 2023-02-03 15:35:03 +01:00
17 changed files with 386 additions and 55 deletions

No files matched your search

+1
View File
@@ -27,3 +27,4 @@ whitelist.json
*.iws
src/main/resources/mixins.*.json
*.bat
.DS_Store
+167 -6
View File
@@ -1,4 +1,4 @@
//version: 1675173326
//version: 1675859611
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
@@ -10,10 +10,13 @@ import com.diffplug.blowdryer.Blowdryer
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.gtnewhorizons.retrofuturagradle.mcp.ReobfuscatedJar
import com.gtnewhorizons.retrofuturagradle.minecraft.RunMinecraftTask
import com.matthewprenger.cursegradle.CurseArtifact
import com.matthewprenger.cursegradle.CurseRelation
import com.modrinth.minotaur.dependencies.ModDependency
import com.modrinth.minotaur.dependencies.VersionDependency
import cpw.mods.fml.relauncher.Side
import org.gradle.api.tasks.options.Option;
import org.gradle.internal.logging.text.StyledTextOutput.Style
import org.gradle.internal.logging.text.StyledTextOutputFactory
import org.jetbrains.gradle.ext.*
@@ -23,6 +26,7 @@ import java.nio.file.Paths
import java.util.concurrent.TimeUnit
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream
import javax.inject.Inject
buildscript {
repositories {
@@ -66,7 +70,7 @@ plugins {
id 'com.diffplug.spotless' version '6.7.2' apply false
id 'com.modrinth.minotaur' version '2.+' apply false
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
id 'com.gtnewhorizons.retrofuturagradle' version '1.1.3'
id 'com.gtnewhorizons.retrofuturagradle' version '1.1.5'
}
boolean settingsupdated = verifySettingsGradle()
settingsupdated = verifyGitAttributes() || settingsupdated
@@ -186,11 +190,21 @@ configurations {
}
if (enableModernJavaSyntax.toBoolean()) {
repositories {
mavenCentral {
mavenContent {
includeGroup("me.eigenraven.java8unsupported")
}
}
}
dependencies {
annotationProcessor 'com.github.bsideup.jabel:jabel-javac-plugin:1.0.0'
compileOnly('com.github.bsideup.jabel:jabel-javac-plugin:1.0.0') {
transitive = false // We only care about the 1 annotation class
}
// Allow using jdk.unsupported classes like sun.misc.Unsafe in the compiled code, working around JDK-8206937.
patchedMinecraft('me.eigenraven.java8unsupported:java-8-unsupported-shim:1.0.0')
}
tasks.withType(JavaCompile).configureEach {
@@ -520,20 +534,20 @@ dependencies {
annotationProcessor('org.ow2.asm:asm-debug-all:5.0.3')
annotationProcessor('com.google.guava:guava:24.1.1-jre')
annotationProcessor('com.google.code.gson:gson:2.8.6')
annotationProcessor('com.gtnewhorizon:gtnhmixins:2.1.10:processor')
annotationProcessor('com.gtnewhorizon:gtnhmixins:2.1.12:processor')
if (usesMixinDebug.toBoolean()) {
runtimeOnlyNonPublishable('org.jetbrains:intellij-fernflower:1.2.1.16')
}
}
if (usesMixins.toBoolean() || forceEnableMixins.toBoolean()) {
implementation('com.gtnewhorizon:gtnhmixins:2.1.10')
implementation('com.gtnewhorizon:gtnhmixins:2.1.12')
}
}
pluginManager.withPlugin('org.jetbrains.kotlin.kapt') {
if (usesMixins.toBoolean()) {
dependencies {
kapt('com.gtnewhorizon:gtnhmixins:2.1.10:processor')
kapt('com.gtnewhorizon:gtnhmixins:2.1.12:processor')
}
}
}
@@ -633,9 +647,142 @@ tasks.named("processResources", ProcessResources).configure {
if (usesMixins.toBoolean()) {
from refMap
dependsOn("compileJava", "compileScala")
}
}
ext.java17Toolchain = (JavaToolchainSpec spec) -> {
spec.languageVersion.set(JavaLanguageVersion.of(17))
spec.vendor.set(JvmVendorSpec.matching("jetbrains"))
}
ext.java17DependenciesCfg = configurations.create("java17Dependencies")
ext.java17PatchDependenciesCfg = configurations.create("java17PatchDependencies")
dependencies {
def lwjgl3ifyVersion = '1.1.21'
def asmVersion = '9.4'
if (modId != 'lwjgl3ify') {
java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}")
}
if (modId != 'hodgepodge') {
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.0.31')
}
java17PatchDependencies('net.minecraft:launchwrapper:1.15') {transitive = false}
java17PatchDependencies("org.ow2.asm:asm:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-commons:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-tree:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-analysis:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-util:${asmVersion}")
java17PatchDependencies('org.ow2.asm:asm-deprecated:7.1')
java17PatchDependencies("org.apache.commons:commons-lang3:3.12.0")
java17PatchDependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}:forgePatches")
}
ext.java17JvmArgs = [
// Java 9+ support
"--illegal-access=warn",
"-Dfile.encoding=UTF-8",
"-Djava.security.manager=allow",
"--add-opens", "java.base/jdk.internal.loader=ALL-UNNAMED",
"--add-opens", "java.base/java.net=ALL-UNNAMED",
"--add-opens", "java.base/java.nio=ALL-UNNAMED",
"--add-opens", "java.base/java.io=ALL-UNNAMED",
"--add-opens", "java.base/java.lang=ALL-UNNAMED",
"--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED",
"--add-opens", "java.base/java.text=ALL-UNNAMED",
"--add-opens", "java.base/java.util=ALL-UNNAMED",
"--add-opens", "java.base/jdk.internal.reflect=ALL-UNNAMED",
"--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED",
"--add-opens", "java.desktop/sun.awt.image=ALL-UNNAMED",
"--add-modules", "jdk.dynalink",
"--add-opens", "jdk.dynalink/jdk.dynalink.beans=ALL-UNNAMED",
"--add-modules", "java.sql.rowset",
"--add-opens", "java.sql.rowset/javax.sql.rowset.serial=ALL-UNNAMED"
]
ext.hotswapJvmArgs = [
// DCEVM advanced hot reload
"-XX:+AllowEnhancedClassRedefinition",
"-XX:HotswapAgent=fatjar"
]
ext.setupHotswapAgentTask = tasks.register("setupHotswapAgent") {
group = "GTNH Buildscript"
description = "Installs a recent version of HotSwapAgent into the Java 17 JetBrains runtime directory"
def hsaUrl = 'https://github.com/HotswapProjects/HotswapAgent/releases/download/1.4.2-SNAPSHOT/hotswap-agent-1.4.2-SNAPSHOT.jar'
def targetFolderProvider = javaToolchains.launcherFor(java17Toolchain).map {it.metadata.installationPath.dir("lib/hotswap")}
def targetFilename = "hotswap-agent.jar"
onlyIf {
!targetFolderProvider.get().file(targetFilename).asFile.exists()
}
doLast {
def targetFolder = targetFolderProvider.get()
targetFolder.asFile.mkdirs()
download.run {
src hsaUrl
dest targetFolder.file(targetFilename).asFile
overwrite false
tempAndMove true
}
}
}
public abstract class RunHotswappableMinecraftTask extends RunMinecraftTask {
// IntelliJ doesn't seem to allow commandline arguments so we also support an env variable
private boolean enableHotswap = Boolean.valueOf(System.getenv("HOTSWAP"));
@Input
public boolean getEnableHotswap() { return enableHotswap }
@Option(option = "hotswap", description = "Enables HotSwapAgent for enhanced class reloading under a debugger")
public boolean setEnableHotswap(boolean enable) { enableHotswap = enable }
@Inject
public RunHotswappableMinecraftTask(Side side, String superTask) {
super(side)
this.lwjglVersion = 3
this.javaLauncher = project.javaToolchains.launcherFor(project.java17Toolchain)
this.extraJvmArgs.addAll(project.java17JvmArgs)
this.extraJvmArgs.addAll(project.provider(() -> enableHotswap ? project.hotswapJvmArgs : []))
this.classpath(project.java17PatchDependenciesCfg)
if (side == Side.CLIENT) {
this.classpath(project.minecraftTasks.lwjgl3Configuration)
}
// Use a raw provider instead of map to not create a dependency on the task
this.classpath(project.provider(() -> project.tasks.named(superTask, RunMinecraftTask).get().classpath))
this.classpath.filter { file ->
!file.path.contains("2.9.4-nightly-20150209") // Remove lwjgl2
}
this.classpath(project.java17DependenciesCfg)
if (!(project.usesMixins.toBoolean() || project.forceEnableMixins.toBoolean())) {
this.extraArgs.addAll("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker")
}
}
}
def runClient17Task = tasks.register("runClient17", RunHotswappableMinecraftTask, Side.CLIENT, "runClient")
runClient17Task.configure {
setup(project)
group = "Modded Minecraft"
description = "Runs the modded client using Java 17, lwjgl3ify and Hodgepodge"
dependsOn(setupHotswapAgentTask, mcpTasks.launcherSources.classesTaskName, minecraftTasks.taskDownloadVanillaAssets, mcpTasks.taskPackagePatchedMc, 'jar')
mainClass = "GradleStart"
}
def runServer17Task = tasks.register("runServer17", RunHotswappableMinecraftTask, Side.SERVER, "runServer")
runServer17Task.configure {
setup(project)
group = "Modded Minecraft"
description = "Runs the modded server using Java 17, lwjgl3ify and Hodgepodge"
dependsOn(setupHotswapAgentTask, mcpTasks.launcherSources.classesTaskName, minecraftTasks.taskDownloadVanillaAssets, mcpTasks.taskPackagePatchedMc, 'jar')
mainClass = "GradleStartServer"
extraArgs.add("nogui")
}
def getManifestAttributes() {
def manifestAttributes = [:]
if (!containsMixinsAndOrCoreModOnly.toBoolean() && (usesMixins.toBoolean() || coreModClass)) {
@@ -705,7 +852,7 @@ if (usesShadowedDependencies.toBoolean()) {
javaComponent.withVariantsFromConfiguration(configurations.shadowRuntimeElements) {
skip()
}
for (runTask in ["runClient", "runServer"]) {
for (runTask in ["runClient", "runServer", "runClient17", "runServer17"]) {
tasks.named(runTask).configure {
dependsOn("shadowJar")
}
@@ -754,6 +901,20 @@ idea {
"2. Run Server"(Gradle) {
taskNames = ["runServer"]
}
"1a. Run Client (Java 17)"(Gradle) {
taskNames = ["runClient17"]
}
"2a. Run Server (Java 17)"(Gradle) {
taskNames = ["runServer17"]
}
"1b. Run Client (Java 17, Hotswap)"(Gradle) {
taskNames = ["runClient17"]
envs = ["HOTSWAP": "true"]
}
"2b. Run Server (Java 17, Hotswap)"(Gradle) {
taskNames = ["runServer17"]
envs = ["HOTSWAP": "true"]
}
"3. Run Obfuscated Client"(Gradle) {
taskNames = ["runObfClient"]
}
@@ -221,6 +221,11 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
return true;
}
if (NEIClientConfig.isKeyHashDown("gui.next_tooltip")) {
GuiContainerManager.incrementTooltipPage();
return true;
}
if (isEnabled() && !isHidden()) {
for (Widget widget : controlWidgets) if (inputFocused == null) widget.lastKeyTyped(keyID, keyChar);
}
@@ -267,6 +267,14 @@ public class NEIClientConfig {
.getBooleanValue(false);
API.addOption(new OptionToggleButton("inventory.optimize_gui_overlap_computation", true));
tag.getTag("inventory.jei_style_cycled_ingredients").setComment("JEI styled cycled ingredients")
.getBooleanValue(true);
API.addOption(new OptionToggleButton("inventory.jei_style_cycled_ingredients", true));
tag.getTag("inventory.shift_overlay_recipe")
.setComment("Require holding shift to move items when overlaying recipe").getBooleanValue(true);
API.addOption(new OptionToggleButton("inventory.shift_overlay_recipe", true));
tag.getTag("tools.handler_load_from_config").setComment("ADVANCED: Load handlers from config")
.getBooleanValue(false);
API.addOption(new OptionToggleButton("tools.handler_load_from_config", true) {
@@ -345,6 +353,7 @@ public class NEIClientConfig {
API.addHashBind("gui.hide_bookmarks", Keyboard.KEY_B);
API.addKeyBind("gui.getprevioussearch", Keyboard.KEY_UP);
API.addKeyBind("gui.getnextsearch", Keyboard.KEY_DOWN);
API.addHashBind("gui.next_tooltip", Keyboard.KEY_Z);
API.addKeyBind("world.chunkoverlay", Keyboard.KEY_F9);
API.addKeyBind("world.moboverlay", Keyboard.KEY_F7);
@@ -420,6 +429,36 @@ public class NEIClientConfig {
return hash != Keyboard.CHAR_NONE && hash == NEIClientUtils.getKeyHash();
}
public static String getKeyName(int keyBind, boolean useHash) {
return getKeyName(keyBind, useHash, false);
}
public static String getKeyName(int keyBind, boolean useHash, boolean showOnlyHash) {
String keyText = "";
if (useHash) {
final String DELIMITER = " + ";
if ((keyBind & NEIClientUtils.CTRL_HASH) != 0) {
keyText += NEIClientUtils.translate(Minecraft.isRunningOnMac ? "key.ctrl.mac" : "key.ctrl") + DELIMITER;
}
if ((keyBind & NEIClientUtils.SHIFT_HASH) != 0) {
keyText += "SHIFT" + DELIMITER;
}
if ((keyBind & NEIClientUtils.ALT_HASH) != 0) {
keyText += "ALT" + DELIMITER;
}
}
if (!showOnlyHash) {
keyText += Keyboard.getKeyName(unHashKey(keyBind));
}
return keyText;
}
public static int unHashKey(int keyBind) {
return keyBind & ~(NEIClientUtils.CTRL_HASH | NEIClientUtils.SHIFT_HASH | NEIClientUtils.ALT_HASH);
}
public static void bootNEI(World world) {
if (configLoaded) return;
@@ -539,6 +578,14 @@ public class NEIClientConfig {
return getBooleanSetting("inventory.optimize_gui_overlap_computation");
}
public static boolean useJEIStyledCycledIngredients() {
return getBooleanSetting("inventory.jei_style_cycled_ingredients");
}
public static boolean requireShiftForOverlayRecipe() {
return getBooleanSetting("inventory.shift_overlay_recipe");
}
public static boolean isEnabled() {
return enabledOverride && getBooleanSetting("inventory.widgetsenabled");
}
@@ -107,6 +107,14 @@ public class API {
RecipeInfo.registerOverlayHandler(classz, handler, ident);
}
/**
* @param classz The class of your gui
* @param ident The recipe identification string
*/
public static boolean hasGuiOverlayHandler(Class<? extends GuiContainer> classz, String ident) {
return RecipeInfo.hasOverlayHandler(classz, ident);
}
/**
* Set the offset to be added to items to translate them into recipe coords on the actual gui, default is 5, 11.
* Primarily RecipeTransferRects
@@ -6,5 +6,5 @@ import codechicken.nei.recipe.IRecipeHandler;
public interface IOverlayHandler {
public void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean shift);
void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean shift);
}
@@ -5,11 +5,9 @@ import static codechicken.lib.gui.GuiDraw.drawStringC;
import java.awt.Rectangle;
import net.minecraft.client.Minecraft;
import net.minecraft.util.EnumChatFormatting;
import org.lwjgl.input.Keyboard;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.NEIClientUtils;
public class OptionKeyBind extends OptionButton {
@@ -124,31 +122,8 @@ public class OptionKeyBind extends OptionButton {
@Override
public String getButtonText() {
String keyText = "";
if (useHash) {
final int metahash = Math.max(editing ? NEIClientUtils.getMetaHash() : getValue(), 0);
final String DELIMITER = EnumChatFormatting.GRAY + " + " + EnumChatFormatting.RESET;
if ((metahash & NEIClientUtils.CTRL_HASH) == NEIClientUtils.CTRL_HASH) {
keyText += NEIClientUtils.translate(Minecraft.isRunningOnMac ? "key.ctrl.mac" : "key.ctrl") + DELIMITER;
}
if ((metahash & NEIClientUtils.SHIFT_HASH) == NEIClientUtils.SHIFT_HASH) {
keyText += "SHIFT" + DELIMITER;
}
if ((metahash & NEIClientUtils.ALT_HASH) == NEIClientUtils.ALT_HASH) {
keyText += "ALT" + DELIMITER;
}
}
if (!editing) {
keyText += Keyboard.getKeyName(
getValue() & ~(NEIClientUtils.CTRL_HASH | NEIClientUtils.SHIFT_HASH | NEIClientUtils.ALT_HASH));
}
return keyText;
final int metahash = Math.max(editing ? NEIClientUtils.getMetaHash() : getValue(), 0);
return NEIClientConfig.getKeyName(metahash, useHash, editing);
}
@Override
@@ -5,7 +5,7 @@ import static codechicken.lib.gui.GuiDraw.fontRenderer;
import static codechicken.lib.gui.GuiDraw.getMousePosition;
import static codechicken.lib.gui.GuiDraw.renderEngine;
import java.awt.Point;
import java.awt.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
@@ -32,6 +32,7 @@ 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.recipe.StackInfo;
@@ -497,7 +498,49 @@ public class GuiContainerManager {
if (tooltip.size() > 0) tooltip.set(0, tooltip.get(0) + GuiDraw.TOOLTIP_LINESPACE); // add space after 'title'
drawMultilineTip(font, mousex + 12, mousey - 12, tooltip);
drawPagedTooltip(font, mousex + 12, mousey - 12, tooltip);
}
private static int tooltipPage;
public static void drawPagedTooltip(FontRenderer font, int x, int y, List<String> list) {
if (list.isEmpty()) return;
List<List<String>> tooltips = splitTooltipByPage(list);
tooltipPage = tooltipPage < tooltips.size() ? tooltipPage : 0;
if (tooltips.size() > 1) {
tooltips.get(tooltipPage).add(
EnumChatFormatting.ITALIC + NEIClientUtils.translate(
"inventory.tooltip.page",
tooltipPage + 1,
tooltips.size(),
NEIClientConfig.getKeyName(NEIClientConfig.getKeyBinding("gui.next_tooltip"), true)));
}
drawMultilineTip(font, x, y, tooltips.get(tooltipPage));
}
public static List<List<String>> splitTooltipByPage(List<String> list) {
List<List<String>> ret = new ArrayList<>();
List<String> tmp = new ArrayList<>();
int height = -2;
for (int i = 0; i < list.size(); i++) {
String text = list.get(i);
GuiDraw.ITooltipLineHandler line = GuiDraw.getTipLine(text);
int lineHeight = line != null ? line.getSize().height
: text.endsWith(GuiDraw.TOOLTIP_LINESPACE) && i + 1 < list.size() ? 12 : 10;
if (height + lineHeight <= GuiDraw.displaySize().height - 8 * 2 - 10) {
// top & bottom 8px + last line for showing page
height += lineHeight;
} else {
ret.add(new ArrayList<>(tmp));
tmp.clear();
height = -2;
}
tmp.add(text);
}
if (!tmp.isEmpty()) {
ret.add(tmp);
}
return ret;
}
public static boolean shouldShowTooltip(GuiContainer window) {
@@ -516,6 +559,10 @@ public class GuiContainerManager {
}
}
public static void incrementTooltipPage() {
tooltipPage++;
}
public void renderSlotUnderlay(Slot slot) {
for (IContainerDrawHandler drawHandler : drawHandlers) drawHandler.renderSlotUnderlay(window, slot);
}
@@ -4,6 +4,7 @@ import static codechicken.lib.gui.GuiDraw.getMousePosition;
import java.awt.Point;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.minecraft.client.Minecraft;
@@ -38,7 +39,10 @@ public class GuiCraftingRecipe extends GuiRecipe<ICraftingHandler> {
final RecipeHandlerQuery<ICraftingHandler> recipeQuery = new RecipeHandlerQuery<>(
h -> h.getRecipeHandler(outputId, results),
craftinghandlers,
serialCraftingHandlers);
serialCraftingHandlers,
"Error while looking up crafting recipe",
"outputId: " + outputId,
"results: " + Arrays.toString(results));
final ArrayList<ICraftingHandler> handlers = recipeQuery.runWithProfiling("recipe.concurrent.crafting");
@@ -471,6 +471,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
}
protected void overlayRecipe(int recipe, final boolean shift) {
boolean moveItems = shift || !NEIClientConfig.requireShiftForOverlayRecipe();
if (handler == null || !handler.hasOverlay(firstGui, firstGui.inventorySlots, recipe)) {
mc.displayGuiScreen(firstGui);
return;
@@ -479,8 +480,8 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
final IOverlayHandler overlayHandler = handler.getOverlayHandler(firstGui, recipe);
mc.displayGuiScreen(firstGui);
if (renderer == null || shift) {
overlayHandler.overlayRecipe(firstGui, currenthandlers.get(recipetype), recipe, shift);
if (renderer == null || moveItems) {
overlayHandler.overlayRecipe(firstGui, currenthandlers.get(recipetype), recipe, moveItems);
} else {
LayoutManager.overlayRenderer = renderer;
}
@@ -1,6 +1,7 @@
package codechicken.nei.recipe;
import java.util.ArrayList;
import java.util.Arrays;
import net.minecraft.client.Minecraft;
@@ -16,7 +17,10 @@ public class GuiUsageRecipe extends GuiRecipe<IUsageHandler> {
RecipeHandlerQuery<IUsageHandler> recipeQuery = new RecipeHandlerQuery<>(
h -> getUsageOrCatalystHandler(h, inputId, ingredients),
usagehandlers,
serialUsageHandlers);
serialUsageHandlers,
"Error while looking up usage recipe",
"inputId: " + inputId,
"ingredients: " + Arrays.toString(ingredients));
ArrayList<IUsageHandler> handlers = recipeQuery.runWithProfiling("recipe.concurrent.usage");
if (handlers.isEmpty()) return false;
@@ -21,20 +21,29 @@ class RecipeHandlerQuery<T extends IRecipeHandler> {
private final Function<T, T> recipeHandlerFunction;
private final List<T> recipeHandlers;
private final List<T> serialRecipeHandlers;
private final String[] errorMessage;
private boolean error = false;
RecipeHandlerQuery(Function<T, T> recipeHandlerFunction, List<T> recipeHandlers, List<T> serialRecipeHandlers) {
RecipeHandlerQuery(Function<T, T> recipeHandlerFunction, List<T> recipeHandlers, List<T> serialRecipeHandlers,
String... errorMessage) {
this.recipeHandlerFunction = recipeHandlerFunction;
this.recipeHandlers = recipeHandlers;
this.serialRecipeHandlers = serialRecipeHandlers;
this.errorMessage = errorMessage;
}
ArrayList<T> runWithProfiling(String profilerSection) {
TaskProfiler profiler = ProfilerRecipeHandler.getProfiler();
profiler.start(profilerSection);
try {
return getRecipeHandlersParallel();
ArrayList<T> handlers = getRecipeHandlersParallel();
if (error) {
displayRecipeLookupError();
}
return handlers;
} catch (InterruptedException | ExecutionException e) {
displayRecipeLookupError(e);
printLog(e);
displayRecipeLookupError();
return new ArrayList<>(0);
} finally {
profiler.end();
@@ -51,19 +60,37 @@ class RecipeHandlerQuery<T extends IRecipeHandler> {
}
private ArrayList<T> getSerialHandlersWithRecipes() {
return serialRecipeHandlers.stream().map(recipeHandlerFunction).filter(h -> h.numRecipes() > 0)
.collect(Collectors.toCollection(ArrayList::new));
return serialRecipeHandlers.stream().map(handler -> {
try {
return recipeHandlerFunction.apply(handler);
} catch (Throwable t) {
printLog(t);
error = true;
return null;
}
}).filter(h -> h != null && h.numRecipes() > 0).collect(Collectors.toCollection(ArrayList::new));
}
private ArrayList<T> getHandlersWithRecipes() throws InterruptedException, ExecutionException {
return ItemList.forkJoinPool.submit(
() -> recipeHandlers.parallelStream().map(recipeHandlerFunction).filter(h -> h.numRecipes() > 0)
.collect(Collectors.toCollection(ArrayList::new)))
.get();
return ItemList.forkJoinPool.submit(() -> recipeHandlers.parallelStream().map(handler -> {
try {
return recipeHandlerFunction.apply(handler);
} catch (Throwable t) {
printLog(t);
error = true;
return null;
}
}).filter(h -> h != null && h.numRecipes() > 0).collect(Collectors.toCollection(ArrayList::new))).get();
}
private static void displayRecipeLookupError(Exception e) {
e.printStackTrace();
private void printLog(Throwable t) {
for (String message : errorMessage) {
NEIClientConfig.logger.error(message);
}
t.printStackTrace();
}
private void displayRecipeLookupError() {
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if (player != null) {
IChatComponent chat = new ChatComponentTranslation("nei.chat.recipe.error");
@@ -70,6 +70,10 @@ public class RecipeInfo {
return overlayMap.containsKey(new OverlayKey(gui.getClass(), ident));
}
public static boolean hasOverlayHandler(Class<? extends GuiContainer> classz, String ident) {
return overlayMap.containsKey(new OverlayKey(classz, ident));
}
public static IOverlayHandler getOverlayHandler(GuiContainer gui, String ident) {
return overlayMap.get(new OverlayKey(gui.getClass(), ident));
}
@@ -182,8 +182,12 @@ public abstract class TemplateRecipeHandler implements ICraftingHandler, IUsageH
public List<PositionedStack> getCycledIngredients(int cycle, List<PositionedStack> ingredients) {
if (!NEIClientUtils.shiftKey()) {
for (int itemIndex = 0; itemIndex < ingredients.size(); itemIndex++) {
randomRenderPermutation(ingredients.get(itemIndex), cycle + itemIndex);
if (NEIClientConfig.useJEIStyledCycledIngredients()) {
jeiStyledRenderPermutation(ingredients, cycle);
} else {
for (int itemIndex = 0; itemIndex < ingredients.size(); itemIndex++) {
randomRenderPermutation(ingredients.get(itemIndex), cycle + itemIndex);
}
}
}
@@ -195,6 +199,12 @@ public abstract class TemplateRecipeHandler implements ICraftingHandler, IUsageH
stack.setPermutationToRender(Math.abs(rand.nextInt()) % stack.items.length);
}
public void jeiStyledRenderPermutation(List<PositionedStack> stacks, long cycle) {
for (PositionedStack stack : stacks) {
stack.setPermutationToRender((int) (cycle % stack.items.length));
}
}
public void setIngredientPermutation(Collection<PositionedStack> ingredients, ItemStack ingredient) {
for (PositionedStack stack : ingredients) {
for (int i = 0; i < stack.items.length; i++) {
@@ -1343,6 +1343,25 @@ tonius.neiintegration.mods.minefactoryreloaded.RecipeHandlerSewer,MineFactoryRel
tonius.neiintegration.mods.minefactoryreloaded.RecipeHandlerGrinder,MineFactoryReloaded:machine.0:13,,MineFactoryReloaded,TRUE,,,,,,
tonius.neiintegration.mods.minefactoryreloaded.RecipeHandlerBioReactor,MineFactoryReloaded:machine.1:10,,MineFactoryReloaded,TRUE,,,,,,
tonius.neiintegration.mods.minefactoryreloaded.RecipeHandlerSlaughterhouse,MineFactoryReloaded:machine.1:13,,MineFactoryReloaded,TRUE,,,,,,
de.ellpeck.actuallyadditions.mod.nei.NEIBookletRecipe,ActuallyAdditions:itemBooklet,,ActuallyAdditions,TRUE,,,,,,
de.ellpeck.actuallyadditions.mod.nei.NEIHairyBallRecipe,ActuallyAdditions:itemHairyBall,,ActuallyAdditions,TRUE,,,,,,
de.ellpeck.actuallyadditions.mod.nei.NEICrusherRecipe$Double,ActuallyAdditions:blockGrinderDouble,,ActuallyAdditions,TRUE,,,,,,
de.ellpeck.actuallyadditions.mod.nei.NEICrusherRecipe,ActuallyAdditions:blockGrinder,,ActuallyAdditions,TRUE,,,,,,
de.ellpeck.actuallyadditions.mod.nei.NEIFurnaceDoubleRecipe,ActuallyAdditions:blockFurnaceDouble,,ActuallyAdditions,TRUE,,,,,,
de.ellpeck.actuallyadditions.mod.nei.NEICoffeeMachineRecipe,ActuallyAdditions:blockCoffeeMachine,,ActuallyAdditions,TRUE,,,,,,
de.ellpeck.actuallyadditions.mod.nei.NEICompostRecipe,ActuallyAdditions:blockCompost,,ActuallyAdditions,TRUE,,,,,,
de.ellpeck.actuallyadditions.mod.nei.NEIReconstructorRecipe,ActuallyAdditions:blockAtomicReconstructor,,ActuallyAdditions,TRUE,,,,,,
de.ellpeck.actuallyadditions.mod.nei.NEITreasureChestRecipe,ActuallyAdditions:blockTreasureChest,,ActuallyAdditions,TRUE,,,,,,
vazkii.botania.client.integration.nei.RecipeHandlerFloatingFlowers,Botania:miniIsland,,Botania,TRUE,,,,,,
vazkii.botania.client.integration.nei.RecipeHandlerPetalApothecary,Botania:altar,,Botania,TRUE,,,,,,
vazkii.botania.client.integration.nei.RecipeHandlerRunicAltar,Botania:runeAltar,,Botania,TRUE,,,,,,
vazkii.botania.client.integration.nei.RecipeHandlerManaPool,Botania:pool,,Botania,TRUE,,,,,,
vazkii.botania.client.integration.nei.RecipeHandlerElvenTrade,Botania:alfheimPortal,,Botania,TRUE,,,,,,
vazkii.botania.client.integration.nei.RecipeHandlerBrewery,Botania:brewery,,Botania,TRUE,,,,,,
vazkii.botania.client.integration.nei.RecipeHandlerPureDaisy,Botania:specialFlower,"{type:puredaisy}",Botania,TRUE,,,,,,
vazkii.botania.client.integration.nei.RecipeHandlerLexicaBotania,Botania:lexicon,,Botania,TRUE,,,,,,
neiplugins.forge.OreDictionaryList,minecraft:book,,NEIPlugins,TRUE,,,,,,
neiplugins.forge.FluidRegistryList,minecraft:bucket,,NEIPlugins,TRUE,,,,,,
de.ellpeck.actuallyadditions.mod.nei.NEIBookletRecipe,ActuallyAdditions:itemBooklet,,ActuallyAdditions,TRUE,,,,,,,,,,,
de.ellpeck.actuallyadditions.mod.nei.NEIHairyBallRecipe,ActuallyAdditions:itemHairyBall,,ActuallyAdditions,TRUE,,,,,,,,,,,
de.ellpeck.actuallyadditions.mod.nei.NEICrusherRecipe$Double,ActuallyAdditions:blockGrinderDouble,,ActuallyAdditions,TRUE,,,,,,,,,,,
1 handler itemName nbtInfo modId modRequired excludedModId priority minVersion maxVersion forceClassName itemNotes
1343 tonius.neiintegration.mods.minefactoryreloaded.RecipeHandlerGrinder MineFactoryReloaded:machine.0:13 MineFactoryReloaded TRUE
1344 tonius.neiintegration.mods.minefactoryreloaded.RecipeHandlerBioReactor MineFactoryReloaded:machine.1:10 MineFactoryReloaded TRUE
1345 tonius.neiintegration.mods.minefactoryreloaded.RecipeHandlerSlaughterhouse MineFactoryReloaded:machine.1:13 MineFactoryReloaded TRUE
1346 de.ellpeck.actuallyadditions.mod.nei.NEIBookletRecipe ActuallyAdditions:itemBooklet ActuallyAdditions TRUE
1347 de.ellpeck.actuallyadditions.mod.nei.NEIHairyBallRecipe ActuallyAdditions:itemHairyBall ActuallyAdditions TRUE
1348 de.ellpeck.actuallyadditions.mod.nei.NEICrusherRecipe$Double ActuallyAdditions:blockGrinderDouble ActuallyAdditions TRUE
1349 de.ellpeck.actuallyadditions.mod.nei.NEICrusherRecipe ActuallyAdditions:blockGrinder ActuallyAdditions TRUE
1350 de.ellpeck.actuallyadditions.mod.nei.NEIFurnaceDoubleRecipe ActuallyAdditions:blockFurnaceDouble ActuallyAdditions TRUE
1351 de.ellpeck.actuallyadditions.mod.nei.NEICoffeeMachineRecipe ActuallyAdditions:blockCoffeeMachine ActuallyAdditions TRUE
1352 de.ellpeck.actuallyadditions.mod.nei.NEICompostRecipe ActuallyAdditions:blockCompost ActuallyAdditions TRUE
1353 de.ellpeck.actuallyadditions.mod.nei.NEIReconstructorRecipe ActuallyAdditions:blockAtomicReconstructor ActuallyAdditions TRUE
1354 de.ellpeck.actuallyadditions.mod.nei.NEITreasureChestRecipe ActuallyAdditions:blockTreasureChest ActuallyAdditions TRUE
1355 vazkii.botania.client.integration.nei.RecipeHandlerFloatingFlowers Botania:miniIsland Botania TRUE
1356 vazkii.botania.client.integration.nei.RecipeHandlerPetalApothecary Botania:altar Botania TRUE
1357 vazkii.botania.client.integration.nei.RecipeHandlerRunicAltar Botania:runeAltar Botania TRUE
1358 vazkii.botania.client.integration.nei.RecipeHandlerManaPool Botania:pool Botania TRUE
1359 vazkii.botania.client.integration.nei.RecipeHandlerElvenTrade Botania:alfheimPortal Botania TRUE
1360 vazkii.botania.client.integration.nei.RecipeHandlerBrewery Botania:brewery Botania TRUE
1361 vazkii.botania.client.integration.nei.RecipeHandlerPureDaisy Botania:specialFlower {type:puredaisy} Botania TRUE
1362 vazkii.botania.client.integration.nei.RecipeHandlerLexicaBotania Botania:lexicon Botania TRUE
1363 neiplugins.forge.OreDictionaryList minecraft:book NEIPlugins TRUE
1364 neiplugins.forge.FluidRegistryList minecraft:bucket NEIPlugins TRUE
1365 de.ellpeck.actuallyadditions.mod.nei.NEIBookletRecipe ActuallyAdditions:itemBooklet ActuallyAdditions TRUE
1366 de.ellpeck.actuallyadditions.mod.nei.NEIHairyBallRecipe ActuallyAdditions:itemHairyBall ActuallyAdditions TRUE
1367 de.ellpeck.actuallyadditions.mod.nei.NEICrusherRecipe$Double ActuallyAdditions:blockGrinderDouble ActuallyAdditions TRUE
+11 -1
View File
@@ -520,4 +520,14 @@ de.ellpeck.actuallyadditions.mod.nei.NEICoffeeMachineRecipe,Actually Additions,A
de.ellpeck.actuallyadditions.mod.nei.NEICompostRecipe,Actually Additions,ActuallyAdditions:blockCompost,,ActuallyAdditions,TRUE,,,,,,,,,,,
de.ellpeck.actuallyadditions.mod.nei.NEIReconstructorRecipe,Actually Additions,ActuallyAdditions:blockAtomicReconstructor,,ActuallyAdditions,TRUE,,,,,,,,,,,
de.ellpeck.actuallyadditions.mod.nei.NEITreasureChestRecipe,Actually Additions,ActuallyAdditions:blockTreasureChest,,ActuallyAdditions,TRUE,,,,,,,,,,,
vazkii.botania.client.integration.nei.RecipeHandlerFloatingFlowers,Botania,Botania:miniIsland,,Botania,TRUE,,,,,5,,,,,,
vazkii.botania.client.integration.nei.RecipeHandlerPetalApothecary,Botania,Botania:altar,,Botania,TRUE,,,102,137,4,,,,,,
vazkii.botania.client.integration.nei.RecipeHandlerRunicAltar,Botania,Botania:runeAltar,,Botania,TRUE,,,122,137,4,,,,,,
vazkii.botania.client.integration.nei.RecipeHandlerManaPool,Botania,Botania:pool,,Botania,TRUE,,,90,137,4,,,,,,
vazkii.botania.client.integration.nei.RecipeHandlerElvenTrade,Botania,Botania:alfheimPortal,,Botania,TRUE,,,90,130,4,,,,,,
vazkii.botania.client.integration.nei.RecipeHandlerBrewery,Botania,Botania:brewery,,Botania,TRUE,,,,,4,,,,,,
vazkii.botania.client.integration.nei.RecipeHandlerPureDaisy,Botania,Botania:specialFlower,"{type:puredaisy}",Botania,TRUE,,,,,4,,,,,,
vazkii.botania.client.integration.nei.RecipeHandlerLexicaBotania,Botania,Botania:lexicon,,Botania,TRUE,,,,,,,,,,,
neiplugins.forge.OreDictionaryList,NEIPlugins,minecraft:book,,NEIPlugins,TRUE,,,,,,,,,,,
neiplugins.forge.FluidRegistryList,NEIPlugins,minecraft:bucket,,NEIPlugins,TRUE,,,,,,,,,,,
de.ellpeck.actuallyadditions.mod.nei.NEITreasureChestRecipe,Actually Additions,ActuallyAdditions:blockTreasureChest,,ActuallyAdditions,TRUE,,,,,,,,,,,
1 handler modName itemName nbtInfo modId modRequired excludedModId yShift handlerHeight handlerWidth maxRecipesPerPage imageResource imageX imageY imageWidth imageHeight itemNotes
520 de.ellpeck.actuallyadditions.mod.nei.NEICompostRecipe Actually Additions ActuallyAdditions:blockCompost ActuallyAdditions TRUE
521 de.ellpeck.actuallyadditions.mod.nei.NEIReconstructorRecipe Actually Additions ActuallyAdditions:blockAtomicReconstructor ActuallyAdditions TRUE
522 de.ellpeck.actuallyadditions.mod.nei.NEITreasureChestRecipe Actually Additions ActuallyAdditions:blockTreasureChest ActuallyAdditions TRUE
523 vazkii.botania.client.integration.nei.RecipeHandlerFloatingFlowers Botania Botania:miniIsland Botania TRUE 5
524 vazkii.botania.client.integration.nei.RecipeHandlerPetalApothecary Botania Botania:altar Botania TRUE 102 137 4
525 vazkii.botania.client.integration.nei.RecipeHandlerRunicAltar Botania Botania:runeAltar Botania TRUE 122 137 4
526 vazkii.botania.client.integration.nei.RecipeHandlerManaPool Botania Botania:pool Botania TRUE 90 137 4
527 vazkii.botania.client.integration.nei.RecipeHandlerElvenTrade Botania Botania:alfheimPortal Botania TRUE 90 130 4
528 vazkii.botania.client.integration.nei.RecipeHandlerBrewery Botania Botania:brewery Botania TRUE 4
529 vazkii.botania.client.integration.nei.RecipeHandlerPureDaisy Botania Botania:specialFlower {type:puredaisy} Botania TRUE 4
530 vazkii.botania.client.integration.nei.RecipeHandlerLexicaBotania Botania Botania:lexicon Botania TRUE
531 neiplugins.forge.OreDictionaryList NEIPlugins minecraft:book NEIPlugins TRUE
532 neiplugins.forge.FluidRegistryList NEIPlugins minecraft:bucket NEIPlugins TRUE
533 de.ellpeck.actuallyadditions.mod.nei.NEITreasureChestRecipe Actually Additions ActuallyAdditions:blockTreasureChest ActuallyAdditions TRUE
@@ -56,6 +56,7 @@ nei.inventory.current.gamemode.0=Current gamemode: survival
nei.inventory.current.gamemode.1=Current gamemode: creative
nei.inventory.current.gamemode.2=Current gamemode: creative+
nei.inventory.current.gamemode.3=Current gamemode: adventure
nei.inventory.tooltip.page=Page: %s / %s [Press %s to see next page]
nei.inventory.gamemode.0=Click: Set gamemode to survival
nei.inventory.gamemode.1=Click: Set gamemode to creative
@@ -108,6 +109,7 @@ nei.options.keys.gui.overlay_hide=Hide Overlay Recipe
nei.options.keys.gui.overlay_use=Use Overlay Recipe
nei.options.keys.gui.getprevioussearch=Previous Search
nei.options.keys.gui.getnextsearch=Next Search
nei.options.keys.gui.next_tooltip=Next Tooltip
nei.options.keys.world=World
nei.options.keys.world.chunkoverlay=Chunk Boundary Overlay
nei.options.keys.world.moboverlay=Mob Spawn Overlay
@@ -164,6 +166,12 @@ nei.options.inventory.ignore_potion_overlap.false=No
nei.options.inventory.optimize_gui_overlap_computation=Optimize computation for GUI overlap
nei.options.inventory.optimize_gui_overlap_computation.true=Yes
nei.options.inventory.optimize_gui_overlap_computation.false=No
nei.options.inventory.jei_style_cycled_ingredients=JEI styled cycled ingredients
nei.options.inventory.jei_style_cycled_ingredients.true=Yes
nei.options.inventory.jei_style_cycled_ingredients.false=No
nei.options.inventory.shift_overlay_recipe=Require holding shift to move items when overlaying recipe
nei.options.inventory.shift_overlay_recipe.true=Yes
nei.options.inventory.shift_overlay_recipe.false=No
nei.options.inventory.widgetsenabled.true=NEI Enabled
nei.options.inventory.widgetsenabled.false=NEI Disabled
nei.options.inventory.cheatmode.0=Recipe Mode