Search in sources :

Example 96 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project Railcraft by Railcraft.

the class InvTools method addItemToolTip.

// @Deprecated
// public static boolean isSynthetic(ItemStack stack) {
// NBTTagCompound nbt = stack.getTagCompound();
// return nbt != null && nbt.hasKey("synthetic");
// }
// 
// @SuppressWarnings("unused")
// public static void markItemSynthetic(ItemStack stack) {
// NBTTagCompound nbt = getItemData(stack);
// nbt.setBoolean("synthetic", true);
// NBTTagCompound display = nbt.getCompoundTag("display");
// nbt.setTag("display", display);
// NBTTagList lore = display.getTagList("Lore", 8);
// display.setTag("Lore", lore);
// lore.appendTag(new NBTTagString("\u00a77\u00a7o" + LocalizationPlugin.translate("item.synthetic")));
// }
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", 8);
    display.setTag("Lore", lore);
    lore.appendTag(new NBTTagString(msg));
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagString(net.minecraft.nbt.NBTTagString)

Example 97 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project Railcraft by Railcraft.

the class ItemPost method addInformation.

@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack stack, @Nullable World world, List<String> tooltip, ITooltipFlag flag) {
    if (stack.getItemDamage() == EnumPost.EMBLEM.ordinal() && stack.hasTagCompound()) {
        NBTTagCompound nbt = stack.getTagCompound();
        NBTTagString emblemIdent = (NBTTagString) nbt.getTag("emblem");
        if (emblemIdent == null || EmblemToolsClient.packageManager == null)
            return;
        Emblem emblem = EmblemToolsClient.packageManager.getEmblem(emblemIdent.getString());
        if (emblem != null)
            tooltip.add(TextFormatting.GRAY + emblem.displayName);
    }
}
Also used : Emblem(mods.railcraft.client.emblems.Emblem) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagString(net.minecraft.nbt.NBTTagString) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 98 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project Railcraft by Railcraft.

the class ItemRoutingTable method getPages.

@Nullable
public static List<List<String>> getPages(ItemStack routingTable) {
    if (InvTools.isEmpty(routingTable) || !isRoutingTable(routingTable))
        return null;
    NBTTagCompound nbt = routingTable.getTagCompound();
    if (nbt == null)
        return null;
    List<NBTTagList> pagesList = NBTPlugin.getNBTList(nbt, "pages", NBTTagList.class);
    List<List<String>> contents = new ArrayList<>();
    for (NBTTagList pageNBT : pagesList) {
        List<NBTTagString> pageList = NBTPlugin.asList(pageNBT);
        List<String> page = new ArrayList<>();
        contents.add(page);
        for (NBTTagString line : pageList) {
            page.add(line.getString());
        }
    }
    return contents;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagString(net.minecraft.nbt.NBTTagString) NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagString(net.minecraft.nbt.NBTTagString) Nullable(org.jetbrains.annotations.Nullable)

Example 99 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project Wizardry by TeamWizardry.

the class SpellUtils method deserializeModuleList.

public static List<List<ModuleInstance>> deserializeModuleList(@Nonnull NBTTagList list) {
    List<List<ModuleInstance>> modules = new ArrayList<>();
    List<ModuleInstance> moduleList = new ArrayList<>();
    for (int i = 0; i < list.tagCount(); i++) {
        NBTBase base = list.get(i);
        if (!(base instanceof NBTTagString))
            continue;
        NBTTagString string = (NBTTagString) base;
        if (string.isEmpty()) {
            if (!moduleList.isEmpty())
                modules.add(moduleList);
            moduleList = new ArrayList<>();
        }
        ModuleInstance module = ModuleInstance.deserialize(string);
        if (module == null)
            continue;
        moduleList.add(module);
    }
    if (!moduleList.isEmpty())
        modules.add(moduleList);
    return modules;
}
Also used : NBTBase(net.minecraft.nbt.NBTBase) ArrayList(java.util.ArrayList) NBTTagString(net.minecraft.nbt.NBTTagString) ArrayList(java.util.ArrayList) NBTTagList(net.minecraft.nbt.NBTTagList) List(java.util.List) ModuleInstance(com.teamwizardry.wizardry.api.spell.module.ModuleInstance)

Example 100 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project Wizardry by TeamWizardry.

the class TileHaloInfuser method updateItems.

public void updateItems(boolean soft) {
    NBTTagList slots = NBTHelper.getList(getHalo(), "slots", NBTTagString.class);
    if (slots == null || slots.tagCount() < HaloInfusionItemRegistry.getItems().size() - 1) {
        slots = new NBTTagList();
        for (int i = 0; i < HaloInfusionItemRegistry.getItems().size(); i++) {
            slots.appendTag(new NBTTagString(HaloInfusionItemRegistry.EMPTY.getNbtName()));
        }
        NBTHelper.setList(getHalo(), "slots", slots);
    }
    for (int i = 0; i < HaloInfusionItemRegistry.getItems().size(); i++) {
        EntityHaloInfusionItem entity = entities.get(i);
        String itemName = slots.getStringTagAt(i);
        entity.setHaloInfusionItem(HaloInfusionItemRegistry.getItemFromName(itemName), soft);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagString(net.minecraft.nbt.NBTTagString) EntityHaloInfusionItem(com.teamwizardry.wizardry.common.entity.EntityHaloInfusionItem) NBTTagString(net.minecraft.nbt.NBTTagString)

Aggregations

NBTTagString (net.minecraft.nbt.NBTTagString)101 NBTTagList (net.minecraft.nbt.NBTTagList)82 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)57 ItemStack (net.minecraft.item.ItemStack)18 NBTTagIntArray (net.minecraft.nbt.NBTTagIntArray)11 NBTBase (net.minecraft.nbt.NBTBase)10 NBTTagByteArray (net.minecraft.nbt.NBTTagByteArray)10 NBTTagInt (net.minecraft.nbt.NBTTagInt)10 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 List (java.util.List)7 NBTTagShort (net.minecraft.nbt.NBTTagShort)7 ArrayList (java.util.ArrayList)5 Map (java.util.Map)5 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 Item (net.minecraft.item.Item)4