Search in sources :

Example 41 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project ImmersiveEngineering by BluSunrize.

the class TileEntityTurret method writeCustomNBT.

@Override
public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) {
    nbt.setBoolean("dummy", dummy);
    nbt.setBoolean("redstoneInverted", redstoneControlInverted);
    if (facing != null)
        nbt.setInteger("facing", facing.ordinal());
    energyStorage.writeToNBT(nbt);
    if (owner != null)
        nbt.setString("owner", owner);
    NBTTagList list = new NBTTagList();
    for (String s : targetList) list.appendTag(new NBTTagString(s));
    nbt.setTag("targetList", list);
    nbt.setBoolean("whitelist", whitelist);
    nbt.setBoolean("attackAnimals", attackAnimals);
    nbt.setBoolean("attackPlayers", attackPlayers);
    nbt.setBoolean("attackNeutrals", attackNeutrals);
    if (target != null)
        nbt.setString("target", target.getUniqueID().toString());
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagString(net.minecraft.nbt.NBTTagString) NBTTagString(net.minecraft.nbt.NBTTagString)

Example 42 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project GregTech by GregTechCE.

the class TileEntitySurfaceRock method readFromNBT.

@Override
public void readFromNBT(NBTTagCompound compound) {
    super.readFromNBT(compound);
    Material material = Material.MATERIAL_REGISTRY.getObject(compound.getString("Material"));
    this.material = material == null ? Materials.Aluminium : material;
    for (NBTBase undergroundMaterialNBTBase : compound.getTagList("UndergroundMaterials", NBT.TAG_STRING)) {
        undergroundMaterials.add(Material.MATERIAL_REGISTRY.getObject(((NBTTagString) undergroundMaterialNBTBase).getString()));
    }
}
Also used : NBTBase(net.minecraft.nbt.NBTBase) NBTTagString(net.minecraft.nbt.NBTTagString) Material(gregtech.api.unification.material.type.Material)

Example 43 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project Almura by AlmuraDev.

the class LookingDebugPanel method renderEntity.

private void renderEntity(final Entity entity) {
    final boolean player = entity instanceof EntityPlayer;
    boolean drewItem = false;
    ResourceLocation id;
    if (player) {
        id = EntityListAccessor.accessor$getPlayerResourceLocation();
    } else {
        id = EntityList.getKey(entity);
    }
    if (id != null) {
        if (!player) {
            // Draw egg, if available
            if (EntityList.ENTITY_EGGS.containsKey(id)) {
                final ItemStack item = new ItemStack(Items.SPAWN_EGG);
                ItemMonsterPlacer.applyEntityIdToItemStack(item, id);
                this.drawItem(item, 4, this.autoHeight + 4);
                drewItem = true;
            } else {
                this.autoHeight += ITEM_HEIGHT_OFFSET;
            }
        } else {
            // Draw the skull of the player
            final ItemStack skull = new ItemStack(Items.SKULL, 1, 3);
            final NBTTagCompound tag = new NBTTagCompound();
            tag.setTag("SkullOwner", new NBTTagString(entity.getName()));
            skull.setTagCompound(tag);
            this.drawItem(skull, 4, this.autoHeight + 4);
            drewItem = true;
        }
        this.drawText(Text.of(TextColors.WHITE, id.toString()), drewItem ? 24 : 4, this.autoHeight - 14, false, true);
        this.autoHeight -= 2;
        if (entity.hasCustomName() || player) {
            this.drawProperty("name", entity.getName(), drewItem ? 24 : 4, this.autoHeight);
        }
    }
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayer(net.minecraft.entity.player.EntityPlayer) NBTTagString(net.minecraft.nbt.NBTTagString) ItemStack(net.minecraft.item.ItemStack)

Example 44 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project Minechem by iopleke.

the class JournalItem method writeKnowledge.

/**
     * Writes knowledge to the journal
     *
     * @param itemStack the journal stack
     * @param player    the player that writes the knowledge
     * @param isRemote  is the world remote on true it will send a {@link minechem.handler.message.JournalMessage} to the server
     */
public void writeKnowledge(ItemStack itemStack, EntityPlayer player, boolean isRemote) {
    if (isRemote) {
        MessageHandler.INSTANCE.sendToServer(new JournalMessage(player));
        return;
    }
    NBTTagCompound tagCompound = itemStack.stackTagCompound;
    Set<String> playerKnowledge = ResearchRegistry.getInstance().getResearchFor(player);
    if (playerKnowledge == null) {
        return;
    }
    Set<String> bookKnowledge = new LinkedHashSet<String>();
    if (tagCompound == null) {
        tagCompound = new NBTTagCompound();
    } else if (tagCompound.hasKey("research")) {
        NBTTagList bookKnowledgeTag = tagCompound.getTagList("research", 8);
        for (int i = 0; i < bookKnowledgeTag.tagCount(); i++) {
            bookKnowledge.add(bookKnowledgeTag.getStringTagAt(i));
        }
    }
    bookKnowledge.addAll(playerKnowledge);
    NBTTagList bookKnowledgeTag = new NBTTagList();
    for (String knowledgeKey : bookKnowledge) {
        bookKnowledgeTag.appendTag(new NBTTagString(knowledgeKey));
    }
    tagCompound.setTag("research", bookKnowledgeTag);
    Set<String> authors = new LinkedHashSet<String>();
    if (tagCompound.hasKey("authors")) {
        NBTTagList authorsTag = tagCompound.getTagList("authors", 8);
        for (int i = 0; i < authorsTag.tagCount(); i++) {
            authors.add(authorsTag.getStringTagAt(i));
        }
    }
    authors.add(player.getDisplayName());
    NBTTagList authorsTag = new NBTTagList();
    for (String author : authors) {
        authorsTag.appendTag(new NBTTagString(author));
    }
    tagCompound.setTag("authors", authorsTag);
    itemStack.setTagCompound(tagCompound);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) NBTTagList(net.minecraft.nbt.NBTTagList) JournalMessage(minechem.handler.message.JournalMessage) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagString(net.minecraft.nbt.NBTTagString) NBTTagString(net.minecraft.nbt.NBTTagString)

Example 45 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project Minechem by iopleke.

the class AugmentedItem method setAugment.

/**
     * Set {@link minechem.item.augment.augments.IAugment} on Item
     *
     * @param item        ItemStack to add augment to
     * @param augmentItem Augment to add
     */
@Override
public boolean setAugment(ItemStack item, ItemStack augmentItem) {
    IAugment augment = AugmentRegistry.getAugment(augmentItem);
    if (augment == null) {
        return false;
    }
    if (!item.hasTagCompound()) {
        item.setTagCompound(new NBTTagCompound());
    }
    NBTTagCompound tagCompound = item.getTagCompound();
    String augmentKey = augment.getKey();
    if (!tagCompound.hasKey(augmentKey, Compendium.NBTTags.tagCompound)) {
        NBTTagList augments = tagCompound.getTagList(augmentList, Compendium.NBTTags.tagString);
        augments.appendTag(new NBTTagString(augmentKey));
        tagCompound.setTag(augmentList, augments);
        NBTTagCompound augmentTag = new NBTTagCompound();
        augmentTag.setTag(Compendium.NBTTags.item, augmentItem.writeToNBT(new NBTTagCompound()));
        augmentTag.setByte(this.level, (byte) 0);
        tagCompound.setTag(augmentKey, augmentTag);
        return true;
    }
    return false;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) IAugment(minechem.item.augment.augments.IAugment) 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