Search in sources :

Example 1 with EntityNatureGuardian

use of am2.bosses.EntityNatureGuardian in project ArsMagica2 by Mithion.

the class EntityThrownSickle method setDead.

@Override
public void setDead() {
    if (getThrowingEntity() != null && getThrowingEntity() instanceof EntityNatureGuardian) {
        ((EntityNatureGuardian) getThrowingEntity()).hasSickle = true;
    } else if (getThrowingEntity() != null && getThrowingEntity() instanceof EntityPlayer) {
        if (!worldObj.isRemote)
            if (getThrowingEntity().getHealth() <= 0) {
                PlayerTracker.storeSoulboundItemForRespawn((EntityPlayer) getThrowingEntity(), ItemsCommonProxy.natureScytheEnchanted.copy());
            } else {
                if (!((EntityPlayer) getThrowingEntity()).inventory.addItemStackToInventory(ItemsCommonProxy.natureScytheEnchanted.copy())) {
                    EntityItem item = new EntityItem(worldObj);
                    item.setPosition(posX, posY, posZ);
                    item.setEntityItemStack(ItemsCommonProxy.natureScytheEnchanted.copy());
                    worldObj.spawnEntityInWorld(item);
                }
            }
    }
    super.setDead();
}
Also used : EntityNatureGuardian(am2.bosses.EntityNatureGuardian) DummyEntityPlayer(am2.utility.DummyEntityPlayer) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityItem(net.minecraft.entity.item.EntityItem)

Example 2 with EntityNatureGuardian

use of am2.bosses.EntityNatureGuardian in project ArsMagica2 by Mithion.

the class EntityThrownSickle method onUpdate.

