mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-20 12:20:00 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
903271b279 |
No files matched your search
@@ -165,11 +165,17 @@ public abstract class ShortcutInputHandler {
|
||||
RecipeChainMath math = null;
|
||||
|
||||
if (slot == null) {
|
||||
math = RecipeChainMath.of(Recipe.of(recipeId), slot != null ? slot.getMultiplier() : 1);
|
||||
final Recipe recipe = Recipe.of(recipeId);
|
||||
if (recipe != null) {
|
||||
math = RecipeChainMath.of(recipe, 1);
|
||||
}
|
||||
} else if (slot.getRecipeId() != null && !slot.isIngredient()) {
|
||||
|
||||
if (slot.getGroup().crafting == null) {
|
||||
math = RecipeChainMath.of(Recipe.of(slot.getRecipeId()), slot != null ? slot.getMultiplier() : 1);
|
||||
final Recipe recipe = Recipe.of(slot.getRecipeId());
|
||||
if (recipe != null) {
|
||||
math = RecipeChainMath.of(recipe, slot != null ? slot.getMultiplier() : 1);
|
||||
}
|
||||
} else {
|
||||
math = ItemPanels.bookmarkPanel.getGrid()
|
||||
.createRecipeChainMath(slot.getGroupId(), slot.getRecipeId());
|
||||
|
||||
@@ -386,8 +386,8 @@ public class GuiContainerManager {
|
||||
|
||||
public static void enableMatrixStackLogging() {
|
||||
if (!contextEnabled) {
|
||||
modelviewDepth = GL11.glGetInteger(GL11.GL_MODELVIEW_STACK_DEPTH);
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||
modelviewDepth = GL11.glGetInteger(GL11.GL_MODELVIEW_STACK_DEPTH);
|
||||
contextEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package codechicken.nei.recipe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -16,7 +15,6 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
|
||||
import codechicken.nei.LRUCache;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
@@ -289,8 +287,6 @@ public class Recipe {
|
||||
}
|
||||
}
|
||||
|
||||
private static final LRUCache<RecipeId, Recipe> recipeCache = new LRUCache<>(200);
|
||||
|
||||
private final String handlerName;
|
||||
private final RecipeIngredient[] results;
|
||||
private final RecipeIngredient[] ingredients;
|
||||
@@ -298,14 +294,6 @@ public class Recipe {
|
||||
|
||||
private Recipe(String handlerName, List<RecipeIngredient> ingredients, List<RecipeIngredient> results) {
|
||||
this.handlerName = handlerName;
|
||||
|
||||
ingredients.sort(
|
||||
Comparator.comparingInt((RecipeIngredient ingr) -> ingr.rely)
|
||||
.thenComparingInt((RecipeIngredient ingr) -> ingr.relx));
|
||||
results.sort(
|
||||
Comparator.comparingInt((RecipeIngredient ingr) -> ingr.rely)
|
||||
.thenComparingInt((RecipeIngredient ingr) -> ingr.relx));
|
||||
|
||||
this.ingredients = ingredients.toArray(new RecipeIngredient[ingredients.size()]);
|
||||
this.results = results.toArray(new RecipeIngredient[results.size()]);
|
||||
}
|
||||
@@ -343,17 +331,13 @@ public class Recipe {
|
||||
return null;
|
||||
}
|
||||
|
||||
final Recipe recipe = recipeCache.computeIfAbsent(recipeId, ri -> {
|
||||
final RecipeHandlerRef handlerRef = RecipeHandlerRef.of(recipeId);
|
||||
final RecipeHandlerRef handlerRef = RecipeHandlerRef.of(recipeId);
|
||||
|
||||
if (handlerRef != null) {
|
||||
return Recipe.of(handlerRef);
|
||||
}
|
||||
if (handlerRef != null) {
|
||||
return Recipe.of(handlerRef);
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
return recipe != null ? recipe.copy() : null;
|
||||
return null;
|
||||
}
|
||||
|
||||
protected static List<RecipeIngredient> extractItems(List<?> items) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
|
||||
import codechicken.nei.LRUCache;
|
||||
import codechicken.nei.LayoutManager;
|
||||
import codechicken.nei.api.IOverlayHandler;
|
||||
import codechicken.nei.api.IRecipeOverlayRenderer;
|
||||
@@ -13,6 +14,7 @@ import codechicken.nei.recipe.Recipe.RecipeId;
|
||||
|
||||
public class RecipeHandlerRef {
|
||||
|
||||
private static final LRUCache<RecipeId, RecipeHandlerRef> recipeRefCache = new LRUCache<>(200);
|
||||
public final IRecipeHandler handler;
|
||||
public final int recipeIndex;
|
||||
|
||||
@@ -28,19 +30,22 @@ public class RecipeHandlerRef {
|
||||
public static RecipeHandlerRef of(RecipeId recipeId) {
|
||||
|
||||
if (recipeId.getResult() != null && !recipeId.getIngredients().isEmpty()) {
|
||||
final List<ICraftingHandler> handlers = GuiCraftingRecipe
|
||||
.getCraftingHandlers("recipeId", recipeId.getResult(), recipeId);
|
||||
return recipeRefCache.computeIfAbsent(recipeId, ri -> {
|
||||
final List<ICraftingHandler> handlers = GuiCraftingRecipe
|
||||
.getCraftingHandlers("recipeId", recipeId.getResult(), recipeId);
|
||||
|
||||
for (ICraftingHandler handler : handlers) {
|
||||
int refIndex = SearchRecipeHandler.findFirst(
|
||||
handler,
|
||||
recipeIndex -> recipeId.equalsIngredients(handler.getIngredientStacks(recipeIndex)));
|
||||
for (ICraftingHandler handler : handlers) {
|
||||
int refIndex = SearchRecipeHandler.findFirst(
|
||||
handler,
|
||||
recipeIndex -> recipeId.equalsIngredients(handler.getIngredientStacks(recipeIndex)));
|
||||
|
||||
if (refIndex >= 0) {
|
||||
return new RecipeHandlerRef(handler, refIndex);
|
||||
if (refIndex >= 0) {
|
||||
return new RecipeHandlerRef(handler, refIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in new issue
Block a user