package loordgek.itemhandlerv2.captest;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public class lol {
public static boolean somthing = false;
public ItemStack createNewStack(){
somthing = true;
ItemStack stack = new ItemStack(Items.ITEM_FRAME);
if (!stack.hasTagCompound())
stack.setTagCompound(new NBTTagCompound());
stack.getTagCompound().setBoolean("somthing", true);
somthing = false;
return stack;
}
//note you should a bool to the rhe nbt of the sack if you want the cap to survive between saves
@SubscribeEvent
public void onAttachCapabilities(AttachCapabilitiesEvent<ItemStack> event) {
if (event.getObject().hasTagCompound()){
if (event.getObject().getTagCompound().hasKey("somthing"))
//add a cap here
}
if (somthing)// i made the stack
{
//add a cap here
}
}
}