Search in sources :

Example 6 with WizardryWorld

use of com.teamwizardry.wizardry.api.capability.world.WizardryWorld in project Wizardry by TeamWizardry.

the class PacketSyncWizardryWorld method handle.

@Override
public void handle(@NotNull MessageContext ctx) {
    if (ctx.side.isServer())
        return;
    World world = LibrarianLib.PROXY.getClientPlayer().world;
    if (world == null)
        return;
    WizardryWorld cap = WizardryWorldCapability.get(world);
    if (cap != null) {
        cap.deserializeNBT(compound);
    }
}
Also used : WizardryWorld(com.teamwizardry.wizardry.api.capability.world.WizardryWorld) World(net.minecraft.world.World) WizardryWorld(com.teamwizardry.wizardry.api.capability.world.WizardryWorld)

Example 7 with WizardryWorld

use of com.teamwizardry.wizardry.api.capability.world.WizardryWorld in project Wizardry by TeamWizardry.

the class ModuleInstance method castSpell.

/**
 * Use this to run the module properly.
 *
 * @param data    The spellData associated with it.
 * @param ring    The SpellRing made with this.
 * @return If the spellData has succeeded.
 */
public final boolean castSpell(@Nonnull World world, @Nonnull SpellData data, @Nonnull SpellRing ring) {
    if (world.isRemote)
        return true;
    boolean success;
    boolean ranOnce = false;
    NBTTagList list = data.getDataWithFallback(SpellData.DefaultKeys.TAG_LIST, new NBTTagList());
    for (NBTBase base : list) {
        if (base instanceof NBTTagString) {
            if (((NBTTagString) base).getString().equals(ring.getUniqueID().toString())) {
                ranOnce = true;
                break;
            }
        }
    }
    if (moduleClass instanceof ILingeringModule && !ranOnce) {
        WizardryWorld worldCap = WizardryWorldCapability.get(world);
        list.appendTag(new NBTTagString(ring.getUniqueID().toString()));
        data.addData(SpellData.DefaultKeys.TAG_LIST, list);
        success = internalCastSpell(world, data, ring) && ((ILingeringModule) moduleClass).runOnStart(world, data, ring);
        if (success) {
            worldCap.getSpellObjectManager().addLingering(new SpellObjectManager.LingeringObject(world, data, ring), ((ILingeringModule) moduleClass).getLingeringTime(world, data, ring));
        }
    } else {
        success = internalCastSpell(world, data, ring);
    }
    if (success || ignoreResultsForRendering()) {
        sendRenderPacket(world, data, ring);
    }
    return success;
}
Also used : WizardryWorld(com.teamwizardry.wizardry.api.capability.world.WizardryWorld) SpellObjectManager(com.teamwizardry.wizardry.api.SpellObjectManager) ILingeringModule(com.teamwizardry.wizardry.api.spell.ILingeringModule)

Example 8 with WizardryWorld

use of com.teamwizardry.wizardry.api.capability.world.WizardryWorld in project Wizardry by TeamWizardry.

the class IDelayedModule method addDelayedSpell.

default void addDelayedSpell(@Nonnull World world, SpellRing spellRing, SpellData data, int expiry) {
    WizardryWorld worldCap = WizardryWorldCapability.get(world);
    worldCap.getSpellObjectManager().addDelayed(new SpellObjectManager.DelayedObject(world, data, spellRing), expiry);
}
Also used : WizardryWorld(com.teamwizardry.wizardry.api.capability.world.WizardryWorld) SpellObjectManager(com.teamwizardry.wizardry.api.SpellObjectManager)

Example 9 with WizardryWorld

use of com.teamwizardry.wizardry.api.capability.world.WizardryWorld 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 10 with WizardryWorld

use of com.teamwizardry.wizardry.api.capability.world.WizardryWorld 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)

Aggregations

WizardryWorld (com.teamwizardry.wizardry.api.capability.world.WizardryWorld)11 NemezTracker (com.teamwizardry.wizardry.common.core.nemez.NemezTracker)6 UUID (java.util.UUID)3 Nullable (javax.annotation.Nullable)3 SpellObjectManager (com.teamwizardry.wizardry.api.SpellObjectManager)2 BlockPos (net.minecraft.util.math.BlockPos)2 World (net.minecraft.world.World)2 ILingeringModule (com.teamwizardry.wizardry.api.spell.ILingeringModule)1 EntityBackupZombie (com.teamwizardry.wizardry.common.entity.EntityBackupZombie)1 Entity (net.minecraft.entity.Entity)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EnumFacing (net.minecraft.util.EnumFacing)1 Vec3d (net.minecraft.util.math.Vec3d)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1