mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-11 16:07:38 +00:00
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 <sborovetchi@estatim.com>
This commit is contained in:
1 parent
ce17ec8026
commit
5dde7cad8b
20 files changed
+1582
-591
No files matched your search
@@ -0,0 +1,56 @@
|
||||
package codechicken.nei.recipe.stackinfo;
|
||||
|
||||
import codechicken.nei.api.IStackStringifyHandler;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
|
||||
public class DefaultStackStringifyHandler implements IStackStringifyHandler
|
||||
{
|
||||
|
||||
public NBTTagCompound convertItemStackToNBT(ItemStack stack, boolean saveStackSize)
|
||||
{
|
||||
final NBTTagCompound nbTag = new NBTTagCompound();
|
||||
nbTag.setString("strId", Item.itemRegistry.getNameForObject(stack.getItem()));
|
||||
nbTag.setInteger("Count", saveStackSize? stack.stackSize: 1);
|
||||
nbTag.setShort("Damage", (short)stack.getItemDamage());
|
||||
|
||||
if (stack.hasTagCompound()) {
|
||||
nbTag.setTag("tag", stack.getTagCompound());
|
||||
}
|
||||
|
||||
return nbTag;
|
||||
}
|
||||
|
||||
public ItemStack convertNBTToItemStack(NBTTagCompound nbtTag)
|
||||
{
|
||||
final String strId = nbtTag.getString("strId");
|
||||
|
||||
nbtTag = (NBTTagCompound)nbtTag.copy();
|
||||
nbtTag.setInteger("id", GameData.getItemRegistry().getId(strId)); //getObject
|
||||
|
||||
final ItemStack stack = ItemStack.loadItemStackFromNBT(nbtTag);
|
||||
|
||||
if (stack != null) {
|
||||
stack.stackSize = nbtTag.getInteger("Count");
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
public FluidStack getFluid(ItemStack stack)
|
||||
{
|
||||
FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(stack);
|
||||
|
||||
if (fluidStack == null && stack.getItem() instanceof IFluidContainerItem) {
|
||||
fluidStack = ((IFluidContainerItem) stack.getItem()).getFluid(stack);
|
||||
}
|
||||
|
||||
return fluidStack;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user