mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-19 20:00:00 +00:00
Compare commits
19
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
66deab6dbd | ||
|
|
4953edde4b | ||
|
|
9873de760f | ||
|
|
355cc5bd0e | ||
|
|
183e40a6c2 | ||
|
|
79660a09d5 | ||
|
|
b03ae51e3c | ||
|
|
91d57c28b7 | ||
|
|
06cdea3fd6 | ||
|
|
ceae486a31 | ||
|
|
d35e77661f | ||
|
|
4285632807 | ||
|
|
b16916dbe6 | ||
|
|
57db3fa789 | ||
|
|
c5c798c61a | ||
|
|
f9cba79a22 | ||
|
|
0a24334693 | ||
|
|
8ef88ff9f2 | ||
|
|
4cfbe6b3ad |
No files matched your search
+2
-2
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user