Search in sources :

Example 31 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project ArsMagica2 by Mithion.

the class Story method finalizeStory.

public static ItemStack finalizeStory(ItemStack stack, String title, String author) {
    if (stack.stackTagCompound == null)
        return stack;
    stack.stackTagCompound.setTag("title", new NBTTagString(title));
    stack.stackTagCompound.setTag("author", new NBTTagString(author));
    stack = InventoryUtilities.replaceItem(stack, Items.written_book);
    return stack;
}
Also used : NBTTagString(net.minecraft.nbt.NBTTagString)

Example 32 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project ArsMagica2 by Mithion.

the class Story method WritePartToNBT.

public void WritePartToNBT(NBTTagCompound compound, int part) {
    ArrayList<NBTTagString> storyData = getStoryPart(part);
    if (storyData.equals(""))
        return;
    // part
    compound.setInteger("story_part", part);
    // title
    NBTTagString title = new NBTTagString(this.title);
    compound.setTag("title", title);
    // author
    NBTTagString author = new NBTTagString(this.author);
    compound.setTag("author", author);
    // pages
    NBTTagList pages = new NBTTagList();
    for (NBTTagString page : storyData) {
        pages.appendTag(page);
    }
    compound.setTag("pages", pages);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagString(net.minecraft.nbt.NBTTagString)

Example 33 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project ArsMagica2 by Mithion.

the class Story method WritePartToNBT.

public static void WritePartToNBT(NBTTagCompound compound, ArrayList<NBTTagString> storyData) {
    // pages
    NBTTagList pages = new NBTTagList();
    for (NBTTagString page : storyData) {
        pages.appendTag(page);
    }
    compound.setTag("pages", pages);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagString(net.minecraft.nbt.NBTTagString)

Example 34 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project LogisticsPipes by RS485.

the class ItemModule method addInformation.

@Override
@SideOnly(Side.CLIENT)
public void addInformation(@Nonnull ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
    if (stack.hasTagCompound()) {
        NBTTagCompound nbt = stack.getTagCompound();
        assert nbt != null;
        if (nbt.hasKey("informationList")) {
            if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
                NBTTagList nbttaglist = nbt.getTagList("informationList", 8);
                for (int i = 0; i < nbttaglist.tagCount(); i++) {
                    Object nbttag = nbttaglist.get(i);
                    String data = ((NBTTagString) nbttag).getString();
                    if (data.equals("<inventory>") && i + 1 < nbttaglist.tagCount()) {
                        nbttag = nbttaglist.get(i + 1);
                        data = ((NBTTagString) nbttag).getString();
                        if (data.startsWith("<that>")) {
                            String prefix = data.substring(6);
                            NBTTagCompound module = nbt.getCompoundTag("moduleInformation");
                            int size = module.getTagList(prefix + "items", module.getId()).tagCount();
                            if (module.hasKey(prefix + "itemsCount")) {
                                size = module.getInteger(prefix + "itemsCount");
                            }
                            ItemIdentifierInventory inv = new ItemIdentifierInventory(size, "InformationTempInventory", Integer.MAX_VALUE);
                            inv.readFromNBT(module, prefix);
                            for (int pos = 0; pos < inv.getSizeInventory(); pos++) {
                                ItemIdentifierStack identStack = inv.getIDStackInSlot(pos);
                                if (identStack != null) {
                                    if (identStack.getStackSize() > 1) {
                                        tooltip.add("  " + identStack.getStackSize() + "x " + identStack.getFriendlyName());
                                    } else {
                                        tooltip.add("  " + identStack.getFriendlyName());
                                    }
                                }
                            }
                        }
                        i++;
                    } else {
                        tooltip.add(data);
                    }
                }
            } else {
                TextUtil.addTooltipInformation(stack, tooltip, false);
            }
        } else {
            TextUtil.addTooltipInformation(stack, tooltip, Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT));
        }
    } else {
        TextUtil.addTooltipInformation(stack, tooltip, Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT));
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemIdentifierInventory(logisticspipes.utils.item.ItemIdentifierInventory) NBTTagString(net.minecraft.nbt.NBTTagString) NBTTagString(net.minecraft.nbt.NBTTagString) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 35 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project LogisticsPipes by RS485.

the class ItemIdentifier method debugDumpTag.

private void debugDumpTag(NBTBase nbt, StringBuilder sb) {
    if (nbt == null) {
        sb.append("null");
        return;
    }
    if (nbt instanceof NBTTagByte) {
        sb.append("TagByte(data=").append(((NBTTagByte) nbt).getByte()).append(")");
    } else if (nbt instanceof NBTTagShort) {
        sb.append("TagShort(data=").append(((NBTTagShort) nbt).getShort()).append(")");
    } else if (nbt instanceof NBTTagInt) {
        sb.append("TagInt(data=").append(((NBTTagInt) nbt).getInt()).append(")");
    } else if (nbt instanceof NBTTagLong) {
        sb.append("TagLong(data=").append(((NBTTagLong) nbt).getLong()).append(")");
    } else if (nbt instanceof NBTTagFloat) {
        sb.append("TagFloat(data=").append(((NBTTagFloat) nbt).getFloat()).append(")");
    } else if (nbt instanceof NBTTagDouble) {
        sb.append("TagDouble(data=").append(((NBTTagDouble) nbt).getDouble()).append(")");
    } else if (nbt instanceof NBTTagString) {
        sb.append("TagString(data=\"").append(((NBTTagString) nbt).getString()).append("\")");
    } else if (nbt instanceof NBTTagByteArray) {
        sb.append("TagByteArray(data=");
        for (int i = 0; i < ((NBTTagByteArray) nbt).getByteArray().length; i++) {
            sb.append(((NBTTagByteArray) nbt).getByteArray()[i]);
            if (i < ((NBTTagByteArray) nbt).getByteArray().length - 1) {
                sb.append(",");
            }
        }
        sb.append(")");
    } else if (nbt instanceof NBTTagIntArray) {
        sb.append("TagIntArray(data=");
        for (int i = 0; i < ((NBTTagIntArray) nbt).getIntArray().length; i++) {
            sb.append(((NBTTagIntArray) nbt).getIntArray()[i]);
            if (i < ((NBTTagIntArray) nbt).getIntArray().length - 1) {
                sb.append(",");
            }
        }
        sb.append(")");
    } else if (nbt instanceof NBTTagList) {
        sb.append("TagList(data=");
        for (int i = 0; i < ((NBTTagList) nbt).tagCount(); i++) {
            debugDumpTag((((NBTTagList) nbt).get(i)), sb);
            if (i < ((NBTTagList) nbt).tagCount() - 1) {
                sb.append(",");
            }
        }
        sb.append(")");
    } else if (nbt instanceof NBTTagCompound) {
        sb.append("TagCompound(data=");
        for (Iterator<String> iter = ((NBTTagCompound) nbt).getKeySet().iterator(); iter.hasNext(); ) {
            String key = iter.next();
            NBTBase value = ((NBTTagCompound) nbt).getTag(key);
            sb.append("\"").append(key).append("\"=");
            debugDumpTag((value), sb);
            if (iter.hasNext()) {
                sb.append(",");
            }
        }
        sb.append(")");
    } else {
        sb.append(nbt.getClass().getName()).append("(?)");
    }
}
Also used : NBTTagFloat(net.minecraft.nbt.NBTTagFloat) NBTTagInt(net.minecraft.nbt.NBTTagInt) NBTTagByte(net.minecraft.nbt.NBTTagByte) FinalNBTTagCompound(logisticspipes.utils.FinalNBTTagCompound) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagString(net.minecraft.nbt.NBTTagString) NBTTagIntArray(net.minecraft.nbt.NBTTagIntArray) NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagShort(net.minecraft.nbt.NBTTagShort) NBTBase(net.minecraft.nbt.NBTBase) NBTTagString(net.minecraft.nbt.NBTTagString) NBTTagByteArray(net.minecraft.nbt.NBTTagByteArray) NBTTagLong(net.minecraft.nbt.NBTTagLong) NBTTagDouble(net.minecraft.nbt.NBTTagDouble)

Aggregations

NBTTagString (net.minecraft.nbt.NBTTagString)98 NBTTagList (net.minecraft.nbt.NBTTagList)79 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)57 ItemStack (net.minecraft.item.ItemStack)16 NBTTagIntArray (net.minecraft.nbt.NBTTagIntArray)11 NBTTagByteArray (net.minecraft.nbt.NBTTagByteArray)10 NBTTagInt (net.minecraft.nbt.NBTTagInt)10 NBTBase (net.minecraft.nbt.NBTBase)9 NBTTagDouble (net.minecraft.nbt.NBTTagDouble)9 NBTTagFloat (net.minecraft.nbt.NBTTagFloat)9 NBTTagByte (net.minecraft.nbt.NBTTagByte)8 NBTTagLong (net.minecraft.nbt.NBTTagLong)8 ResourceLocation (net.minecraft.util.ResourceLocation)8 NBTTagShort (net.minecraft.nbt.NBTTagShort)7 List (java.util.List)6 Map (java.util.Map)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Item (net.minecraft.item.Item)4