Search in sources :

Example 1 with Story

use of am2.lore.Story in project ArsMagica2 by Mithion.

the class ItemLostJournal method getSubItems.

@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List par3List) {
    super.getSubItems(item, par2CreativeTabs, par3List);
    int sCount = 0;
    for (Story s : StoryManager.INSTANCE.allStories()) {
        int meta = sCount << 16;
        for (short i = 0; i < s.getNumParts(); ++i) {
            meta = sCount + i;
            ItemStack stack = new ItemStack(item, 1, meta);
            stack.stackTagCompound = new NBTTagCompound();
            s.WritePartToNBT(stack.stackTagCompound, i);
            stack.stackTagCompound.setString("title", s.getTitle());
            par3List.add(stack);
        }
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) Story(am2.lore.Story) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 2 with Story

use of am2.lore.Story in project ArsMagica2 by Mithion.

the class ItemLostJournal method getStory.

public Story getStory(ItemStack stack) {
    if (stack.hasTagCompound()) {
        NBTTagCompound compound = stack.getTagCompound();
        String nbtTitle = compound.getString("title");
        Story s = StoryManager.INSTANCE.getByTitle(nbtTitle);
        return s;
    }
    return null;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Story(am2.lore.Story)

Aggregations

Story (am2.lore.Story)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 ItemStack (net.minecraft.item.ItemStack)1