mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-08 12:34:46 +00:00
Check unknown bookmark group (#1014)
This commit is contained in:
1 parent
bd595f739c
commit
7817640d96
5 files changed
+36
-57
No files matched your search
@@ -903,14 +903,18 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
|
||||
}
|
||||
|
||||
private List<String> recipeChainTooltip(int groupId, List<String> currenttip) {
|
||||
boolean crafting = this.grid.getGroup(groupId).crafting != null;
|
||||
boolean crafting = this.grid.isCraftingMode(groupId);
|
||||
|
||||
if (this.recipeChainTooltipLineHandler == null || this.recipeChainTooltipLineHandler.groupId != groupId
|
||||
|| this.recipeChainTooltipLineHandler.crafting != crafting) {
|
||||
this.recipeChainTooltipLineHandler = new RecipeChainTooltipLineHandler(
|
||||
groupId,
|
||||
crafting,
|
||||
this.grid.createRecipeChainMath(groupId));
|
||||
final RecipeChainMath recipeChainMath = this.grid.createRecipeChainMath(groupId);
|
||||
|
||||
if (recipeChainMath != null) {
|
||||
this.recipeChainTooltipLineHandler = new RecipeChainTooltipLineHandler(
|
||||
groupId,
|
||||
crafting,
|
||||
recipeChainMath);
|
||||
}
|
||||
}
|
||||
|
||||
currenttip.add(GuiDraw.TOOLTIP_HANDLER + GuiDraw.getTipLineId(this.recipeChainTooltipLineHandler));
|
||||
|
||||
@@ -302,7 +302,17 @@ public class NEIClientConfig {
|
||||
});
|
||||
|
||||
tag.getTag("inventory.history.save").setComment("Enable/disable History save").getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.history.save", true));
|
||||
API.addOption(new OptionToggleButton("inventory.history.save", true) {
|
||||
|
||||
@Override
|
||||
public boolean onClick(int button) {
|
||||
super.onClick(button);
|
||||
ItemPanels.itemPanel.historyPanel.save();
|
||||
ItemPanels.itemPanel.historyPanel.load();
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
tag.getTag("inventory.craftables.enabled").setComment("Enable/disable Craftables Panel").getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.craftables.enabled", true));
|
||||
|
||||
@@ -600,6 +600,11 @@ public class BookmarkGrid extends ItemsGrid<BookmarksGridSlot, BookmarkGrid.Book
|
||||
|
||||
public RecipeChainMath createRecipeChainMath(int groupId, RecipeId recipeId) {
|
||||
final BookmarkGroup group = getGroup(groupId);
|
||||
|
||||
if (group == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final List<BookmarkItem> chainItems = new ArrayList<>();
|
||||
final Set<RecipeId> collapsedRecipes = group.crafting != null && recipeId == null ? group.collapsedRecipes
|
||||
: Collections.emptySet();
|
||||
|
||||
@@ -25,34 +25,6 @@ import codechicken.nei.recipe.StackInfo;
|
||||
|
||||
public class RecipeChainMath {
|
||||
|
||||
public interface ChainVisitor {
|
||||
|
||||
void enterRecipe(RecipeId recipeId, long multiplier);
|
||||
|
||||
void addIngredient(BookmarkItem ingrItem, long requestedAmount);
|
||||
|
||||
void addIngredientFresh(BookmarkItem ingrItem, long freshAmount);
|
||||
|
||||
void leaveRecipe();
|
||||
|
||||
}
|
||||
|
||||
private static class EmptyChainVisitor implements ChainVisitor {
|
||||
|
||||
@Override
|
||||
public void enterRecipe(RecipeId recipeId, long multiplier) {}
|
||||
|
||||
@Override
|
||||
public void addIngredient(BookmarkItem ingrItem, long requestedAmount) {}
|
||||
|
||||
@Override
|
||||
public void addIngredientFresh(BookmarkItem ingrItem, long freshAmount) {}
|
||||
|
||||
@Override
|
||||
public void leaveRecipe() {}
|
||||
|
||||
}
|
||||
|
||||
private static class ContainerItemResult {
|
||||
|
||||
public ItemStack stack;
|
||||
@@ -66,8 +38,6 @@ public class RecipeChainMath {
|
||||
}
|
||||
}
|
||||
|
||||
private static final ChainVisitor EMPTY_CHAIN_VISITOR = new EmptyChainVisitor();
|
||||
|
||||
private static final ItemStack ROOT_ITEM = new ItemStack(Blocks.fire);
|
||||
private static final RecipeId ROOT_RECIPE_ID = RecipeId
|
||||
.of(ROOT_ITEM, "recipe-autocrafting", Collections.emptyList());
|
||||
@@ -328,10 +298,6 @@ public class RecipeChainMath {
|
||||
}
|
||||
|
||||
public RecipeChainMath refresh() {
|
||||
return refresh(EMPTY_CHAIN_VISITOR);
|
||||
}
|
||||
|
||||
public RecipeChainMath refresh(ChainVisitor visitor) {
|
||||
final boolean isPausedItemDamageSound = StackInfo.isPausedItemDamageSound();
|
||||
StackInfo.pauseItemDamageSound(true);
|
||||
|
||||
@@ -356,7 +322,7 @@ public class RecipeChainMath {
|
||||
}
|
||||
|
||||
this.preferredItems.put(prefItem, prefItem);
|
||||
calculateSuitableRecipe(prefItem, prefMultiplier, new ArrayList<>(), visitor);
|
||||
calculateSuitableRecipe(prefItem, prefMultiplier, new ArrayList<>());
|
||||
this.preferredItems.remove(prefItem);
|
||||
}
|
||||
}
|
||||
@@ -375,14 +341,11 @@ public class RecipeChainMath {
|
||||
return this;
|
||||
}
|
||||
|
||||
private void calculateSuitableRecipe(BookmarkItem ingrItem, long ingrMultiplier, List<RecipeId> visited,
|
||||
ChainVisitor visitor) {
|
||||
private void calculateSuitableRecipe(BookmarkItem ingrItem, long ingrMultiplier, List<RecipeId> visited) {
|
||||
final BookmarkItem prefItem = this.preferredItems.get(ingrItem);
|
||||
long ingrAmount = ingrItem
|
||||
.getAmount(ingrMultiplier, prefItem != null ? prefItem.itemStack : ingrItem.itemStack);
|
||||
|
||||
visitor.addIngredient(prefItem != null ? prefItem : ingrItem, ingrAmount);
|
||||
|
||||
// calculate existing containers
|
||||
if (ingrAmount > 0) {
|
||||
for (ItemStack stack : ingrItem.permutations.values()) {
|
||||
@@ -400,7 +363,7 @@ public class RecipeChainMath {
|
||||
if (ingrAmount > 0) {
|
||||
for (BookmarkItem item : this.initialItems) {
|
||||
if (item.containsItems(ingrItem)
|
||||
&& (ingrAmount = addRequiredAmount(item, ingrAmount, item.getAmount(), visitor)) == 0) {
|
||||
&& (ingrAmount = addRequiredAmount(item, ingrAmount, item.getAmount())) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -408,37 +371,35 @@ public class RecipeChainMath {
|
||||
|
||||
// shift amount
|
||||
if (prefItem == null) {
|
||||
addRequiredAmount(ingrItem, ingrAmount, Long.MAX_VALUE, visitor);
|
||||
addRequiredAmount(ingrItem, ingrAmount, Long.MAX_VALUE);
|
||||
} else if (visited.contains(prefItem.recipeId)) {
|
||||
addRequiredAmount(prefItem, ingrAmount, Long.MAX_VALUE, visitor);
|
||||
addRequiredAmount(prefItem, ingrAmount, Long.MAX_VALUE);
|
||||
} else {
|
||||
addRequiredAmount(prefItem, ingrAmount, Long.MAX_VALUE, visitor);
|
||||
addRequiredAmount(prefItem, ingrAmount, Long.MAX_VALUE);
|
||||
final long multiplier = Math
|
||||
.max(0, prefItem.getMultiplierFromAmount(this.requiredAmount.get(prefItem)) - prefItem.multiplier);
|
||||
|
||||
if (multiplier > 0) {
|
||||
addShift(prefItem.recipeId, multiplier);
|
||||
visited.add(prefItem.recipeId);
|
||||
prepareIngredients(prefItem.recipeId, multiplier, visited, visitor);
|
||||
prepareIngredients(prefItem.recipeId, multiplier, visited);
|
||||
visited.remove(prefItem.recipeId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void prepareIngredients(RecipeId recipeId, long multiplier, List<RecipeId> visited, ChainVisitor visitor) {
|
||||
visitor.enterRecipe(recipeId, multiplier);
|
||||
private void prepareIngredients(RecipeId recipeId, long multiplier, List<RecipeId> visited) {
|
||||
|
||||
for (BookmarkItem item : this.recipeIngredients) {
|
||||
if (!item.emptyFactor() && recipeId.equals(item.recipeId)) {
|
||||
calculateSuitableRecipe(item, multiplier, visited, visitor);
|
||||
calculateSuitableRecipe(item, multiplier, visited);
|
||||
}
|
||||
}
|
||||
|
||||
visitor.leaveRecipe();
|
||||
}
|
||||
|
||||
private long addRequiredAmount(BookmarkItem prefItem, long ingrAmount, long maxAmount, ChainVisitor visitor) {
|
||||
private long addRequiredAmount(BookmarkItem prefItem, long ingrAmount, long maxAmount) {
|
||||
long shiftAmount = this.requiredAmount.getOrDefault(prefItem, 0L);
|
||||
|
||||
if (hasContainerItem(prefItem.itemStack)) {
|
||||
@@ -495,7 +456,6 @@ public class RecipeChainMath {
|
||||
ingrAmount -= initAmount;
|
||||
}
|
||||
|
||||
visitor.addIngredientFresh(prefItem, shiftAmount - this.requiredAmount.getOrDefault(prefItem, 0L));
|
||||
this.requiredAmount.put(prefItem, shiftAmount);
|
||||
|
||||
return ingrAmount;
|
||||
|
||||
@@ -442,7 +442,7 @@ nei.options.inventory.history.useRows=Rows
|
||||
nei.options.inventory.history.worldSpecific=World Specific
|
||||
nei.options.inventory.history.worldSpecific.true=Yes
|
||||
nei.options.inventory.history.worldSpecific.false=No
|
||||
nei.options.inventory.history.save=Save
|
||||
nei.options.inventory.history.save=History Persistence
|
||||
nei.options.inventory.history.save.true=Enabled
|
||||
nei.options.inventory.history.save.false=Disabled
|
||||
nei.options.inventory.craftables=Craftables Panel
|
||||
|
||||
Reference in new issue
Block a user