use of net.minecraft.nbt.NBTTagString in project BuildCraft by BuildCraft.
the class InvUtils method addItemToolTip.
public static void addItemToolTip(ItemStack stack, String msg) {
NBTTagCompound nbt = getItemData(stack);
NBTTagCompound display = nbt.getCompoundTag("display");
nbt.setTag("display", display);
NBTTagList lore = display.getTagList("Lore", Constants.NBT.TAG_STRING);
display.setTag("Lore", lore);
lore.appendTag(new NBTTagString(msg));
}
use of net.minecraft.nbt.NBTTagString in project Railcraft by Railcraft.
the class ItemRoutingTable method setPages.
public static void setPages(ItemStack routingTable, List<List<String>> pages) {
cleanEmptyPages(pages);
NBTTagList data = new NBTTagList();
for (List<String> page : pages) {
NBTTagList pageNBT = new NBTTagList();
data.appendTag(pageNBT);
for (String line : page) {
pageNBT.appendTag(new NBTTagString(line));
}
}
NBTTagCompound nbt = InvTools.getItemData(routingTable);
nbt.setTag("pages", data);
}
use of net.minecraft.nbt.NBTTagString in project Railcraft by Railcraft.
the class ItemRoutingTable method getContents.
@Nullable
public static Deque<String> getContents(ItemStack routingTable) {
if (InvTools.isEmpty(routingTable) || !isRoutingTable(routingTable))
return null;
NBTTagCompound nbt = routingTable.getTagCompound();
if (nbt == null)
return null;
Deque<String> contents = new LinkedList<>();
List<NBTTagList> pages = NBTPlugin.getNBTList(nbt, "pages", NBTTagList.class);
for (NBTTagList page : pages) {
List<NBTTagString> lines = NBTPlugin.asList(page);
for (NBTTagString line : lines) {
contents.add(line.getString());
}
}
return contents;
}
use of net.minecraft.nbt.NBTTagString in project PneumaticCraft by MineMaarten.
the class NBTToJsonConverter method getObject.
private JsonObject getObject(NBTTagCompound tag) {
Set<String> keys = tag.func_150296_c();
JsonObject jsonRoot = new JsonObject();
for (String key : keys) {
JsonObject keyObject = new JsonObject();
jsonRoot.add(key, keyObject);
NBTBase nbt = tag.getTag(key);
keyObject.addProperty("type", nbt.getId());
if (nbt instanceof NBTTagCompound) {
keyObject.add("value", getObject((NBTTagCompound) nbt));
} else if (nbt instanceof NBTPrimitive) {
keyObject.addProperty("value", ((NBTPrimitive) nbt).func_150286_g());
} else if (nbt instanceof NBTTagString) {
keyObject.addProperty("value", ((NBTTagString) nbt).func_150285_a_());
} else if (nbt instanceof NBTTagList) {
JsonArray array = new JsonArray();
NBTTagList tagList = (NBTTagList) nbt;
for (int i = 0; i < tagList.tagCount(); i++) {
array.add(getObject(tagList.getCompoundTagAt(i)));
}
keyObject.add("value", array);
} else if (nbt instanceof NBTTagIntArray) {
JsonArray array = new JsonArray();
NBTTagIntArray intArray = (NBTTagIntArray) nbt;
for (int i : intArray.func_150302_c()) {
array.add(new JsonPrimitive(i));
}
keyObject.add("value", array);
} else {
throw new IllegalArgumentException("NBT to JSON converter doesn't support the nbt tag: " + NBTBase.NBTTypes[nbt.getId()] + ", tag: " + nbt);
}
}
return jsonRoot;
}
use of net.minecraft.nbt.NBTTagString in project ArsMagica2 by Mithion.
the class Story method WriteMultiplePartsToNBT.
public void WriteMultiplePartsToNBT(NBTTagCompound compound, List<Short> parts) {
// title
NBTTagString title = new NBTTagString(this.title);
compound.setTag("title", title);
// author
NBTTagString author = new NBTTagString(this.author);
compound.setTag("author", author);
Collections.sort(parts);
NBTTagList pages = new NBTTagList();
for (Short i : parts) {
ArrayList<NBTTagString> storyData = getStoryPart(i);
if (storyData.equals(""))
continue;
for (NBTTagString page : storyData) {
pages.appendTag(page);
}
}
compound.setTag("pages", pages);
}
Aggregations