Search in sources :

Example 1 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, Entity entity) {
    WizardryWorld worldCap = WizardryWorldCapability.get(world);
    HashMap<UUID, NemezTracker> nemezDrives = worldCap.getEntityNemezDrives();
    if (nemezDrives.containsKey(entity.getUniqueID()))
        return nemezDrives.get(entity.getUniqueID());
    return worldCap.addNemezDrive(entity.getUniqueID(), new NemezTracker());
}
Also used : WizardryWorld(com.teamwizardry.wizardry.api.capability.world.WizardryWorld) NemezTracker(com.teamwizardry.wizardry.common.core.nemez.NemezTracker) UUID(java.util.UUID)

Example 2 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, UUID uuid) {
    WizardryWorld worldCap = WizardryWorldCapability.get(world);
    if (worldCap.getEntityNemezDrives().containsKey(uuid)) {
        NemezTracker tracker = worldCap.getEntityNemezDrives().get(uuid);
        worldCap.removeNemezDrive(uuid);
        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 3 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, BlockPos pos) {
    WizardryWorld worldCap = WizardryWorldCapability.get(world);
    if (worldCap.getBlockNemezDrives().containsKey(pos)) {
        NemezTracker tracker = worldCap.getBlockNemezDrives().get(pos);
        worldCap.removeNemezDrive(pos);
        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 4 with WizardryWorld

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

the class SpellTicker method tick.

@SubscribeEvent
public static void tick(TickEvent.WorldTickEvent event) {
    if (event.world.isRemote)
        return;
    if (event.phase != TickEvent.Phase.END)
        return;
    World world = event.world;
    WizardryWorld worldCap = WizardryWorldCapability.get(world);
    if (worldCap == null)
        return;
    // PacketHandler.NETWORK.sendToDimension(new PacketSyncWizardryWorld(worldCap.serializeNBT()), world.provider.getDimension())
    worldCap.getSpellObjectManager().tick(onChange -> {
    });
}
Also used : WizardryWorld(com.teamwizardry.wizardry.api.capability.world.WizardryWorld) World(net.minecraft.world.World) WizardryWorld(com.teamwizardry.wizardry.api.capability.world.WizardryWorld) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 5 with WizardryWorld

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

the class ModuleEffectBackup method run.

@Override
public boolean run(@NotNull World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    if (world.isRemote)
        return true;
    Vec3d targetPos = spell.getTarget(world);
    EnumFacing facing = spell.getData(FACE_HIT);
    Entity caster = spell.getCaster(world);
    double duration = spellRing.getAttributeValue(world, AttributeRegistry.DURATION, spell) * 20;
    if (!spellRing.taxCaster(world, spell, true))
        return false;
    if (targetPos == null)
        return true;
    if (!(caster instanceof EntityLivingBase))
        return true;
    if (facing != null && !world.isAirBlock(new BlockPos(targetPos))) {
        targetPos = new Vec3d(new BlockPos(targetPos).offset(facing)).add(0.5, 0.5, 0.5);
    }
    UUID player = caster.getUniqueID();
    WizardryWorld world1 = WizardryWorldCapability.get(world);
    if (world1 == null)
        return true;
    if (world1.getBackupCount(player) < ConfigValues.maxZombies) {
        EntityBackupZombie zombie = new EntityBackupZombie(world, (EntityLivingBase) caster, (int) duration);
        zombie.setPosition(targetPos.x, targetPos.y, targetPos.z);
        zombie.forceSpawn = true;
        world.spawnEntity(zombie);
        world1.incBackupCount(player);
    }
    return true;
}
Also used : Entity(net.minecraft.entity.Entity) WizardryWorld(com.teamwizardry.wizardry.api.capability.world.WizardryWorld) EnumFacing(net.minecraft.util.EnumFacing) EntityLivingBase(net.minecraft.entity.EntityLivingBase) BlockPos(net.minecraft.util.math.BlockPos) EntityBackupZombie(com.teamwizardry.wizardry.common.entity.EntityBackupZombie) UUID(java.util.UUID) Vec3d(net.minecraft.util.math.Vec3d)

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