Compare commits

..
Author SHA1 Message Date
Martin Robertz 66deab6dbd Merge remote-tracking branch 'slprime/bookmarks_groups_and_filter' into dev 2024-01-26 21:30:09 +01:00
slprime 4953edde4b fixed rounding in chain calculation 2024-01-26 19:19:02 +02:00
slprime 9873de760f Change Search Recipe Algorithm 2024-01-26 17:53:31 +02:00
Martin Robertz 355cc5bd0e Merge remote-tracking branch 'slprime/bookmarks_groups_and_filter' into dev 2024-01-22 18:21:53 +01:00
slprime 183e40a6c2 fix recipe extra information 2024-01-22 00:57:27 +02:00
Martin Robertz 79660a09d5 Merge remote-tracking branch 'slprime/bookmarks_groups_and_filter' into dev 2024-01-21 11:16:56 +01:00
slprime b03ae51e3c Add Search Recipe Icon 2024-01-21 12:11:49 +02:00
Martin Robertz 91d57c28b7 Merge remote-tracking branch 'slprime/bookmarks_groups_and_filter' into dev 2024-01-20 21:43:51 +01:00
slprime 06cdea3fd6 fix input V in ME terminal 2024-01-19 23:39:01 +02:00
Martin Robertz ceae486a31 update bs+properties 2024-01-16 22:10:41 +01:00
Martin Robertz d35e77661f Merge remote-tracking branch 'slprime/bookmarks_groups_and_filter' into dev 2024-01-16 22:09:20 +01:00
slprime 4285632807 remove println 2024-01-14 16:02:21 +02:00
slprime b16916dbe6 Optimize Chain Algorithm 2024-01-14 14:51:26 +02:00
Martin Robertz 57db3fa789 Merge remote-tracking branch 'slprime/bookmarks_groups_and_filter' into dev 2024-01-14 10:38:18 +01:00
slprime c5c798c61a Pull all Bookmarked Items: use groups 2024-01-13 18:35:19 +02:00
Martin Robertz f9cba79a22 update deps 2024-01-13 00:09:15 +01:00
slprime 0a24334693 change hiddenhandler handlerId 2024-01-11 23:43:36 +02:00
slprime 8ef88ff9f2 fix crash after DnD; add remove group function 2024-01-11 21:08:08 +02:00
slprime 4cfbe6b3ad Create Bookmarks Groups; Search Recipe 2024-01-10 23:29:03 +02:00
6 changed files with 48 additions and 120 deletions

No files matched your search

