Search in sources :

Example 56 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project OpenLights by PC-Logix.

the class TileEntitySidedEnvironment method writeToNBT.

@Override
public void writeToNBT(NBTTagCompound nbt) {
    super.writeToNBT(nbt);
    int index = 0;
    for (Node node : nodes) {
        // See readFromNBT() regarding host check.
        if (node != null && node.host() == this) {
            final NBTTagCompound nodeNbt = new NBTTagCompound();
            node.save(nodeNbt);
            nbt.setTag("oc:node" + index, nodeNbt);
        }
        ++index;
    }
}
Also used : Node(li.cil.oc.api.network.Node) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 57 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project Witchworks by Um-Mitternacht.

the class BrewUtils method createBrew.

public static ItemStack createBrew(Item item, BrewEffect... effects) {
    ItemStack stack = new ItemStack(item);
    NBTTagList list = addBrewData(stack);
    for (BrewEffect effect : effects) {
        NBTTagCompound tag = new NBTTagCompound();
        IBrew brew = effect.getBrew();
        tag.setInteger(BREW_ID, BrewRegistry.getBrewId(brew));
        tag.setInteger(BREW_AMPLIFIER, effect.getAmplifier());
        tag.setInteger(BREW_DURATION, effect.getDuration());
        list.appendTag(tag);
    }
    return stack;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) BrewEffect(com.witchworks.api.item.BrewEffect) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) IBrew(com.witchworks.api.item.IBrew)

Example 58 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project Witchworks by Um-Mitternacht.

the class BrewUtils method serialize.

public static NBTTagCompound serialize(Collection<Object> collection) {
    List<BrewEffect> brewEffects = new ArrayList<>();
    List<PotionEffect> potionEffects = new ArrayList<>();
    for (Object brew : collection) {
        if (brew instanceof BrewEffect) {
            brewEffects.add((BrewEffect) brew);
        } else if (brew instanceof PotionEffect) {
            potionEffects.add((PotionEffect) brew);
        }
    }
    NBTTagCompound compound = new NBTTagCompound();
    appendPotions(compound, mixPotions(potionEffects));
    appendBrews(compound, mixBrews(brewEffects));
    return compound;
}
Also used : BrewEffect(com.witchworks.api.item.BrewEffect) PotionEffect(net.minecraft.potion.PotionEffect) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 59 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project Witchworks by Um-Mitternacht.

the class BrewUtils method appendPotions.

public static void appendPotions(NBTTagCompound tag, Collection<PotionEffect> effects) {
    NBTTagList tagList = tag.getTagList("CustomPotionEffects", 9);
    for (PotionEffect potioneffect : effects) {
        tagList.appendTag(potioneffect.writeCustomPotionEffectToNBT(new NBTTagCompound()));
    }
    tag.setTag("CustomPotionEffects", tagList);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) PotionEffect(net.minecraft.potion.PotionEffect) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 60 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project Witchworks by Um-Mitternacht.

the class RitualHolder method writeNBT.

public void writeNBT(NBTTagCompound cmp) {
    NBTTagCompound tag = new NBTTagCompound();
    tag.setInteger("ritual", KettleRegistry.getRituals().indexOf(ritual));
    tag.setInteger("energy_left", energy_left);
    tag.setInteger("ticks", ticks);
    tag.setBoolean("fail", fail);
    cmp.setTag("ritual_data", tag);
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Aggregations

NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3985 NBTTagList (net.minecraft.nbt.NBTTagList)1052 ItemStack (net.minecraft.item.ItemStack)883 BlockPos (net.minecraft.util.math.BlockPos)229 TileEntity (net.minecraft.tileentity.TileEntity)173 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)148 ArrayList (java.util.ArrayList)99 Block (net.minecraft.block.Block)98 ResourceLocation (net.minecraft.util.ResourceLocation)96 IBlockState (net.minecraft.block.state.IBlockState)92 EntityPlayer (net.minecraft.entity.player.EntityPlayer)81 NBTTagString (net.minecraft.nbt.NBTTagString)79 Nonnull (javax.annotation.Nonnull)74 Map (java.util.Map)71 UUID (java.util.UUID)69 NBTBase (net.minecraft.nbt.NBTBase)66 HashMap (java.util.HashMap)64 EnumFacing (net.minecraft.util.EnumFacing)61 NotNull (org.jetbrains.annotations.NotNull)60 Item (net.minecraft.item.Item)55