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;
}
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;
}
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;
}
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]));
});
}
}
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);
}
Aggregations