+2 -2
View File
@@ -1,4 +1,4 @@
//version: 1706545953
//version: 1705357285
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
@@ -651,7 +651,7 @@ repositories {
def mixinProviderGroup = "io.github.legacymoddingmc"
def mixinProviderModule = "unimixins"
def mixinProviderVersion = "0.1.15"
def mixinProviderVersion = "0.1.13"
def mixinProviderSpecNoClassifer = "${mixinProviderGroup}:${mixinProviderModule}:${mixinProviderVersion}"
def mixinProviderSpec = "${mixinProviderSpecNoClassifer}:dev"
ext.mixinProviderSpec = mixinProviderSpec
@@ -29,7 +29,7 @@ public class BookmarkCraftingChain {
public int factor = 0;
public int count = 0;
public boolean ingredient = false;
public int fluidCellAmount = 1;
public boolean fluidCell = false;
public ItemStack stack = null;
public CraftingChainItem(ItemStack stack, ItemStackMetadata stackMetadata) {
@@ -40,9 +40,9 @@ public class BookmarkCraftingChain {
if (fluid != null) {
this.stackIndex = getStackIndex(fluid);
this.count = fluid.amount * Math.max(0, stack.stackSize);
this.fluidCellAmount = StackInfo.isFluidContainer(stack) ? fluid.amount : 1;
this.factor = this.fluidCellAmount * stackMetadata.factor;
this.count = fluid.amount * Math.max(1, stack.stackSize);
this.fluidCell = StackInfo.isFluidContainer(stack);
this.factor = this.fluidCell ? fluid.amount : stackMetadata.factor;
} else {
this.stackIndex = getStackIndex(stack);
this.count = StackInfo.itemStackToNBT(stack).getInteger("Count");
@@ -55,7 +55,7 @@ public class BookmarkCraftingChain {
public ItemStack getItemStack(long count) {
return StackInfo.loadFromNBT(
StackInfo.itemStackToNBT(this.stack),
this.factor > 0 ? (count / this.fluidCellAmount) : 0);
this.factor > 0 ? (this.fluidCell ? (count / this.factor) : count) : 0);
}
public static void clearStatic() {
@@ -144,7 +144,6 @@ public class BookmarkCraftingChain {
for (int index = 0; index < items.size(); index++) {
CraftingChainItem item = new CraftingChainItem(items.get(index), metadata.get(index));
item.guid = item.ingredient ? "i" + item.guid : "r" + item.guid;
this.items.add(item);
if (this.multiplier.get(item.recipeIndex) == null) {
@@ -275,7 +274,7 @@ public class BookmarkCraftingChain {
for (CraftingChainItem item : request.outputs.get(stackIndex)) {
if (!request.initialItems.contains(item.recipeIndex) && item.factor > 0) {
long ingrCount = calculateCount(request, request.inputs.get(item.stackIndex), item.recipeIndex);
long ingrCount = calculateCount(request, request.inputs.get(item.stackIndex));
long outputCount = calculateCount(request, request.outputs.get(item.stackIndex));
long shift = (long) Math.ceil((ingrCount - outputCount) / (double) item.factor);
@@ -295,17 +294,11 @@ public class BookmarkCraftingChain {
}
private long calculateCount(CraftingChainRequest request, HashSet<CraftingChainItem> items) {
return calculateCount(request, items, -1);
}
private long calculateCount(CraftingChainRequest request, HashSet<CraftingChainItem> items, int recipeIndex) {
long count = 0L;
if (items != null) {
for (CraftingChainItem item : items) {
if (item.recipeIndex != recipeIndex || recipeIndex == -1) {
count += request.counts.get(item.guid) + item.factor * request.multiplier.get(item.recipeIndex);
}
count += request.counts.get(item.guid) + item.factor * request.multiplier.get(item.recipeIndex);
}
}
@@ -91,44 +91,6 @@ public class BookmarkPanel extends PanelWidget {
this.ungroup = ungroup;
this.rowIndexA = rowIndexA;
}
public int getTopRowIndex(BookmarkGrid BGrid) {
int topRowIndex = Math.min(this.rowIndexA, this.rowIndexB);
int topItemIndex = BGrid.getRowItemIndex(topRowIndex, true);
ItemStackMetadata meta = topItemIndex >= 0 ? BGrid.metadata.get(topItemIndex) : null;
if (meta != null && meta.recipeId != null) {
while (topItemIndex > 0 && meta.groupId == BGrid.metadata.get(topItemIndex - 1).groupId
&& meta.recipeId.equals(BGrid.metadata.get(topItemIndex - 1).recipeId)) {
topItemIndex--;
}
int index = BGrid.getMask().indexOf(topItemIndex);
topRowIndex = index == -1 ? 0 : index / BGrid.columns;
}
return topRowIndex;
}
public int getBottomRowIndex(BookmarkGrid BGrid) {
int bottomRowIndex = Math.max(this.rowIndexA, this.rowIndexB);
int bottomItemIndex = BGrid.getRowItemIndex(bottomRowIndex, false);
ItemStackMetadata meta = bottomItemIndex >= 0 ? BGrid.metadata.get(bottomItemIndex) : null;
if (meta != null && meta.recipeId != null) {
int size = BGrid.size();
while (bottomItemIndex < size - 1 && meta.groupId == BGrid.metadata.get(bottomItemIndex + 1).groupId
&& meta.recipeId.equals(BGrid.metadata.get(bottomItemIndex + 1).recipeId)) {
bottomItemIndex++;
}
int index = BGrid.getMask().indexOf(bottomItemIndex);
bottomRowIndex = index == -1 ? BGrid.getLastRowIndex() : index / BGrid.columns;
}
return bottomRowIndex;
}
}
protected static class ItemStackMetadata {
@@ -217,9 +179,7 @@ public class BookmarkPanel extends PanelWidget {
private static class RecipeTooltipRenderer {
public ItemStack stack = null;
public BookmarkRecipeId recipeId = null;
public int slotIndex = 0;
public GuiRecipe<?> gui = null;
public Runnable createRecipeGui = null;
}
@@ -321,7 +281,6 @@ public class BookmarkPanel extends PanelWidget {
if (c == 0 && (meta.recipeId == null || meta.ingredient == false
|| index + 1 < rows * columns && isInvalidSlot(index + 1)
|| previousMeta.groupId != meta.groupId
|| meta.ingredient && !meta.recipeId.equals(previousMeta.recipeId))) {
// In first column must be an item without recipe, a recipe result, or an ingredient
// if the second column is occupied
@@ -443,8 +402,8 @@ public class BookmarkPanel extends PanelWidget {
int previoudGroupId = DEFAULT_GROUP_ID;
if (groupingItem != null && groupingItem.rowIndexB != -1) {
int topRowIndex = groupingItem.getTopRowIndex(this);
int bottomRowIndex = groupingItem.getBottomRowIndex(this);
int topRowIndex = Math.min(groupingItem.rowIndexA, groupingItem.rowIndexB);
int bottomRowIndex = Math.max(groupingItem.rowIndexA, groupingItem.rowIndexB);
int groupIdA = groupMask.get(groupingItem.rowIndexA);
int groupId = groupingItem.ungroup ? DEFAULT_GROUP_ID : (groupIdA == DEFAULT_GROUP_ID ? -1 : groupIdA);
groupMask = new ArrayList<>(groupMask);
@@ -455,12 +414,12 @@ public class BookmarkPanel extends PanelWidget {
if (groupIdA != DEFAULT_GROUP_ID && !groupingItem.ungroup
&& groupingItem.rowIndexA != groupingItem.rowIndexB) {
if (groupingItem.rowIndexB < groupingItem.rowIndexA) {
if (groupingItem.rowIndexB == topRowIndex) {
for (int rowIndex = topRowIndex - 1; rowIndex >= 0
&& groupMask.get(rowIndex) == groupIdA; rowIndex--) {
groupMask.set(rowIndex, DEFAULT_GROUP_ID);
}
} else if (groupingItem.rowIndexB > groupingItem.rowIndexA) {
} else if (groupingItem.rowIndexB == bottomRowIndex) {
for (int rowIndex = bottomRowIndex + 1; rowIndex < groupMask.size()
&& groupMask.get(rowIndex) == groupIdA; rowIndex++) {
groupMask.set(rowIndex, DEFAULT_GROUP_ID);
@@ -674,8 +633,8 @@ public class BookmarkPanel extends PanelWidget {
protected void createGroup(GroupingItem groupingItem) {
final List<Integer> mask = getMask();
final int topRowIndex = groupingItem.getTopRowIndex(this);
final int bottomRowIndex = groupingItem.getBottomRowIndex(this);
final int topRowIndex = Math.min(groupingItem.rowIndexA, groupingItem.rowIndexB);
final int bottomRowIndex = Math.max(groupingItem.rowIndexA, groupingItem.rowIndexB);
final int groupIdA = getRowGroupId(groupingItem.rowIndexA);
final int startMaskIndex = topRowIndex * columns;
final int endMaskIntex = Math.min((bottomRowIndex + 1) * columns, mask.size());
@@ -1073,17 +1032,16 @@ public class BookmarkPanel extends PanelWidget {
return;
}
if (this.recipeTooltipRenderer == null || this.recipeTooltipRenderer.recipeId != meta.recipeId) {
if (this.recipeTooltipRenderer == null || this.recipeTooltipRenderer.slotIndex != focused.slotIndex) {
this.recipeTooltipRenderer = new RecipeTooltipRenderer();
this.recipeTooltipRenderer.stack = this.realItems.get(focused.slotIndex);
this.recipeTooltipRenderer.recipeId = meta.recipeId;
this.recipeTooltipRenderer.slotIndex = focused.slotIndex;
this.recipeTooltipRenderer.createRecipeGui = () -> {
GuiRecipe<?> gui = GuiCraftingRecipe.createRecipeGui(
"recipeId",
false,
this.recipeTooltipRenderer.stack,
this.recipeTooltipRenderer.recipeId);
final int slotIndex = this.recipeTooltipRenderer.slotIndex;
final BookmarkRecipeId recipeId = this.metadata.get(slotIndex).recipeId;
GuiRecipe<?> gui = GuiCraftingRecipe
.createRecipeGui("recipeId", false, this.realItems.get(slotIndex), recipeId);
if (gui != null) {
gui.initGui();
@@ -20,6 +20,8 @@ import codechicken.nei.recipe.BookmarkRecipeId;
import codechicken.nei.recipe.GuiCraftingRecipe;
import codechicken.nei.recipe.GuiRecipe;
import codechicken.nei.recipe.GuiUsageRecipe;
import codechicken.nei.recipe.StackInfo;
import codechicken.nei.recipe.stackinfo.GTFluidStackStringifyHandler;
public abstract class ShortcutInputHandler {
@@ -65,11 +67,11 @@ public abstract class ShortcutInputHandler {
}
if (NEIClientConfig.isKeyHashDown("gui.recipe")) {
return GuiCraftingRecipe.openRecipeGui("item", stackover);
return GuiCraftingRecipe.openRecipeGui("item", normalizeItemStack(stackover));
}
if (NEIClientConfig.isKeyHashDown("gui.usage")) {
return GuiUsageRecipe.openRecipeGui("item", stackover);
return GuiUsageRecipe.openRecipeGui("item", normalizeItemStack(stackover));
}
if (NEIClientConfig.isKeyHashDown("gui.bookmark")) {
@@ -99,6 +101,7 @@ public abstract class ShortcutInputHandler {
if (stackover != null) {
final int button = Mouse.getEventButton();
stackover = stackover.copy();
if (button == 0) {
return GuiCraftingRecipe.openRecipeGui("item", stackover);
@@ -164,4 +167,10 @@ public abstract class ShortcutInputHandler {
return false;
}
private static ItemStack normalizeItemStack(ItemStack stack) {
GTFluidStackStringifyHandler.replaceAE2FCFluidDrop = true;
stack = StackInfo.loadFromNBT(StackInfo.itemStackToNBT(stack));
GTFluidStackStringifyHandler.replaceAE2FCFluidDrop = false;
return stack;
}
}
@@ -18,7 +18,6 @@ import codechicken.nei.ItemPanels;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.stackinfo.GTFluidStackStringifyHandler;
public class GuiCraftingRecipe extends GuiRecipe<ICraftingHandler> {
@@ -34,7 +33,6 @@ public class GuiCraftingRecipe extends GuiRecipe<ICraftingHandler> {
final BookmarkRecipeId recipeId;
if ("item".equals(outputId)) {
results = Arrays.asList(results).stream().map(rslt -> normalizeItemStack((ItemStack) rslt)).toArray();
recipeId = getRecipeId(mc.currentScreen, (ItemStack) results[0]);
} else if ("recipeId".equals(outputId)) {
recipeId = (BookmarkRecipeId) results[1];
@@ -116,13 +114,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;
}
protected static BookmarkRecipeId getRecipeId(GuiScreen gui, ItemStack stackover) {
if (gui instanceof GuiRecipe) {
@@ -4,11 +4,9 @@ import java.util.ArrayList;
import java.util.Arrays;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.recipe.stackinfo.GTFluidStackStringifyHandler;
public class GuiUsageRecipe extends GuiRecipe<IUsageHandler> {
@@ -16,50 +14,29 @@ public class GuiUsageRecipe extends GuiRecipe<IUsageHandler> {
public static ArrayList<IUsageHandler> serialUsageHandlers = new ArrayList<>();
public static boolean openRecipeGui(String inputId, Object... ingredients) {
if ("item".equals(inputId)) {
ingredients = Arrays.asList(ingredients).stream().map(ingr -> normalizeItemStack((ItemStack) ingr))
.toArray();
}
final ArrayList<IUsageHandler> handlers = getUsageHandlers(inputId, ingredients);
if (!handlers.isEmpty()) {
final Minecraft mc = NEIClientUtils.mc();
final BookmarkRecipeId recipeId = getCurrentRecipe(mc.currentScreen);
final GuiUsageRecipe gui = new GuiUsageRecipe(handlers);
mc.displayGuiScreen(gui);
gui.openTargetRecipe(recipeId);
return true;
}
return false;
}
private GuiUsageRecipe(ArrayList<IUsageHandler> handlers) {
super(NEIClientUtils.mc().currentScreen);
this.currenthandlers = handlers;
}
public static ArrayList<IUsageHandler> getUsageHandlers(String inputId, Object... ingredients) {
final RecipeHandlerQuery<IUsageHandler> recipeQuery = new RecipeHandlerQuery<>(
RecipeHandlerQuery<IUsageHandler> recipeQuery = new RecipeHandlerQuery<>(
h -> getUsageOrCatalystHandler(h, inputId, ingredients),
usagehandlers,
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;
return recipeQuery.runWithProfiling("recipe.concurrent.usage");
Minecraft mc = NEIClientUtils.mc();
BookmarkRecipeId recipeId = getCurrentRecipe(mc.currentScreen);
GuiUsageRecipe gui = new GuiUsageRecipe(handlers);
mc.displayGuiScreen(gui);
gui.openTargetRecipe(recipeId);
return true;
}
private static ItemStack normalizeItemStack(ItemStack stack) {
GTFluidStackStringifyHandler.replaceAE2FCFluidDrop = true;
stack = StackInfo.loadFromNBT(StackInfo.itemStackToNBT(stack));
GTFluidStackStringifyHandler.replaceAE2FCFluidDrop = false;
return stack;
private GuiUsageRecipe(ArrayList<IUsageHandler> handlers) {
super(NEIClientUtils.mc().currentScreen);
this.currenthandlers = handlers;
}
public static void registerUsageHandler(IUsageHandler handler) {