Search in sources :

Example 61 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project Charset by CharsetMC.

the class TileEntityDayBarrel method addUpgrade.

// TODO: Handle invalid combinations somewhere?
static ItemStack addUpgrade(ItemStack barrel, BarrelUpgrade upgrade) {
    NBTTagCompound tag = ItemUtils.getTagCompound(barrel, true);
    NBTTagList list;
    if (!tag.hasKey("upgrades")) {
        list = new NBTTagList();
    } else {
        list = tag.getTagList("upgrades", Constants.NBT.TAG_STRING);
        for (int i = 0; i < list.tagCount(); i++) {
            if (list.getStringTagAt(i).equals(upgrade.name())) {
                return barrel;
            }
        }
    }
    list.appendTag(new NBTTagString(upgrade.name()));
    if (list.tagCount() > 0) {
        tag.setTag("upgrades", list);
    }
    return barrel;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagString(net.minecraft.nbt.NBTTagString)

Example 62 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project BiomeTweaker by superckl.

the class WorldSavedDataASMTweaks method writeToNBT.

@Override
public NBTTagCompound writeToNBT(final NBTTagCompound compound) {
    final NBTTagList list = new NBTTagList();
    BiomeTweaker.getInstance().getEnabledTweaks().forEach(t -> {
        list.appendTag(new NBTTagString(t));
    });
    compound.setTag("asmtweaks", list);
    return compound;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagString(net.minecraft.nbt.NBTTagString)

Example 63 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project TecTech by Technus.

the class GT_MetaTileEntity_EM_research method outputAfterRecipe_EM.

@Override
public void outputAfterRecipe_EM() {
    if (!eHolders.isEmpty()) {
        if (tRecipe != null && ItemList.Tool_DataStick.isStackEqual(mInventory[1], false, true)) {
            eHolders.get(0).getBaseMetaTileEntity().setActive(false);
            eHolders.get(0).mInventory[0] = null;
            mInventory[1].setStackDisplayName(GT_LanguageManager.getTranslation(tRecipe.mOutput.getDisplayName()) + " Construction Data");
            // code above makes it not null
            NBTTagCompound tNBT = mInventory[1].getTagCompound();
            tNBT.setTag("output", tRecipe.mOutput.writeToNBT(new NBTTagCompound()));
            tNBT.setInteger("time", tRecipe.mDuration);
            tNBT.setInteger("eu", tRecipe.mEUt);
            for (int i = 0; i < tRecipe.mInputs.length; i++) {
                tNBT.setTag(String.valueOf(i), tRecipe.mInputs[i].writeToNBT(new NBTTagCompound()));
            }
            for (int i = 0; i < tRecipe.mFluidInputs.length; i++) {
                tNBT.setTag("f" + i, tRecipe.mFluidInputs[i].writeToNBT(new NBTTagCompound()));
            }
            tNBT.setString("author", EnumChatFormatting.BLUE + "Tec" + EnumChatFormatting.DARK_BLUE + "Tech" + EnumChatFormatting.WHITE + " Assembling Line Recipe Generator");
            NBTTagList tNBTList = new NBTTagList();
            tNBTList.appendTag(new NBTTagString("Construction plan for " + tRecipe.mOutput.stackSize + ' ' + GT_LanguageManager.getTranslation(tRecipe.mOutput.getDisplayName()) + ". Needed EU/t: " + tRecipe.mEUt + " Production time: " + tRecipe.mDuration / 20));
            for (int i = 0; i < tRecipe.mInputs.length; i++) {
                if (tRecipe.mInputs[i] != null) {
                    tNBTList.appendTag(new NBTTagString("Input Bus " + (i + 1) + ": " + tRecipe.mInputs[i].stackSize + ' ' + GT_LanguageManager.getTranslation(tRecipe.mInputs[i].getDisplayName())));
                }
            }
            for (int i = 0; i < tRecipe.mFluidInputs.length; i++) {
                if (tRecipe.mFluidInputs[i] != null) {
                    tNBTList.appendTag(new NBTTagString("Input Hatch " + (i + 1) + ": " + tRecipe.mFluidInputs[i].amount + "L " + GT_LanguageManager.getTranslation(tRecipe.mFluidInputs[i].getLocalizedName())));
                }
            }
            tNBT.setTag("pages", tNBTList);
        } else if (aRecipe != null && ItemList.Tool_DataOrb.isStackEqual(mInventory[1], false, true)) {
            eHolders.get(0).getBaseMetaTileEntity().setActive(false);
            eHolders.get(0).mInventory[0] = null;
            mInventory[1].setStackDisplayName(GT_LanguageManager.getTranslation(aRecipe.mOutputs[0].getDisplayName()) + ' ' + machineType + " Construction Data");
            // code above makes it not null
            NBTTagCompound tNBT = mInventory[1].getTagCompound();
            tNBT.setString("eMachineType", machineType);
            GameRegistry.UniqueIdentifier uid = GameRegistry.findUniqueIdentifierFor(aRecipe.mOutputs[0].getItem());
            tNBT.setString(E_RECIPE_ID, uid + ":" + aRecipe.mOutputs[0].getItemDamage());
            tNBT.setString("author", EnumChatFormatting.BLUE + "Tec" + EnumChatFormatting.DARK_BLUE + "Tech" + EnumChatFormatting.WHITE + ' ' + machineType + " Recipe Generator");
        }
    }
    computationRequired = computationRemaining = 0;
    tRecipe = null;
    aRecipe = null;
    holdItem = null;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagString(net.minecraft.nbt.NBTTagString)

Example 64 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project Bewitchment by Um-Mitternacht.

the class TileEntityGlyph method readDataNBT.

@Override
protected void readDataNBT(NBTTagCompound tag) {
    cooldown = tag.getInteger("cooldown");
    if (tag.hasKey("ritual"))
        ritual = AdapterIRitual.REGISTRY.getValue(new ResourceLocation(tag.getString("ritual")));
    if (tag.hasKey("player"))
        entityPlayer = UUID.fromString(tag.getString("player"));
    if (tag.hasKey("data"))
        ritualData = tag.getCompoundTag("data");
    if (tag.hasKey("entityList")) {
        entityList = new ArrayList<Tuple<String, String>>();
        tag.getTagList("entityList", NBT.TAG_STRING).forEach(nbts -> {
            String[] names = ((NBTTagString) nbts).getString().split("!");
            if (names.length == 2)
                entityList.add(new Tuple<String, String>(names[0], names[1]));
        });
    }
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) NBTTagString(net.minecraft.nbt.NBTTagString) Tuple(net.minecraft.util.Tuple)

Example 65 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project Bewitchment by Um-Mitternacht.

the class TileEntityGlyph method writeDataNBT.

@Override
protected void writeDataNBT(NBTTagCompound tag) {
    tag.setInteger("cooldown", cooldown);
    if (ritual != null)
        tag.setString("ritual", ritual.getRegistryName().toString());
    if (entityPlayer != null)
        tag.setString("player", entityPlayer.toString());
    if (ritualData != null)
        tag.setTag("data", ritualData);
    NBTTagList list = new NBTTagList();
    for (int i = 0; i < entityList.size(); i++) {
        Tuple<String, String> t = entityList.get(i);
        list.appendTag(new NBTTagString(t.getFirst() + "!" + t.getSecond()));
    }
    tag.setTag("entityList", list);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagString(net.minecraft.nbt.NBTTagString) 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