Search in sources :

Example 1 with AMLineArc

use of am2.particles.AMLineArc 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 2 with AMLineArc

use of am2.particles.AMLineArc in project ArsMagica2 by Mithion.

the class TileEntityBlackAurem method updateEntity.

@Override
public void updateEntity() {
    if (worldObj.isRemote) {
        this.rotation += this.rotationIncrement;
    } else {
        surroundingCheckTicks++;
    }
    if (worldObj.isRemote || ticksSinceLastEntityScan++ > 25) {
        updateNearbyEntities();
        ticksSinceLastEntityScan = 0;
    }
    Iterator<EntityLivingBase> it = cachedEntities.iterator();
    while (it.hasNext()) {
        EntityLivingBase ent = it.next();
        if (ent.isDead) {
            it.remove();
            continue;
        }
        MovingObjectPosition mop = this.worldObj.rayTraceBlocks(Vec3.createVectorHelper(xCoord + 0.5, yCoord + 1.5, zCoord + 0.5), Vec3.createVectorHelper(ent.posX, ent.posY + ent.getEyeHeight(), ent.posZ), false);
        if (EntityUtilities.isSummon(ent) || mop != null) {
            continue;
        }
        ent.motionY = 0;
        ent.motionX = 0;
        ent.motionZ = 0;
        double deltaX = this.xCoord + 0.5f - ent.posX;
        double deltaZ = this.zCoord + 0.5f - ent.posZ;
        double deltaY = this.yCoord - ent.posY;
        double angle = Math.atan2(deltaZ, deltaX);
        double offsetX = Math.cos(angle) * 0.1;
        double offsetZ = Math.sin(angle) * 0.1;
        double offsetY = 0.05f;
        double distanceHorizontal = deltaX * deltaX + deltaZ * deltaZ;
        double distanceVertical = this.yCoord - ent.posY;
        boolean spawnedParticles = false;
        if (distanceHorizontal < 1.3) {
            if (distanceVertical < -1.5) {
                if (worldObj.isRemote && worldObj.rand.nextInt(10) < 3) {
                    AMCore.proxy.particleManager.BoltFromPointToPoint(worldObj, xCoord + 0.5, yCoord + 1.3, zCoord + 0.5, ent.posX, ent.posY, ent.posZ, 4, 0x000000);
                }
            }
            if (distanceVertical < -2) {
                offsetY = 0;
                if (!worldObj.isRemote) {
                    if (ent.attackEntityFrom(DamageSources.darkNexus, 4)) {
                        if (ent.getHealth() <= 0) {
                            ent.setDead();
                            float power = ((int) Math.ceil((ent.getMaxHealth() * (ent.ticksExisted / 20)) % 5000)) * this.powerMultiplier;
                            PowerNodeRegistry.For(this.worldObj).insertPower(this, PowerTypes.DARK, power);
                        }
                    }
                }
            }
        }
        if (worldObj.isRemote) {
            if (!arcs.containsKey(ent)) {
                AMLineArc arc = (AMLineArc) AMCore.proxy.particleManager.spawn(worldObj, "textures/blocks/oreblocksunstone.png", xCoord + 0.5, yCoord + 1.3, zCoord + 0.5, ent);
                if (arc != null) {
                    arc.setExtendToTarget();
                    arc.setRBGColorF(1, 1, 1);
                }
                arcs.put(ent, arc);
            }
            Iterator arcIterator = arcs.keySet().iterator();
            ArrayList<Entity> toRemove = new ArrayList<Entity>();
            while (arcIterator.hasNext()) {
                Entity arcEnt = (Entity) arcIterator.next();
                AMLineArc arc = (AMLineArc) arcs.get(arcEnt);
                if (arcEnt == null || arcEnt.isDead || arc == null || arc.isDead || new AMVector3(ent).distanceSqTo(new AMVector3(xCoord, yCoord, zCoord)) > 100)
                    toRemove.add(arcEnt);
            }
            for (Entity e : toRemove) {
                arcs.remove(e);
            }
        }
        if (!worldObj.isRemote)
            ent.moveEntity(offsetX, offsetY, offsetZ);
    }
    if (surroundingCheckTicks % 100 == 0) {
        checkNearbyBlockState();
        surroundingCheckTicks = 1;
        if (!worldObj.isRemote && PowerNodeRegistry.For(this.worldObj).checkPower(this, this.capacity * 0.1f)) {
            List<EntityPlayer> nearbyPlayers = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(this.xCoord - 2, this.yCoord, this.zCoord - 2, this.xCoord + 2, this.yCoord + 3, this.zCoord + 2));
            for (EntityPlayer p : nearbyPlayers) {
                if (p.isPotionActive(BuffList.manaRegen.id))
                    continue;
                p.addPotionEffect(new BuffEffectManaRegen(600, 3));
            }
        }
    // TODO:
    /*if (rand.nextDouble() < (this.getCharge() / this.getCapacity()) * 0.01){
					int maxSev = (int)Math.ceil((this.getCharge() / this.getCapacity()) * 2) + rand.nextInt(2);
					IllEffectsManager.instance.ApplyRandomBadThing(this, IllEffectSeverity.values()[maxSev], BadThingTypes.DARKNEXUS);
				}*/
    }
    super.callSuperUpdate();
}
Also used : Entity(net.minecraft.entity.Entity) ArrayList(java.util.ArrayList) BuffEffectManaRegen(am2.buffs.BuffEffectManaRegen) AMLineArc(am2.particles.AMLineArc) AMVector3(am2.api.math.AMVector3) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) EntityLivingBase(net.minecraft.entity.EntityLivingBase) Iterator(java.util.Iterator) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 3 with AMLineArc

