mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-13 00:47:35 +00:00
* ItemZoom, hotkeys & more tooltips * fix tooltips * fix hover crash to unnamed item * fix bookmark group with groupIds bigger than 127 --------- Co-authored-by: slprime <history-21@yandex.ru> Co-authored-by: Martin Robertz <dream-master@gmx.net>
46 lines
1.7 KiB
Java
46 lines
1.7 KiB
Java
package codechicken.nei.api;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Optional;
|
|
import java.util.stream.Collectors;
|
|
|
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
import net.minecraft.inventory.Slot;
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import codechicken.nei.PositionedStack;
|
|
import codechicken.nei.recipe.IRecipeHandler;
|
|
|
|
public interface IOverlayHandler {
|
|
|
|
void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean shift);
|
|
|
|
default List<Boolean> presenceOverlay(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex) {
|
|
final List<Boolean> itemPresenceSlots = new ArrayList<>();
|
|
final List<PositionedStack> ingredients = recipe.getIngredientStacks(recipeIndex);
|
|
@SuppressWarnings("unchecked")
|
|
final List<ItemStack> invStacks = ((List<Slot>) firstGui.inventorySlots.inventorySlots).stream()
|
|
.filter(
|
|
s -> s != null && s.getStack() != null
|
|
&& s.getStack().stackSize > 0
|
|
&& s.isItemValid(s.getStack())
|
|
&& s.canTakeStack(firstGui.mc.thePlayer))
|
|
.map(s -> s.getStack().copy()).collect(Collectors.toCollection(ArrayList::new));
|
|
|
|
for (PositionedStack stack : ingredients) {
|
|
Optional<ItemStack> used = invStacks.stream().filter(is -> is.stackSize > 0 && stack.contains(is))
|
|
.findFirst();
|
|
|
|
itemPresenceSlots.add(used.isPresent());
|
|
|
|
if (used.isPresent()) {
|
|
ItemStack is = used.get();
|
|
is.stackSize -= 1;
|
|
}
|
|
}
|
|
|
|
return itemPresenceSlots;
|
|
}
|
|
}
|