NEI Bookmarks improvements (#188)

* Add bookmarks sets; save items count in bookmarks; change counts in bookmarks; save ingredients in bookmarks; fill fluidcontainers in bookmarks;
* change fill container controls
* fix fill container
* rollback public variables

Co-authored-by: Serghei Borovetchi <[email protected]>
This commit is contained in:
slprimeandSerghei Borovetchi authored and GitHub committed 2022-01-02 13:30:54 -08:00
1 parent ce17ec8026
commit 5dde7cad8b
20 files changed
+1582 -591

No files matched your search

@@ -1,8 +1,11 @@
package codechicken.nei.recipe;
import codechicken.nei.api.IStackStringifyHandler;
import codechicken.nei.recipe.stackinfo.DefaultStackStringifyHandler;
import codechicken.nei.recipe.stackinfo.GTFluidStackStringifyHandler;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.FluidStack;
import java.util.ArrayList;
@@ -11,13 +14,22 @@ public class StackInfo
public static final ArrayList<IStackStringifyHandler> stackStringifyHandlers = new ArrayList<>();
static {
stackStringifyHandlers.add(new DefaultStackStringifyHandler());
stackStringifyHandlers.add(new GTFluidStackStringifyHandler());
}
public static NBTTagCompound itemStackToNBT(ItemStack stack)
{
return itemStackToNBT(stack, true);
}
public static NBTTagCompound itemStackToNBT(ItemStack stack, boolean saveStackSize)
{
NBTTagCompound nbTag = null;
ItemStack[] stacks = new ItemStack[]{stack};
for (int i = stackStringifyHandlers.size() - 1; i >= 0 && nbTag == null; i--) {
nbTag = stackStringifyHandlers.get(i).convertItemStackToNBT(stacks);
nbTag = stackStringifyHandlers.get(i).convertItemStackToNBT(stack, saveStackSize);
}
return nbTag;
@@ -34,26 +46,31 @@ public class StackInfo
return stack;
}
public static ItemStack normalize(ItemStack item) {
ItemStack copy = null;
for (int i = stackStringifyHandlers.size() - 1; i >= 0 && copy == null; i--) {
copy = stackStringifyHandlers.get(i).normalize(item);
}
return copy;
}
public static boolean equalItemAndNBT(ItemStack stackA, ItemStack stackB, boolean useNBT)
{
if (stackA.isItemEqual(stackB)) {
NBTTagCompound tagCompoundA = stackA.getTagCompound();
NBTTagCompound tagCompoundB = stackB.getTagCompound();
return !useNBT || (tagCompoundA == null && tagCompoundB == null) || (tagCompoundA != null && tagCompoundB != null && tagCompoundA.equals(tagCompoundB));
if (!stackA.isItemEqual(stackB)) {
return false;
}
return false;
if (useNBT) {
NBTTagCompound tagCompoundA = itemStackToNBT(stackA, false);
NBTTagCompound tagCompoundB = itemStackToNBT(stackB, false);
return tagCompoundA == null && tagCompoundB == null || tagCompoundA != null && tagCompoundB != null && tagCompoundA.equals(tagCompoundB);
}
return true;
}
public static FluidStack getFluid(ItemStack stack)
{
FluidStack fluid = null;
for (int i = stackStringifyHandlers.size() - 1; i >= 0 && fluid == null; i--) {
fluid = stackStringifyHandlers.get(i).getFluid(stack);
}
return fluid;
}
}