Search in sources :

Example 1 with EntityThrownRock

use of am2.entities.EntityThrownRock in project ArsMagica2 by Mithion.

the class EntityAIThrowRock method updateTask.

@Override
public void updateTask() {
    host.getLookHelper().setLookPositionWithEntity(target, 30, 30);
    if (host.getDistanceSqToEntity(target) > 100) {
        host.getNavigator().tryMoveToEntityLiving(target, moveSpeed);
    } else {
        host.getNavigator().clearPathEntity();
        if (((IArsMagicaBoss) host).getCurrentAction() != BossActions.THROWING_ROCK)
            ((IArsMagicaBoss) host).setCurrentAction(BossActions.THROWING_ROCK);
        if (((IArsMagicaBoss) host).getTicksInCurrentAction() == 27) {
            if (!host.worldObj.isRemote)
                host.worldObj.playSoundAtEntity(host, ((IArsMagicaBoss) host).getAttackSound(), 1.0f, 1.0f);
            host.faceEntity(target, 180, 180);
            if (!host.worldObj.isRemote) {
                EntityThrownRock projectile = new EntityThrownRock(host.worldObj, host, 2.0f);
                host.worldObj.spawnEntityInWorld(projectile);
            }
        }
    }
}
Also used : EntityThrownRock(am2.entities.EntityThrownRock) IArsMagicaBoss(am2.bosses.IArsMagicaBoss)

Example 2 with EntityThrownRock

use of am2.entities.EntityThrownRock in project ArsMagica2 by Mithion.

the class MeteorSpawnHelper method spawnMeteor.

public void spawnMeteor() {
    ticksSinceLastMeteor = 48000;
    if (MinecraftServer.getServer().worldServers.length < 1)
        return;
    WorldServer ws = null;
    for (WorldServer world : MinecraftServer.getServer().worldServers) {
        if (world.provider.dimensionId == 0) {
            ws = world;
            break;
        }
    }
    if (ws == null)
        return;
    long time = ws.getWorldTime() % 24000;
    if (time > 14500 && time < 21500) {
        // night time range (just past dusk and just before dawn)
        if (ws.playerEntities.size() < 1)
            return;
        int playerID = rand.nextInt(ws.playerEntities.size());
        EntityPlayer player = (EntityPlayer) ws.playerEntities.get(playerID);
        if (ExtendedProperties.For(player).getMagicLevel() < AMCore.config.getMeteorMinSpawnLevel())
            return;
        AMVector3 spawnCoord = new AMVector3(player);
        boolean found = false;
        int meteorOffsetRadius = 64;
        AMVector3 attractorCoord = FlickerOperatorMoonstoneAttractor.getMeteorAttractor(spawnCoord);
        if (attractorCoord != null) {
            spawnCoord = attractorCoord;
            meteorOffsetRadius = 4;
        }
        for (int i = 0; i < 10; ++i) {
            AMVector3 offsetCoord = spawnCoord.copy().add(new AMVector3(rand.nextInt(meteorOffsetRadius) - (meteorOffsetRadius / 2), 0, rand.nextInt(meteorOffsetRadius) - (meteorOffsetRadius / 2)));
            offsetCoord.y = correctYCoord(ws, (int) offsetCoord.x, (int) offsetCoord.y, (int) offsetCoord.z);
            if (offsetCoord.y < 0)
                return;
            if (topBlockIsBiomeGeneric(ws, (int) offsetCoord.x, (int) offsetCoord.y, (int) offsetCoord.z)) {
                spawnCoord = offsetCoord;
                found = true;
                break;
            }
        }
        if (!found)
            return;
        EntityThrownRock meteor = new EntityThrownRock(ws);
        meteor.setPosition(spawnCoord.x + rand.nextInt(meteorOffsetRadius) - (meteorOffsetRadius / 2), ws.getActualHeight(), spawnCoord.z + rand.nextInt(meteorOffsetRadius) - (meteorOffsetRadius / 2));
        meteor.setMoonstoneMeteor();
        meteor.setMoonstoneMeteorTarget(spawnCoord);
        ws.spawnEntityInWorld(meteor);
    }
}
Also used : AMVector3(am2.api.math.AMVector3) EntityThrownRock(am2.entities.EntityThrownRock) EntityPlayer(net.minecraft.entity.player.EntityPlayer) WorldServer(net.minecraft.world.WorldServer)

Example 3 with EntityThrownRock

use of am2.entities.EntityThrownRock in project ArsMagica2 by Mithion.

the class FallingStar method spawnStar.

private boolean spawnStar(ItemStack spellStack, EntityLivingBase caster, Entity target, World world, double x, double y, double z) {
    List<EntityThrownRock> rocks = world.getEntitiesWithinAABB(EntityThrownRock.class, AxisAlignedBB.getBoundingBox(x - 10, y - 10, z - 10, x + 10, y + 10, z + 10));
    int damageMultitplier = SpellUtils.instance.getModifiedInt_Mul(15, spellStack, caster, target, world, 0, SpellModifiers.DAMAGE);
    for (EntityThrownRock rock : rocks) {
        if (rock.getIsShootingStar())
            return false;
    }
    if (!world.isRemote) {
        EntityThrownRock star = new EntityThrownRock(world);
        star.setPosition(x, world.getActualHeight(), z);
        star.setShootingStar(2 * damageMultitplier);
        star.setThrowingEntity(caster);
        star.setSpellStack(spellStack.copy());
        world.spawnEntityInWorld(star);
    }
    return true;
}
Also used : EntityThrownRock(am2.entities.EntityThrownRock)

Aggregations

EntityThrownRock (am2.entities.EntityThrownRock)3 AMVector3 (am2.api.math.AMVector3)1 IArsMagicaBoss (am2.bosses.IArsMagicaBoss)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 WorldServer (net.minecraft.world.WorldServer)1