Search in sources :

Example 31 with NBTTagList

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"));
        }
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 32 with NBTTagList

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);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 33 with NBTTagList

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);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 34 with NBTTagList

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);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 35 with NBTTagList

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);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) PathPoint(net.minecraft.pathfinding.PathPoint) AmadronOfferCustom(pneumaticCraft.common.recipes.AmadronOfferCustom)

Aggregations

NBTTagList (net.minecraft.nbt.NBTTagList)451 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)385 ItemStack (net.minecraft.item.ItemStack)69 NBTTagString (net.minecraft.nbt.NBTTagString)42 BlockPos (net.minecraft.util.math.BlockPos)18 HashMap (java.util.HashMap)17 Map (java.util.Map)17 NotNull (org.jetbrains.annotations.NotNull)17 ArrayList (java.util.ArrayList)14 AMVector3 (am2.api.math.AMVector3)9 ChunkPosition (net.minecraft.world.ChunkPosition)9 NBTBase (net.minecraft.nbt.NBTBase)8 EntityPlayer (net.minecraft.entity.player.EntityPlayer)7 Vec3d (net.minecraft.util.math.Vec3d)7 WorldCoordinate (mods.railcraft.api.core.WorldCoordinate)6 Block (net.minecraft.block.Block)6 ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)5 Entity (net.minecraft.entity.Entity)5 TileEntity (net.minecraft.tileentity.TileEntity)5 ChunkPos (net.minecraft.util.math.ChunkPos)5