use of am2.particles.AMParticle in project ArsMagica2 by Mithion.
the class EntityManaVortex method onUpdate.
@Override
public void onUpdate() {
this.ticksExisted++;
this.rotation += 5;
if (!this.worldObj.isRemote && (this.isDead || this.ticksExisted >= getTicksToExist())) {
this.setDead();
return;
}
if (this.getTicksToExist() - this.ticksExisted <= 20) {
this.scale -= 1f / 20f;
} else if (this.scale < 0.99f) {
this.scale = (float) (Math.sin((float) this.ticksExisted / 50));
}
if (getTicksToExist() - this.ticksExisted <= 5 && !hasGoneBoom) {
hasGoneBoom = true;
if (!worldObj.isRemote) {
List players = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, this.boundingBox.expand(3 + Math.floor(this.ticksExisted / 50), 2, 3 + Math.floor(this.ticksExisted / 50)));
float damage = this.dataWatcher.getWatchableObjectFloat(DW_MANA_STOLEN) * 0.005f;
if (damage > 100)
damage = 100;
Object[] playerArray = players.toArray();
for (Object o : playerArray) {
EntityLivingBase e = (EntityLivingBase) o;
MovingObjectPosition mop = this.worldObj.rayTraceBlocks(Vec3.createVectorHelper(this.posX, this.posY, this.posZ), Vec3.createVectorHelper(e.posX, e.posY + e.getEyeHeight(), e.posZ), false);
if (mop == null)
e.attackEntityFrom(DamageSources.causeEntityPhysicalDamage(this), damage);
}
} else {
for (int i = 0; i < 360; i += AMCore.config.FullGFX() ? 5 : AMCore.config.LowGFX() ? 10 : 20) {
AMParticle effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(worldObj, "ember", this.posX, this.posY, this.posZ);
if (effect != null) {
effect.setIgnoreMaxAge(true);
effect.AddParticleController(new ParticleMoveOnHeading(effect, i, 0, 0.7f, 1, false));
effect.setRGBColorF(0.24f, 0.24f, 0.8f);
effect.noClip = false;
effect.AddParticleController(new ParticleFadeOut(effect, 1, false).setFadeSpeed(0.05f).setKillParticleOnFinish(true));
effect.AddParticleController(new ParticleLeaveParticleTrail(effect, "ember", false, 5, 1, false).addControllerToParticleList(new ParticleMoveOnHeading(effect, i, 0, 0.1f, 1, false)).addControllerToParticleList(new ParticleFadeOut(effect, 1, false).setFadeSpeed(0.1f).setKillParticleOnFinish(true)).setParticleRGB_F(0.24f, 0.24f, 0.8f).addRandomOffset(0.2f, 0.2f, 0.2f));
}
}
}
}
if (getTicksToExist() - this.ticksExisted > 30) {
// get all players within 5 blocks
List<EntityLivingBase> players = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, this.boundingBox.expand(3 + Math.floor(this.ticksExisted / 50), 2, 3 + Math.floor(this.ticksExisted / 50)));
Object[] playerArray = players.toArray();
Vec3 thisPos = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
for (Object o : playerArray) {
EntityLivingBase e = (EntityLivingBase) o;
MovingObjectPosition mop = this.worldObj.rayTraceBlocks(Vec3.createVectorHelper(this.posX, this.posY, this.posZ), Vec3.createVectorHelper(e.posX, e.posY + e.getEyeHeight(), e.posZ), false);
if (mop != null)
continue;
Vec3 playerPos = Vec3.createVectorHelper(e.posX, e.posY + e.getEyeHeight(), e.posZ);
if (worldObj.isRemote) {
if (AMCore.config.NoGFX()) {
break;
}
if (AMCore.config.LowGFX() && (this.ticksExisted % 4) != 0) {
break;
}
AMParticle effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(worldObj, "ember", e.posX, e.posY + (e.getEyeHeight() / 2), e.posZ);
if (effect != null) {
effect.AddParticleController(new ParticleArcToEntity(effect, 1, this, false).generateControlPoints().setKillParticleOnFinish(true));
effect.setRGBColorF(0.24f, 0.24f, 0.8f);
effect.setIgnoreMaxAge(true);
}
}
float manaStolen = ExtendedProperties.For(e).getMaxMana() * 0.01f;
float curMana = ExtendedProperties.For(e).getCurrentMana();
if (manaStolen > curMana)
manaStolen = curMana;
this.dataWatcher.updateObject(DW_MANA_STOLEN, this.dataWatcher.getWatchableObjectFloat(DW_MANA_STOLEN) + manaStolen);
ExtendedProperties.For(e).setCurrentMana(ExtendedProperties.For(e).getCurrentMana() - manaStolen);
AMVector3 movement = MathUtilities.GetMovementVectorBetweenEntities(e, this);
float speed = -0.075f;
e.addVelocity(movement.x * speed, movement.y * speed, movement.z * speed);
}
}
}
use of am2.particles.AMParticle in project ArsMagica2 by Mithion.
the class EntitySpellEffect method rainOfFireUpdate.
private void rainOfFireUpdate() {
float radius = this.dataWatcher.getWatchableObjectFloat(WATCHER_RADIUS);
if (worldObj.isRemote) {
if (spellStack == null) {
spellStack = this.dataWatcher.getWatchableObjectItemStack(22);
if (spellStack == null) {
return;
}
}
int color = 0xFFFFFF;
if (SpellUtils.instance.modifierIsPresent(SpellModifiers.COLOR, spellStack, 0)) {
ISpellModifier[] mods = SpellUtils.instance.getModifiersForStage(spellStack, 0);
int ordinalCount = 0;
for (ISpellModifier mod : mods) {
if (mod instanceof Colour) {
byte[] meta = SpellUtils.instance.getModifierMetadataFromStack(spellStack, mod, 0, ordinalCount++);
color = (int) mod.getModifier(SpellModifiers.COLOR, null, null, null, meta);
}
}
}
for (int i = 0; i < 10; ++i) {
double x = this.posX - radius + (rand.nextDouble() * radius * 2);
double z = this.posZ - radius + (rand.nextDouble() * radius * 2);
double y = this.posY + 10;
AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "explosion_2", x, y, z);
if (particle != null) {
particle.setMaxAge(20);
particle.addVelocity(rand.nextDouble() * 0.2f, 0, rand.nextDouble() * 0.2f);
particle.setAffectedByGravity();
particle.setDontRequireControllers();
particle.setRGBColorI(color);
particle.noClip = false;
}
}
// TODO: SoundHelper.instance.loopSound(worldObj, (float)posX, (float)posY, (float)posZ, "arsmagica2:spell.loop.fire", 1.0f);
} else {
List<Entity> possibleTargets = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(posX - radius, posY - 1, posZ - radius, posX + radius, posY + 3, posZ + radius));
for (Entity e : possibleTargets) {
if (e != dummycaster) {
if (e instanceof EntityDragonPart && ((EntityDragonPart) e).entityDragonObj instanceof EntityLivingBase)
e = (EntityLivingBase) ((EntityDragonPart) e).entityDragonObj;
double lastVelX = e.motionX;
double lastVelY = e.motionY;
double lastVelZ = e.motionZ;
float damage = 0.75f * this.dataWatcher.getWatchableObjectFloat(WATCHER_DAMAGEBONUS);
if (SpellHelper.instance.attackTargetSpecial(null, e, DamageSources.causeEntityFireDamage(dummycaster), damage) && !(e instanceof EntityPlayer))
e.hurtResistantTime = 10;
e.addVelocity(-(e.motionX - lastVelX), -(e.motionY - lastVelY), -(e.motionZ - lastVelZ));
}
}
if (this.dataWatcher.getWatchableObjectByte(WATCHER_ROF_IGNITE) == 1 && rand.nextInt(10) < 2) {
int pX = (int) (posX - radius + rand.nextInt((int) Math.ceil(radius) * 2));
int pY = (int) posY;
int pZ = (int) (posZ - radius + rand.nextInt((int) Math.ceil(radius) * 2));
if (worldObj.isAirBlock(pX, pY, pZ))
worldObj.setBlock(pX, pY, pZ, Blocks.fire);
}
}
}
use of am2.particles.AMParticle in project ArsMagica2 by Mithion.
the class EntityDryad method onUpdate.
@Override
public void onUpdate() {
World world = this.worldObj;
super.onUpdate();
if (!world.isRemote || world == null) {
return;
}
if (worldObj.rand.nextInt(100) == 3) {
AMParticle effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(world, "hr_sparkles_1", this.posX, this.posY + 2, this.posZ);
if (effect != null) {
effect.AddParticleController(new ParticleOrbitEntity(effect, this, worldObj.rand.nextDouble() * 0.2 + 0.2, 1, false));
effect.setIgnoreMaxAge(false);
effect.setRGBColorF(0.1f, 0.8f, 0.1f);
}
}
}
use of am2.particles.AMParticle in project ArsMagica2 by Mithion.
the class EntityAirSled method onUpdate.
@Override
public void onUpdate() {
this.stepHeight = 1.02f;
if (worldObj.isRemote) {
rotation += 1f;
if (this.worldObj.isAirBlock((int) this.posX, (int) (this.posY - 1), (int) this.posZ)) {
for (int i = 0; i < AMCore.config.getGFXLevel(); ++i) {
AMParticle cloud = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "sparkle2", posX, posY + 0.5, posZ);
if (cloud != null) {
cloud.addRandomOffset(1, 1, 1);
cloud.AddParticleController(new ParticleFadeOut(cloud, 1, false).setFadeSpeed(0.01f));
}
}
}
}
super.onUpdate();
}
use of am2.particles.AMParticle in project ArsMagica2 by Mithion.
the class TileEntityCraftingAltar method updateEntity.
@Override
public void updateEntity() {
super.updateEntity();
this.ticksExisted++;
checkStructure();
checkForStartCondition();
updateLecternInformation();
if (isCrafting) {
checkForEndCondition();
updatePowerRequestData();
if (!worldObj.isRemote && !currentDefinitionIsWithinStructurePower() && this.ticksExisted > 100) {
worldObj.newExplosion(null, xCoord + 0.5, yCoord - 1.5, zCoord + 0.5, 5, false, true);
setCrafting(false);
return;
}
if (worldObj.isRemote && checkCounter == 1) {
AMCore.proxy.particleManager.RibbonFromPointToPoint(worldObj, xCoord + 0.5, yCoord - 2, zCoord + 0.5, xCoord + 0.5, yCoord - 3, zCoord + 0.5);
}
List<EntityItem> components = lookForValidItems();
ItemStack stack = getNextPlannedItem();
for (EntityItem item : components) {
if (item.isDead)
continue;
ItemStack entityItemStack = item.getEntityItem();
if (stack != null && compareItemStacks(stack, entityItemStack)) {
if (!worldObj.isRemote) {
updateCurrentRecipe(item);
item.setDead();
} else {
worldObj.playSound(xCoord, yCoord, zCoord, "arsmagica2:misc.craftingaltar.component_added", 1.0f, 0.4f + worldObj.rand.nextFloat() * 0.6f, false);
for (int i = 0; i < 5 * AMCore.config.getGFXLevel(); ++i) {
AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "radiant", item.posX, item.posY, item.posZ);
if (particle != null) {
particle.setMaxAge(40);
particle.AddParticleController(new ParticleMoveOnHeading(particle, worldObj.rand.nextFloat() * 360, worldObj.rand.nextFloat() * 360, 0.01f, 1, false));
particle.AddParticleController(new ParticleFadeOut(particle, 1, false).setFadeSpeed(0.05f).setKillParticleOnFinish(true));
particle.setParticleScale(0.02f);
particle.setRGBColorF(worldObj.rand.nextFloat(), worldObj.rand.nextFloat(), worldObj.rand.nextFloat());
}
}
}
}
}
}
}
Aggregations