Search in sources :

Example 1 with NBTTagString

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

the class ItemModule method addInformation.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean flag) {
    if (itemStack.hasTagCompound()) {
        NBTTagCompound nbt = itemStack.getTagCompound();
        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.tagList.get(i);
                    String data = ((NBTTagString) nbttag).func_150285_a_();
                    if (data.equals("<inventory>") && i + 1 < nbttaglist.tagCount()) {
                        nbttag = nbttaglist.tagList.get(i + 1);
                        data = ((NBTTagString) nbttag).func_150285_a_();
                        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 stack = inv.getIDStackInSlot(pos);
                                if (stack != null) {
                                    if (stack.getStackSize() > 1) {
                                        list.add("  " + stack.getStackSize() + "x " + stack.getFriendlyName());
                                    } else {
                                        list.add("  " + stack.getFriendlyName());
                                    }
                                }
                            }
                        }
                        i++;
                    } else {
                        list.add(data);
                    }
                }
            } else {
                list.add(StringUtils.translate(StringUtils.KEY_HOLDSHIFT));
            }
        } else {
            StringUtils.addShiftAddition(itemStack, list);
        }
    } else {
        StringUtils.addShiftAddition(itemStack, list);
    }
}
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)

Example 2 with NBTTagString

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

the class ItemPost method addInformation.

@Override
public void addInformation(ItemStack stack, EntityPlayer player, List<String> info, boolean adv) {
    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)
            info.add(TextFormatting.GRAY + emblem.displayName);
    }
}
Also used : Emblem(mods.railcraft.client.emblems.Emblem) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagString(net.minecraft.nbt.NBTTagString)

Example 3 with NBTTagString

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

the class BlockManaBattery method destroy.

private void destroy(World world, int i, int j, int k) {
    TileEntityManaBattery te = getTileEntity(world, i, j, k);
    if (te != null && !world.isRemote) {
        float f = world.rand.nextFloat() * 0.8F + 0.1F;
        float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
        float f2 = world.rand.nextFloat() * 0.8F + 0.1F;
        int dmg = (int) ((PowerNodeRegistry.For(world).getPower(te, te.getPowerType()) / te.getCapacity()) * 100);
        if (dmg == 0)
            dmg = 1;
        ItemStack stack = new ItemStack(this);
        stack.damageItem(stack.getMaxDamage() - dmg, new EntityDummyCaster(world));
        stack.stackTagCompound = new NBTTagCompound();
        stack.stackTagCompound.setFloat("mana_battery_charge", PowerNodeRegistry.For(world).getPower(te, te.getPowerType()));
        stack.stackTagCompound.setInteger("mana_battery_powertype", te.getPowerType().ID());
        if (!stack.stackTagCompound.hasKey("Lore"))
            stack.stackTagCompound.setTag("Lore", new NBTTagList());
        NBTTagList tagList = new NBTTagList();
        PowerTypes powerType = te.getPowerType();
        float amt = PowerNodeRegistry.For(world).getPower(te, powerType);
        tagList.appendTag(new NBTTagString(String.format("Contains %.2f %s%s etherium", amt, powerType.chatColor(), powerType.name())));
        stack.stackTagCompound.setTag("Lore", tagList);
        EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, stack);
        float f3 = 0.05F;
        entityitem.motionX = (float) world.rand.nextGaussian() * f3;
        entityitem.motionY = (float) world.rand.nextGaussian() * f3 + 0.2F;
        entityitem.motionZ = (float) world.rand.nextGaussian() * f3;
        world.spawnEntityInWorld(entityitem);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) PowerTypes(am2.api.power.PowerTypes) EntityDummyCaster(am2.entities.EntityDummyCaster) TileEntityManaBattery(am2.blocks.tileentities.TileEntityManaBattery) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagString(net.minecraft.nbt.NBTTagString) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Example 4 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project Totemic by TeamTotemic.

the class StateSelection method writeToNBT.

@Override
void writeToNBT(NBTTagCompound tag) {
    NBTTagList selectorsTag = new NBTTagList();
    for (MusicInstrument instr : selectors) selectorsTag.appendTag(new NBTTagString(instr.getRegistryName().toString()));
    tag.setTag("selectors", selectorsTag);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) MusicInstrument(pokefenn.totemic.api.music.MusicInstrument) NBTTagString(net.minecraft.nbt.NBTTagString)

Example 5 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project Totemic by TeamTotemic.

the class CamelCaseNamesTiles method fixTagCompound.

@Override
public NBTTagCompound fixTagCompound(NBTTagCompound compound) {
    switch(compound.getString("id")) {
        case "totemic:totem_base":
            int state = compound.getByte("state");
            switch(state) {
                case // StateSelection
                1:
                    NBTTagList selectorsTag = compound.getTagList("selectors", 8);
                    for (int i = 0; i < selectorsTag.tagCount(); i++) {
                        String name = checkAndFixName(selectorsTag.getStringTagAt(i), "Music Instrument");
                        selectorsTag.set(i, new NBTTagString(name));
                    }
                    break;
                case // StateStartup
                2:
                    String ceremonyName = compound.getString("ceremony");
                    compound.setString("ceremony", checkAndFixName(ceremonyName, "Ceremony"));
                    NBTTagCompound ceremonyMusic = compound.getCompoundTag("ceremonyMusic");
                    compound.setTag("ceremonyMusic", fixCompoundKeys(ceremonyMusic, "Music Instrument"));
                    NBTTagCompound timesPlayed = compound.getCompoundTag("timesPlayed");
                    compound.setTag("timesPlayed", fixCompoundKeys(timesPlayed, "Music Instrument"));
                    break;
                case // StateCeremonyEffect
                3:
                    ceremonyName = compound.getString("ceremony");
                    compound.setString("ceremony", checkAndFixName(ceremonyName, "Ceremony"));
                    break;
            }
            break;
        case "totemic:totem_pole":
            if (compound.hasKey("effect", Constants.NBT.TAG_STRING)) {
                String name = compound.getString("effect");
                compound.setString("effect", checkAndFixName(name, "Totem Effect"));
            }
            break;
    }
    return compound;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagString(net.minecraft.nbt.NBTTagString) NBTTagString(net.minecraft.nbt.NBTTagString)

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