Search in sources :

Example 6 with NemezTracker

use of com.teamwizardry.wizardry.common.core.nemez.NemezTracker in project Wizardry by TeamWizardry.

the class StandardWizardryWorld method deserializeNBT.

@Override
public void deserializeNBT(NBTTagCompound compound) {
    if (compound.hasKey("spell_object_manager")) {
        spellObjectManager = new SpellObjectManager();
        spellObjectManager.manager.fromNbt(compound.getCompoundTag("spell_object_manager"));
    }
    if (compound.hasKey("drives")) {
        NBTTagList driveNBT = compound.getTagList("drives", Constants.NBT.TAG_COMPOUND);
        for (NBTBase base : driveNBT) {
            if (base instanceof NBTTagCompound) {
                if (((NBTTagCompound) base).hasKey("pos") && ((NBTTagCompound) base).hasKey("drive")) {
                    BlockPos pos = BlockPos.fromLong(((NBTTagCompound) base).getLong("pos"));
                    NemezTracker tracker = new NemezTracker();
                    tracker.deserializeNBT(((NBTTagCompound) base).getTagList("drive", Constants.NBT.TAG_COMPOUND));
                    blockNemezDrives.put(pos, tracker);
                }
            }
        }
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTBase(net.minecraft.nbt.NBTBase) NemezTracker(com.teamwizardry.wizardry.common.core.nemez.NemezTracker) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) BlockPos(net.minecraft.util.math.BlockPos) SpellObjectManager(com.teamwizardry.wizardry.api.SpellObjectManager)

Example 7 with NemezTracker

use of com.teamwizardry.wizardry.common.core.nemez.NemezTracker in project Wizardry by TeamWizardry.

the class StandardWizardryWorld method serializeNBT.

@Override
public NBTTagCompound serializeNBT() {
    NBTTagCompound compound = new NBTTagCompound();
    compound.setTag("spell_object_manager", spellObjectManager.manager.toNbt());
    NBTTagList driveNBT = new NBTTagList();
    for (Map.Entry<BlockPos, NemezTracker> entry : blockNemezDrives.entrySet()) {
        if (entry == null)
            continue;
        NBTTagCompound compound1 = new NBTTagCompound();
        compound1.setLong("pos", entry.getKey().toLong());
        compound1.setTag("drive", entry.getValue().serializeNBT());
        driveNBT.appendTag(compound1);
    }
    compound.setTag("drives", driveNBT);
    return compound;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NemezTracker(com.teamwizardry.wizardry.common.core.nemez.NemezTracker) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) BlockPos(net.minecraft.util.math.BlockPos) HashMap(java.util.HashMap) Map(java.util.Map)

Example 8 with NemezTracker

use of com.teamwizardry.wizardry.common.core.nemez.NemezTracker in project Wizardry by TeamWizardry.

the class WizardryNemezManager method getOrCreateNemezDrive.

public static NemezTracker getOrCreateNemezDrive(World world, BlockPos pos) {
    WizardryWorld worldCap = WizardryWorldCapability.get(world);
    HashMap<BlockPos, NemezTracker> nemezDrives = worldCap.getBlockNemezDrives();
    if (nemezDrives.containsKey(pos))
        return nemezDrives.get(pos);
    return worldCap.addNemezDrive(pos, new NemezTracker());
}
Also used : WizardryWorld(com.teamwizardry.wizardry.api.capability.world.WizardryWorld) NemezTracker(com.teamwizardry.wizardry.common.core.nemez.NemezTracker) BlockPos(net.minecraft.util.math.BlockPos)

Example 9 with NemezTracker

use of com.teamwizardry.wizardry.common.core.nemez.NemezTracker in project Wizardry by TeamWizardry.

the class WizardryNemezManager method getAndRemoveNemezDrive.

@Nullable
public static NemezTracker getAndRemoveNemezDrive(World world, Entity entity) {
    WizardryWorld worldCap = WizardryWorldCapability.get(world);
    if (worldCap.getEntityNemezDrives().containsKey(entity.getUniqueID())) {
        NemezTracker tracker = worldCap.getEntityNemezDrives().get(entity.getUniqueID());
        worldCap.removeNemezDrive(entity.getUniqueID());
        return tracker;
    }
    return null;
}
Also used : WizardryWorld(com.teamwizardry.wizardry.api.capability.world.WizardryWorld) NemezTracker(com.teamwizardry.wizardry.common.core.nemez.NemezTracker) Nullable(javax.annotation.Nullable)

Example 10 with NemezTracker

use of com.teamwizardry.wizardry.common.core.nemez.NemezTracker in project Wizardry by TeamWizardry.

the class WizardryNemezManager method getOrCreateNemezDrive.

public static NemezTracker getOrCreateNemezDrive(World world, UUID uuid) {
    WizardryWorld worldCap = WizardryWorldCapability.get(world);
    HashMap<UUID, NemezTracker> nemezDrives = worldCap.getEntityNemezDrives();
    if (nemezDrives.containsKey(uuid))
        return nemezDrives.get(uuid);
    return worldCap.addNemezDrive(uuid, new NemezTracker());
}
Also used : WizardryWorld(com.teamwizardry.wizardry.api.capability.world.WizardryWorld) NemezTracker(com.teamwizardry.wizardry.common.core.nemez.NemezTracker) UUID(java.util.UUID)

Aggregations

NemezTracker (com.teamwizardry.wizardry.common.core.nemez.NemezTracker)10 WizardryWorld (com.teamwizardry.wizardry.api.capability.world.WizardryWorld)6 BlockPos (net.minecraft.util.math.BlockPos)5 Nullable (javax.annotation.Nullable)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 UUID (java.util.UUID)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 NBTTagList (net.minecraft.nbt.NBTTagList)2 SpellObjectManager (com.teamwizardry.wizardry.api.SpellObjectManager)1 BlockSet (com.teamwizardry.wizardry.api.spell.SpellDataTypes.BlockSet)1 BlockStateCache (com.teamwizardry.wizardry.api.spell.SpellDataTypes.BlockStateCache)1 HashSet (java.util.HashSet)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 Entity (net.minecraft.entity.Entity)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 NBTBase (net.minecraft.nbt.NBTBase)1 PotionEffect (net.minecraft.potion.PotionEffect)1 EnumFacing (net.minecraft.util.EnumFacing)1