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;
}
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);
}
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);
}
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));
}
}
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("(?)");
}
}
Aggregations