mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-16 18:54:45 +00:00
Add the ability to create a chain of items with zero
This commit is contained in:
1 parent
5fd0a74363
commit
983e921f04
3 files changed
+19
-18
No files matched your search
@@ -1116,16 +1116,16 @@ public class BookmarkGrid extends ItemsGrid<BookmarksGridSlot, BookmarkGrid.Book
|
||||
if (item.factor > 0
|
||||
&& outputRecipes.stream().anyMatch(recipeId -> item.equalsRecipe(recipeId, targetGroupId))) {
|
||||
final long multiplier = recipeMultipliers.getOrDefault(item.recipeId, (long) Integer.MAX_VALUE);
|
||||
final boolean isOutputRecipe = group.crafting != null
|
||||
&& !group.crafting.recipeInMiddle.contains(item.recipeId);
|
||||
final boolean recipeInMiddle = group.crafting != null
|
||||
&& group.crafting.recipeInMiddle.contains(item.recipeId);
|
||||
|
||||
recipeMultipliers.put(
|
||||
item.recipeId,
|
||||
Math.min(
|
||||
shiftMultiplier(
|
||||
Math.max(isOutputRecipe ? 1 : 0, item.getMultiplier()),
|
||||
Math.max(recipeInMiddle ? 1 : 0, item.getMultiplier()),
|
||||
shift,
|
||||
isOutputRecipe ? 1 : 0),
|
||||
recipeInMiddle ? 1 : 0),
|
||||
multiplier));
|
||||
items.add(item);
|
||||
}
|
||||
@@ -1148,16 +1148,16 @@ public class BookmarkGrid extends ItemsGrid<BookmarksGridSlot, BookmarkGrid.Book
|
||||
} else if (targetItem.recipeId != null) {
|
||||
final RecipeId recipeId = this.gridGenerator.itemToRecipe
|
||||
.getOrDefault(targetItemIndex, targetItem.recipeId);
|
||||
final boolean isOutputRecipe = group.crafting != null && !group.crafting.recipeInMiddle.contains(recipeId);
|
||||
final boolean recipeInMiddle = group.crafting != null && group.crafting.recipeInMiddle.contains(recipeId);
|
||||
long multiplier = Integer.MAX_VALUE;
|
||||
|
||||
for (BookmarkItem item : this.bookmarkItems) {
|
||||
if (item.equalsRecipe(recipeId, targetItem.groupId) && item.factor > 0) {
|
||||
multiplier = Math.min(
|
||||
shiftMultiplier(
|
||||
Math.max(isOutputRecipe ? 1 : 0, item.getMultiplier()),
|
||||
Math.max(recipeInMiddle ? 1 : 0, item.getMultiplier()),
|
||||
shift,
|
||||
isOutputRecipe ? 1 : 0),
|
||||
recipeInMiddle ? 1 : 0),
|
||||
multiplier);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,9 +179,10 @@ public class RecipeChainDetails {
|
||||
if (itemIndex >= 0 && this.calculatedItems.containsKey(itemIndex)) {
|
||||
final BookmarkItem item = entry.getValue();
|
||||
if (this.recipeInMiddle.contains(item.recipeId)) {
|
||||
this.calculatedItems.get(itemIndex).setRealAmount(item.amount);
|
||||
this.calculatedItems.get(itemIndex)
|
||||
.setRealAmount(Math.max(0, item.factor * (item.getMultiplier() - 1)));
|
||||
} else {
|
||||
this.calculatedItems.get(itemIndex).setRealAmount(Math.max(item.factor, item.amount));
|
||||
this.calculatedItems.get(itemIndex).setRealAmount(item.amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,18 +116,18 @@ public class RecipeChainMath {
|
||||
}
|
||||
|
||||
for (Map.Entry<RecipeId, Long> entry : multipliers.entrySet()) {
|
||||
if (!this.outputRecipes.containsKey(entry.getKey()) && this.preferredItems.values().stream()
|
||||
.noneMatch(resItem -> resItem.recipeId.equals(entry.getKey()))) {
|
||||
this.outputRecipes.put(entry.getKey(), entry.getValue());
|
||||
final RecipeId recipeId = entry.getKey();
|
||||
final boolean isOutputRecipe = this.outputRecipes.containsKey(recipeId);
|
||||
final boolean recipeInMiddle = this.preferredItems.values().stream()
|
||||
.anyMatch(resItem -> resItem.recipeId.equals(recipeId));
|
||||
|
||||
if (!isOutputRecipe && !recipeInMiddle) {
|
||||
this.outputRecipes.put(recipeId, entry.getValue());
|
||||
} else if (isOutputRecipe && recipeInMiddle) {
|
||||
this.outputRecipes.put(recipeId, Math.max(0, entry.getValue() - 1));
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<RecipeId, Long> entry : this.outputRecipes.entrySet()) {
|
||||
if (entry.getValue() == 0 && this.preferredItems.values().stream()
|
||||
.noneMatch(prefItem -> prefItem.recipeId.equals(entry.getKey()))) {
|
||||
entry.setValue(1L);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void collectPreferredItems(RecipeId recipeId, Map<BookmarkItem, BookmarkItem> preferredItems,
|
||||
|
||||
Reference in new issue
Block a user