use of net.minecraft.nbt.NBTTagList in project PneumaticCraft by MineMaarten.
the class AspectList method readFromNBT.
public void readFromNBT(NBTTagCompound nbttagcompound, String label) {
aspects.clear();
NBTTagList tlist = nbttagcompound.getTagList(label, (byte) 10);
for (int j = 0; j < tlist.tagCount(); j++) {
NBTTagCompound rs = (NBTTagCompound) tlist.getCompoundTagAt(j);
if (rs.hasKey("key")) {
add(Aspect.getAspect(rs.getString("key")), rs.getInteger("amount"));
}
}
}
use of net.minecraft.nbt.NBTTagList in project PneumaticCraft by MineMaarten.
the class AspectList method writeToNBT.
public void writeToNBT(NBTTagCompound nbttagcompound, String label) {
NBTTagList tlist = new NBTTagList();
nbttagcompound.setTag(label, tlist);
for (Aspect aspect : getAspects()) if (aspect != null) {
NBTTagCompound f = new NBTTagCompound();
f.setString("key", aspect.getTag());
f.setInteger("amount", getAmount(aspect));
tlist.appendTag(f);
}
}
use of net.minecraft.nbt.NBTTagList in project PneumaticCraft by MineMaarten.
the class AspectList method writeToNBT.
/**
* Writes the list of aspects to nbt
* @param nbttagcompound
* @return
*/
public void writeToNBT(NBTTagCompound nbttagcompound) {
NBTTagList tlist = new NBTTagList();
nbttagcompound.setTag("Aspects", tlist);
for (Aspect aspect : getAspects()) if (aspect != null) {
NBTTagCompound f = new NBTTagCompound();
f.setString("key", aspect.getTag());
f.setInteger("amount", getAmount(aspect));
tlist.appendTag(f);
}
}
use of net.minecraft.nbt.NBTTagList in project PneumaticCraft by MineMaarten.
the class ItemFocusBasic method setFocusUpgradeTagList.
private void setFocusUpgradeTagList(ItemStack focusstack, short[] upgrades) {
if (!focusstack.hasTagCompound())
focusstack.setTagCompound(new NBTTagCompound());
NBTTagCompound nbttagcompound = focusstack.getTagCompound();
NBTTagList tlist = new NBTTagList();
nbttagcompound.setTag("upgrade", tlist);
for (short id : upgrades) {
NBTTagCompound f = new NBTTagCompound();
f.setShort("id", id);
tlist.appendTag(f);
}
}
use of net.minecraft.nbt.NBTTagList in project PneumaticCraft by MineMaarten.
the class EntityDrone method writeEntityToNBT.
@Override
public void writeEntityToNBT(NBTTagCompound tag) {
super.writeEntityToNBT(tag);
TileEntityProgrammer.setWidgetsToNBT(progWidgets, tag);
tag.setBoolean("naturallySpawned", naturallySpawned);
tag.setFloat("currentAir", currentAir);
tag.setFloat("propSpeed", propSpeed);
tag.setBoolean("disabledByHacking", disabledByHacking);
tag.setBoolean("hackedByOwner", gotoOwnerAI != null);
tag.setInteger("color", getDroneColor());
tag.setBoolean("standby", standby);
tag.setFloat("volume", volume);
NBTTagCompound variableTag = new NBTTagCompound();
aiManager.writeToNBT(variableTag);
tag.setTag("variables", variableTag);
NBTTagCompound inv = new NBTTagCompound();
// Write the ItemStacks in the inventory to NBT
NBTTagList tagList = new NBTTagList();
for (int currentIndex = 0; currentIndex < inventory.getSizeInventory(); ++currentIndex) {
if (inventory.getStackInSlot(currentIndex) != null) {
NBTTagCompound tagCompound = new NBTTagCompound();
tagCompound.setByte("Slot", (byte) currentIndex);
inventory.getStackInSlot(currentIndex).writeToNBT(tagCompound);
tagList.appendTag(tagCompound);
}
}
inv.setTag("Inv", tagList);
NBTTagList upgradeList = new NBTTagList();
for (int i = 0; i < 9; i++) {
if (upgradeInventory[i] != null) {
NBTTagCompound slotEntry = new NBTTagCompound();
slotEntry.setByte("Slot", (byte) i);
upgradeInventory[i].writeToNBT(slotEntry);
upgradeList.appendTag(slotEntry);
}
}
// save content in Inventory->Items
inv.setTag("Items", upgradeList);
tag.setTag("Inventory", inv);
tank.writeToNBT(tag);
if (handlingOffer != null) {
NBTTagCompound subTag = new NBTTagCompound();
subTag.setBoolean("isCustom", handlingOffer instanceof AmadronOfferCustom);
handlingOffer.writeToNBT(subTag);
tag.setTag("amadronOffer", subTag);
tag.setInteger("offerTimes", offerTimes);
if (usedTablet != null)
usedTablet.writeToNBT(subTag);
tag.setString("buyingPlayer", buyingPlayer);
}
}
Aggregations