Search in sources :

Example 11 with AMVector3

use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.

the class ClientProxy method drawPowerOnBlockHighlight.

@Override
public void drawPowerOnBlockHighlight(EntityPlayer player, MovingObjectPosition target, float partialTicks) {
    if (AMCore.proxy.getLocalPlayer().getCurrentArmor(3) != null && (AMCore.proxy.getLocalPlayer().getCurrentArmor(3).getItem() == ItemsCommonProxy.magitechGoggles || ArmorHelper.isInfusionPreset(AMCore.proxy.getLocalPlayer().getCurrentArmor(3), GenericImbuement.magitechGoggleIntegration))) {
        TileEntity te = player.worldObj.getTileEntity(target.blockX, target.blockY, target.blockZ);
        if (te != null && te instanceof IPowerNode) {
            AMCore.proxy.setTrackedLocation(new AMVector3(target.blockX, target.blockY, target.blockZ));
        } else {
            AMCore.proxy.setTrackedLocation(AMVector3.zero());
        }
        if (AMCore.proxy.hasTrackedLocationSynced()) {
            PowerNodeEntry data = AMCore.proxy.getTrackedData();
            Block block = player.worldObj.getBlock(target.blockX, target.blockY, target.blockZ);
            float yOff = 0.5f;
            if (data != null) {
                GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_LIGHTING_BIT);
                for (PowerTypes type : ((IPowerNode) te).getValidPowerTypes()) {
                    float pwr = data.getPower(type);
                    float pct = pwr / ((IPowerNode) te).getCapacity() * 100;
                    RenderUtilities.drawTextInWorldAtOffset(String.format("%s%.2f (%.2f%%)", type.chatColor(), pwr, pct), target.blockX - (player.prevPosX - (player.prevPosX - player.posX) * partialTicks) + 0.5f, target.blockY + yOff - (player.prevPosY - (player.prevPosY - player.posY) * partialTicks) + block.getBlockBoundsMaxY() * 0.8f, target.blockZ - (player.prevPosZ - (player.prevPosZ - player.posZ) * partialTicks) + 0.5f, 0xFFFFFF);
                    yOff += 0.12f;
                }
                GL11.glPopAttrib();
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AMVector3(am2.api.math.AMVector3) PowerTypes(am2.api.power.PowerTypes) Block(net.minecraft.block.Block) PowerNodeEntry(am2.power.PowerNodeEntry) IPowerNode(am2.api.power.IPowerNode)

Example 12 with AMVector3

use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.

the class Attract method doTK_Extrapolated.

private boolean doTK_Extrapolated(ItemStack stack, World world, double impactX, double impactY, double impactZ, EntityLivingBase caster) {
    if (caster instanceof EntityPlayer) {
        double range = ExtendedProperties.For(caster).TK_Distance;
        MovingObjectPosition mop = ItemsCommonProxy.spell.getMovingObjectPosition(caster, world, range, false, false);
        if (mop == null) {
            impactX = caster.posX + (Math.cos(Math.toRadians(caster.rotationYaw + 90)) * range);
            impactZ = caster.posZ + (Math.sin(Math.toRadians(caster.rotationYaw + 90)) * range);
            impactY = caster.posY + caster.getEyeHeight() + (-Math.sin(Math.toRadians(caster.rotationPitch)) * range);
        }
    }
    EntityLivingBase target = getClosestEntityToPointWithin(caster, world, new AMVector3(impactX, impactY, impactZ), 16);
    if (target == null)
        return false;
    int hDist = 3;
    AMVector3 movement = MathUtilities.GetMovementVectorBetweenPoints(new AMVector3(target), new AMVector3(impactX, impactY, impactZ));
    if (!world.isRemote) {
        float factor = 0.75f;
        double x = -(movement.x * factor);
        double y = -(movement.y * factor);
        double z = -(movement.z * factor);
        target.addVelocity(x, y, z);
        if (Math.abs(target.motionX) > Math.abs(x * 2)) {
            target.motionX = x * (target.motionX / target.motionX);
        }
        if (Math.abs(target.motionY) > Math.abs(y * 2)) {
            target.motionY = y * (target.motionY / target.motionY);
        }
        if (Math.abs(target.motionZ) > Math.abs(z * 2)) {
            target.motionZ = z * (target.motionZ / target.motionZ);
        }
    }
    return true;
}
Also used : AMVector3(am2.api.math.AMVector3) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ParticleApproachPoint(am2.particles.ParticleApproachPoint)

Example 13 with AMVector3

use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.

the class ClientTickHandler method spawnPowerPathVisuals.

private void spawnPowerPathVisuals() {
    if (Minecraft.getMinecraft().thePlayer.getCurrentArmor(3) != null && (Minecraft.getMinecraft().thePlayer.getCurrentArmor(3).getItem() == ItemsCommonProxy.magitechGoggles || ArmorHelper.isInfusionPreset(Minecraft.getMinecraft().thePlayer.getCurrentArmor(3), GenericImbuement.magitechGoggleIntegration))) {
        if (arcSpawnCounter++ >= arcSpawnFrequency) {
            arcSpawnCounter = 0;
            AMVector3 playerPos = new AMVector3(Minecraft.getMinecraft().thePlayer);
            HashMap<PowerTypes, ArrayList<LinkedList<AMVector3>>> paths = AMCore.proxy.getPowerPathVisuals();
            if (paths != null) {
                for (PowerTypes type : paths.keySet()) {
                    String texture = type == PowerTypes.LIGHT ? "textures/blocks/oreblockbluetopaz.png" : type == PowerTypes.NEUTRAL ? "textures/blocks/oreblockvinteum.png" : type == PowerTypes.DARK ? "textures/blocks/oreblocksunstone.png" : "textures/blocks/oreblocksunstone.png";
                    ArrayList<LinkedList<AMVector3>> pathList = paths.get(type);
                    for (LinkedList<AMVector3> individualPath : pathList) {
                        for (int i = 0; i < individualPath.size() - 1; ++i) {
                            AMVector3 start = individualPath.get(i + 1);
                            AMVector3 end = individualPath.get(i);
                            if (start.distanceSqTo(playerPos) > 2500 || end.distanceSqTo(playerPos) > 2500) {
                                continue;
                            }
                            TileEntity teStart = Minecraft.getMinecraft().theWorld.getTileEntity((int) start.x, (int) start.y, (int) start.z);
                            TileEntity teEnd = Minecraft.getMinecraft().theWorld.getTileEntity((int) end.x, (int) end.y, (int) end.z);
                            if (teEnd == null || !(teEnd instanceof IPowerNode))
                                break;
                            double startX = start.x + ((teStart != null && teStart instanceof IPowerNode) ? ((IPowerNode) teStart).particleOffset(0) : 0.5f);
                            double startY = start.y + ((teStart != null && teStart instanceof IPowerNode) ? ((IPowerNode) teStart).particleOffset(1) : 0.5f);
                            double startZ = start.z + ((teStart != null && teStart instanceof IPowerNode) ? ((IPowerNode) teStart).particleOffset(2) : 0.5f);
                            double endX = end.x + ((IPowerNode) teEnd).particleOffset(0);
                            double endY = end.y + ((IPowerNode) teEnd).particleOffset(1);
                            double endZ = end.z + ((IPowerNode) teEnd).particleOffset(2);
                            AMLineArc arc = (AMLineArc) AMCore.proxy.particleManager.spawn(Minecraft.getMinecraft().theWorld, texture, startX, startY, startZ, endX, endY, endZ);
                            if (arc != null) {
                                arcs.add(arc);
                            }
                        }
                    }
                }
            }
        }
    } else {
        Iterator<AMLineArc> it = arcs.iterator();
        while (it.hasNext()) {
            AMLineArc arc = it.next();
            if (arc == null || arc.isDead)
                it.remove();
            else
                arc.setDead();
        }
        arcSpawnCounter = arcSpawnFrequency;
    }
}
Also used : ArrayList(java.util.ArrayList) AMLineArc(am2.particles.AMLineArc) LinkedList(java.util.LinkedList) TileEntity(net.minecraft.tileentity.TileEntity) AMVector3(am2.api.math.AMVector3) PowerTypes(am2.api.power.PowerTypes) IPowerNode(am2.api.power.IPowerNode)

Example 14 with AMVector3

use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.

the class EntityAIHurricane method continueExecuting.

@Override
public boolean continueExecuting() {
    EntityLivingBase AITarget = ((EntityLiving) host).getAttackTarget();
    if (host.hitCount >= 10) {
        ((IArsMagicaBoss) host).setCurrentAction(BossActions.IDLE);
        cooldownTicks = 20;
        return false;
    }
    if (AITarget == null || AITarget.isDead || ((IArsMagicaBoss) host).getTicksInCurrentAction() > BossActions.SPINNING.getMaxActionTime()) {
        if (!host.worldObj.isRemote) {
            int y = (int) host.posY + 1;
            for (int x = -1; x <= 1; ++x) {
                for (int z = -1; z <= 1; ++z) {
                    while (!host.worldObj.canBlockSeeTheSky((int) host.posX + x, y, (int) host.posZ + z) && host.worldObj.getBlock((int) host.posX + x, y, (int) host.posZ + z) != Blocks.bedrock) {
                        host.worldObj.func_147478_e((int) host.posX + x, y++, (int) host.posZ + z, true);
                    }
                    y = (int) host.posY + 2;
                }
            }
        }
        List<EntityLivingBase> nearbyEntities = host.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, host.boundingBox.expand(2, 2, 2));
        for (EntityLivingBase ent : nearbyEntities) {
            if (ent == host)
                continue;
            AMVector3 movement = MathUtilities.GetMovementVectorBetweenPoints(new AMVector3(host), new AMVector3(ent));
            float factor = 2.15f;
            double x = -(movement.x * factor);
            double y = 2.5f;
            double z = -(movement.z * factor);
            ent.attackEntityFrom(DamageSources.causeEntityWindDamage(host), 12);
            ent.addVelocity(x, y, z);
            if (ent instanceof EntityPlayer) {
                AMNetHandler.INSTANCE.sendVelocityAddPacket(host.worldObj, ent, x, y, z);
            }
            ent.fallDistance = 0f;
        }
        ((IArsMagicaBoss) host).setCurrentAction(BossActions.IDLE);
        cooldownTicks = 20;
        return false;
    }
    return true;
}
Also used : AMVector3(am2.api.math.AMVector3) EntityLiving(net.minecraft.entity.EntityLiving) IArsMagicaBoss(am2.bosses.IArsMagicaBoss) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 15 with AMVector3

use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.

the class EntityAIEnderRush method updateTask.

@Override
public void updateTask() {
    EntityEnderGuardian guardian = getEntity();
    if (guardian.getAttackTarget() != null) {
        guardian.getLookHelper().setLookPositionWithEntity(guardian.getAttackTarget(), 30, 30);
    }
    if (guardian.getTicksInCurrentAction() >= 18 && guardian.getTicksInCurrentAction() <= 30 && guardian.getAttackTarget() != null) {
        AMVector3 a = new AMVector3(guardian);
        AMVector3 b = new AMVector3(guardian.getAttackTarget());
        if (a.distanceSqTo(b) > 4) {
            AMVector3 movement = MathUtilities.GetMovementVectorBetweenPoints(a, b);
            float speed = -5f;
            guardian.moveEntity(movement.x * speed, movement.y * speed, movement.z * speed);
        } else {
            guardian.worldObj.playSoundAtEntity(guardian, ((IArsMagicaBoss) guardian).getAttackSound(), 1.0f, (float) (0.5 + guardian.getRNG().nextDouble() * 0.5f));
            if (guardian.getAttackTarget().attackEntityFrom(DamageSource.causeMobDamage(guardian), 15) && guardian.getAttackTarget().getHealth() <= 0)
                guardian.heal(200);
        }
    }
}
Also used : AMVector3(am2.api.math.AMVector3) EntityEnderGuardian(am2.bosses.EntityEnderGuardian)

Aggregations

AMVector3 (am2.api.math.AMVector3)113 TileEntity (net.minecraft.tileentity.TileEntity)21 EntityPlayer (net.minecraft.entity.player.EntityPlayer)16 EntityLivingBase (net.minecraft.entity.EntityLivingBase)15 ArrayList (java.util.ArrayList)11 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)11 IPowerNode (am2.api.power.IPowerNode)10 Block (net.minecraft.block.Block)9 Entity (net.minecraft.entity.Entity)9 ItemStack (net.minecraft.item.ItemStack)9 NBTTagList (net.minecraft.nbt.NBTTagList)9 IInventory (net.minecraft.inventory.IInventory)8 PowerTypes (am2.api.power.PowerTypes)6 AMParticle (am2.particles.AMParticle)5 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)5 TileEntityCrystalMarker (am2.blocks.tileentities.TileEntityCrystalMarker)4 EntityDragonPart (net.minecraft.entity.boss.EntityDragonPart)4 TileEntityFlickerHabitat (am2.blocks.tileentities.TileEntityFlickerHabitat)3 AMDataWriter (am2.network.AMDataWriter)3 ParticleFloatUpward (am2.particles.ParticleFloatUpward)3