use of net.minecraft.nbt.NBTTagList in project PneumaticCraft by MineMaarten.
the class HeatExchangerLogic method readFromNBT.
@Override
public void readFromNBT(NBTTagCompound tag) {
temperature = tag.getDouble("temperature");
behaviours.clear();
NBTTagList tagList = tag.getTagList("behaviours", 10);
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound t = tagList.getCompoundTagAt(i);
HeatBehaviour behaviour = HeatBehaviourManager.getInstance().getBehaviourForId(t.getString("id"));
if (behaviour != null) {
behaviour.readFromNBT(t);
behaviours.add(behaviour);
}
}
}
use of net.minecraft.nbt.NBTTagList in project PneumaticCraft by MineMaarten.
the class ItemPneumaticArmor method getUpgradeStacks.
/**
* Retrieves the upgrades currently installed on the given armor stack.
*/
public static ItemStack[] getUpgradeStacks(ItemStack iStack) {
NBTTagCompound tag = NBTUtil.getCompoundTag(iStack, "UpgradeInventory");
ItemStack[] inventoryStacks = new ItemStack[9];
if (tag != null) {
NBTTagList itemList = tag.getTagList("Items", 10);
if (itemList != null) {
for (int i = 0; i < itemList.tagCount(); i++) {
NBTTagCompound slotEntry = itemList.getCompoundTagAt(i);
int j = slotEntry.getByte("Slot");
if (j >= 0 && j < 9) {
inventoryStacks[j] = ItemStack.loadItemStackFromNBT(slotEntry);
}
}
}
}
return inventoryStacks;
}
use of net.minecraft.nbt.NBTTagList in project PneumaticCraft by MineMaarten.
the class InventoryPneumaticInventoryItem method writeToNBT.
/**
* Writes a NBT Node with inventory.
*
* @param outerTag
* The NBT Node to write to.
* @return The written NBT Node.
*/
public void writeToNBT() {
NBTTagList itemList = new NBTTagList();
for (int i = 0; i < getSizeInventory(); i++) {
if (getStackInSlot(i) != null) {
NBTTagCompound slotEntry = new NBTTagCompound();
slotEntry.setByte("Slot", (byte) i);
getStackInSlot(i).writeToNBT(slotEntry);
itemList.appendTag(slotEntry);
}
}
// save content in Inventory->Items
NBTTagCompound inventory = new NBTTagCompound();
inventory.setTag("Items", itemList);
NBTUtil.setCompoundTag(armorStack, "UpgradeInventory", inventory);
NBTUtil.removeTag(armorStack, "Inventory");
// return outerTag;
}
use of net.minecraft.nbt.NBTTagList in project PneumaticCraft by MineMaarten.
the class InventoryPneumaticInventoryItem method readFromNBT.
/**
* Reads the inventory from a NBT Node.
*
* @param outerTag
* The NBT Node to read from.
*/
protected void readFromNBT() {
reading = true;
if (NBTUtil.hasTag(armorStack, "Inventory") && armorStack.getTagCompound().getTag("Inventory") instanceof NBTTagCompound) {
Log.info("Converting 'Inventory' tag to 'UpgradeInventory' in Pneumatic items");
armorStack.getTagCompound().setTag("UpgradeInventory", armorStack.getTagCompound().getTag("Inventory"));
armorStack.getTagCompound().removeTag("Inventory");
}
NBTTagList itemList = NBTUtil.getCompoundTag(armorStack, "UpgradeInventory").getTagList("Items", 10);
for (int i = 0; i < itemList.tagCount(); i++) {
NBTTagCompound slotEntry = itemList.getCompoundTagAt(i);
int j = slotEntry.getByte("Slot");
if (j >= 0 && j < getSizeInventory()) {
setInventorySlotContents(j, ItemStack.loadItemStackFromNBT(slotEntry));
}
}
reading = false;
}
use of net.minecraft.nbt.NBTTagList in project PneumaticCraft by MineMaarten.
the class ItemAmadronTablet method getShoppingCart.
public static Map<AmadronOffer, Integer> getShoppingCart(ItemStack tablet) {
Map<AmadronOffer, Integer> offers = new HashMap<AmadronOffer, Integer>();
if (tablet.hasTagCompound() && tablet.getTagCompound().hasKey("shoppingCart")) {
NBTTagList list = tablet.getTagCompound().getTagList("shoppingCart", 10);
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound tag = list.getCompoundTagAt(i);
offers.put(tag.hasKey("inStock") ? AmadronOfferCustom.loadFromNBT(tag) : AmadronOffer.loadFromNBT(tag), tag.getInteger("amount"));
}
}
return offers;
}
Aggregations