Search in sources :

Example 1 with EntityBackupZombie

use of com.teamwizardry.wizardry.common.entity.EntityBackupZombie in project Wizardry by TeamWizardry.

the class ModuleEffectBackup method run.

@Override
@SuppressWarnings("unused")
public boolean run(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    World world = spell.world;
    Entity targetEntity = spell.getVictim();
    Vec3d targetPos = spell.getTarget();
    EnumFacing facing = spell.getData(FACE_HIT);
    Entity caster = spell.getCaster();
    double range = spellRing.getAttributeValue(AttributeRegistry.AREA, spell) / 2.0;
    double time = spellRing.getAttributeValue(AttributeRegistry.DURATION, spell);
    if (!spellRing.taxCaster(spell))
        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)).addVector(0.5, 0.5, 0.5);
    }
    EntityBackupZombie zombie = new EntityBackupZombie(world, (EntityLivingBase) caster, (int) time);
    zombie.setPosition(targetPos.x, targetPos.y, targetPos.z);
    zombie.forceSpawn = true;
    world.spawnEntity(zombie);
    return true;
}
Also used : Entity(net.minecraft.entity.Entity) EnumFacing(net.minecraft.util.EnumFacing) EntityLivingBase(net.minecraft.entity.EntityLivingBase) BlockPos(net.minecraft.util.math.BlockPos) EntityBackupZombie(com.teamwizardry.wizardry.common.entity.EntityBackupZombie) World(net.minecraft.world.World) Vec3d(net.minecraft.util.math.Vec3d)

Example 2 with EntityBackupZombie

use of com.teamwizardry.wizardry.common.entity.EntityBackupZombie 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

EntityBackupZombie (com.teamwizardry.wizardry.common.entity.EntityBackupZombie)2 Entity (net.minecraft.entity.Entity)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 EnumFacing (net.minecraft.util.EnumFacing)2 BlockPos (net.minecraft.util.math.BlockPos)2 Vec3d (net.minecraft.util.math.Vec3d)2 WizardryWorld (com.teamwizardry.wizardry.api.capability.world.WizardryWorld)1 UUID (java.util.UUID)1 World (net.minecraft.world.World)1