@Override
public void onUpdate() {
    if (!worldObj.isRemote && (getThrowingEntity() == null || getThrowingEntity().isDead)) {
        setDead();
        return;
    } else {
        ticksExisted++;
        if (ticksExisted >= maxTicksToExist && !worldObj.isRemote) {
            setDead();
            return;
        }
    }
    if (getThrowingEntity() != null && getThrowingEntity() instanceof EntityNatureGuardian) {
        ((EntityNatureGuardian) getThrowingEntity()).hasSickle = false;
    }
    Vec3 vec3d = Vec3.createVectorHelper(posX, posY, posZ);
    Vec3 vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
    MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1);
    vec3d = Vec3.createVectorHelper(posX, posY, posZ);
    vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
    if (movingobjectposition != null) {
        vec3d1 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
    }
    Entity entity = null;
    List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
    double d = 0.0D;
    for (int j = 0; j < list.size(); j++) {
        Entity entity1 = (Entity) list.get(j);
        if (!entity1.canBeCollidedWith() || entity1.isEntityEqual(getThrowingEntity()) && ticksExisted < 25) {
            continue;
        }
        float f2 = 0.3F;
        AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f2, f2, f2);
        MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3d, vec3d1);
        if (movingobjectposition1 == null) {
            continue;
        }
        double d1 = vec3d.distanceTo(movingobjectposition1.hitVec);
        if (d1 < d || d == 0.0D) {
            entity = entity1;
            d = d1;
        }
    }
    if (entity != null) {
        movingobjectposition = new MovingObjectPosition(entity);
    } else {
        movingobjectposition = new MovingObjectPosition((int) Math.floor(posX), (int) Math.floor(posY), (int) Math.floor(posZ), 0, Vec3.createVectorHelper(posX, posY, posZ));
    }
    if (movingobjectposition != null) {
        HitObject(movingobjectposition);
    }
    posX += motionX;
    posY += motionY;
    posZ += motionZ;
    float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
    rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
    for (rotationPitch = (float) ((Math.atan2(motionY, f) * 180D) / 3.1415927410125732D); rotationPitch - prevRotationPitch < -180F; prevRotationPitch -= 360F) {
    }
    for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F) {
    }
    for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F) {
    }
    for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F) {
    }
    rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
    rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
    float f1 = 0.95F;
    if (isInWater()) {
        for (int k = 0; k < 4; k++) {
            float f3 = 0.25F;
            worldObj.spawnParticle("bubble", posX - motionX * f3, posY - motionY * f3, posZ - motionZ * f3, motionX, motionY, motionZ);
        }
        f1 = 0.8F;
    }
    setPosition(posX, posY, posZ);
    if (this.ticksExisted > 30 && this.ticksExisted < 40) {
        this.motionX *= 0.8f;
        this.motionY *= 0.8f;
        this.motionZ *= 0.8f;
    } else if (this.ticksExisted > 40 && getThrowingEntity() != null) {
        double deltaX = this.posX - getThrowingEntity().posX;
        double deltaZ = this.posZ - getThrowingEntity().posZ;
        double deltaY = this.posY - getThrowingEntity().posY;
        double angle = Math.atan2(deltaZ, deltaX);
        double speed = Math.min((this.ticksExisted - 40f) / 10f, this.getProjectileSpeed());
        double horizontalDistance = MathHelper.sqrt_double(deltaX * deltaX + deltaZ * deltaZ);
        float pitchRotation = (float) (-Math.atan2(deltaY, horizontalDistance));
        this.motionX = -Math.cos(angle) * speed;
        this.motionZ = -Math.sin(angle) * speed;
        this.motionY = Math.sin(pitchRotation) * speed;
        if (this.getDistanceSqToEntity(getThrowingEntity()) < 1.2 && !worldObj.isRemote) {
            this.setDead();
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) EntityNatureGuardian(am2.bosses.EntityNatureGuardian) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with EntityNatureGuardian

use of am2.bosses.EntityNatureGuardian in project ArsMagica2 by Mithion.

the class ModelPlantGuardian method render.

public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
    if (!(entity instanceof EntityNatureGuardian))
        return;
    updateRotations((EntityNatureGuardian) entity, f, f1, f2, f3, f4, f5);
    GL11.glPushMatrix();
    EntityNatureGuardian guardian = (EntityNatureGuardian) entity;
    if (guardian.getCurrentAction() == BossActions.SPINNING) {
        GL11.glRotatef(guardian.spinRotation + (f2 - guardian.ticksExisted) * -40f, 0, 1, 0);
    }
    setHeadRotation(f3, f4);
    Head.render(f5);
    Tendril1.render(f5);
    Tendril2.render(f5);
    Tendril3.render(f5);
    Tendril4.render(f5);
    Tendril5.render(f5);
    Tendril6.render(f5);
    Tendril7.render(f5);
    Tendril8.render(f5);
    Tendril9.render(f5);
    Tendril10.render(f5);
    Tendril11.render(f5);
    Tendril12.render(f5);
    LowerCube1.render(f5);
    LowerCube2.render(f5);
    Body4.render(f5);
    Body3.render(f5);
    Body2.render(f5);
    Body1.render(f5);
    Body.render(f5);
    Shoulders.render(f5);
    SheildArm1.render(f5);
    SickleArm1.render(f5);
    ShieldArm2.render(f5);
    SickleArm2.render(f5);
    Tendril13.render(f5);
    Tendril14.render(f5);
    Tendril15.render(f5);
    Tendril16.render(f5);
    if (((EntityNatureGuardian) entity).hasSickle) {
        Shape39.render(f5);
        Sickle2.render(f5);
        Sickle3.render(f5);
        Sickle4.render(f5);
        Sickle5.render(f5);
    }
    Shield.render(f5);
    GL11.glPopMatrix();
}
Also used : EntityNatureGuardian(am2.bosses.EntityNatureGuardian)

Aggregations

EntityNatureGuardian (am2.bosses.EntityNatureGuardian)3 DummyEntityPlayer (am2.utility.DummyEntityPlayer)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Entity (net.minecraft.entity.Entity)1 EntityItem (net.minecraft.entity.item.EntityItem)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1