use of am2.particles.AMLineArc in project ArsMagica2 by Mithion.

the class ExtendedProperties method spawnManaLinkParticles.

public void spawnManaLinkParticles() {
    if (entity.worldObj != null && entity.worldObj.isRemote) {
        for (ManaLinkEntry entry : this.manaLinks) {
            Entity e = entity.worldObj.getEntityByID(entry.entityID);
            if (e != null && e.getDistanceSqToEntity(entity) < entry.range && e.ticksExisted % 90 == 0) {
                AMLineArc arc = (AMLineArc) AMCore.proxy.particleManager.spawn(entity.worldObj, "textures/blocks/oreblockbluetopaz.png", e, entity);
                if (arc != null) {
                    arc.setIgnoreAge(false);
                    arc.setRBGColorF(0.17f, 0.88f, 0.88f);
                }
            }
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) AMLineArc(am2.particles.AMLineArc)

Example 4 with AMLineArc

use of am2.particles.AMLineArc in project ArsMagica2 by Mithion.

the class ItemRune method spawnLineArcParticle.

public void spawnLineArcParticle(ItemStack stack, World world, EntityPlayer player) {
    if (world.isRemote) {
        Vec3 look = player.getLookVec();
        double dist = 20;
        AMLineArc arc = (AMLineArc) AMCore.proxy.particleManager.spawn(world, "wipblock2", player.posX, player.posY, player.posZ, player.posX + (look.xCoord * dist), player.posY + (look.yCoord * dist), player.posZ + (look.zCoord * dist));
        if (arc != null) {
            arc.setExtendToTarget();
            arc.setRBGColorF(0, 0, 0);
        }
    }
}
Also used : AMLineArc(am2.particles.AMLineArc)

Example 5 with AMLineArc

use of am2.particles.AMLineArc in project ArsMagica2 by Mithion.

the class ManaLink method spawnParticles.

@Override
public void spawnParticles(World world, double x, double y, double z, EntityLivingBase caster, Entity target, Random rand, int colorModifier) {
    AMLineArc arc = (AMLineArc) AMCore.proxy.particleManager.spawn(world, "textures/blocks/wipblock2.png", caster, target);
    if (arc != null) {
        arc.setExtendToTarget();
        arc.setIgnoreAge(false);
        arc.setRBGColorF(0.17f, 0.88f, 0.88f);
    }
}
Also used : AMLineArc(am2.particles.AMLineArc)

Aggregations

AMLineArc (am2.particles.AMLineArc)5 AMVector3 (am2.api.math.AMVector3)2 ArrayList (java.util.ArrayList)2 Entity (net.minecraft.entity.Entity)2 IPowerNode (am2.api.power.IPowerNode)1 PowerTypes (am2.api.power.PowerTypes)1 BuffEffectManaRegen (am2.buffs.BuffEffectManaRegen)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 TileEntity (net.minecraft.tileentity.TileEntity)1 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)1