use of am2.entities.EntityDummyCaster in project ArsMagica2 by Mithion.
the class EntitySpellEffect method wallUpdate.
private void wallUpdate() {
if (worldObj.isRemote) {
if (spellStack == null) {
spellStack = this.dataWatcher.getWatchableObjectItemStack(22);
if (spellStack == null) {
return;
}
}
double dist = this.dataWatcher.getWatchableObjectFloat(WATCHER_RADIUS);
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);
}
}
}
double px = Math.cos(3.141 / 180 * (rotationYaw + 90)) * 0.1f;
double pz = Math.sin(3.141 / 180 * (rotationYaw + 90)) * 0.1f;
double py = 0.1f;
for (float i = 0; i < dist; i += 0.5f) {
double x = this.posX - Math.cos(3.141 / 180 * (rotationYaw)) * i;
double z = this.posZ - Math.sin(3.141 / 180 * (rotationYaw)) * i;
AMParticle effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(worldObj, AMParticleIcons.instance.getParticleForAffinity(SpellUtils.instance.mainAffinityFor(spellStack)), x, posY, z);
if (effect != null) {
effect.setIgnoreMaxAge(false);
effect.setMaxAge(20);
effect.addRandomOffset(1, 1, 1);
effect.setParticleScale(0.15f);
effect.setRGBColorI(color);
if (dataWatcher.getWatchableObjectInt(WATCHER_TYPE) == TYPE_WALL) {
effect.AddParticleController(new ParticleFloatUpward(effect, 0, 0.07f, 1, false));
} else {
effect.setAffectedByGravity();
effect.setDontRequireControllers();
effect.addVelocity(px, py, pz);
}
}
x = this.posX - Math.cos(Math.toRadians(rotationYaw)) * -i;
z = this.posZ - Math.sin(Math.toRadians(rotationYaw)) * -i;
effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(worldObj, AMParticleIcons.instance.getParticleForAffinity(SpellUtils.instance.mainAffinityFor(spellStack)), x, posY, z);
if (effect != null) {
effect.setIgnoreMaxAge(false);
effect.addRandomOffset(1, 1, 1);
effect.setMaxAge(20);
effect.setParticleScale(0.15f);
effect.setRGBColorI(color);
if (dataWatcher.getWatchableObjectInt(WATCHER_TYPE) == TYPE_WALL) {
effect.AddParticleController(new ParticleFloatUpward(effect, 0, 0.07f, 1, false));
} else {
effect.setAffectedByGravity();
effect.setDontRequireControllers();
effect.addVelocity(px, py, pz);
}
}
}
} else {
ticksToEffect--;
if (spellStack == null) {
if (!worldObj.isRemote) {
this.setDead();
}
return;
}
if (dummycaster == null) {
dummycaster = DummyEntityPlayer.fromEntityLiving(new EntityDummyCaster(worldObj));
}
if (ticksToEffect <= 0) {
ticksToEffect = maxTicksToEffect_wall;
float radius = this.dataWatcher.getWatchableObjectFloat(WATCHER_RADIUS);
List<Entity> possibleTargets = worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(posX - radius, posY - 1, posZ - radius, posX + radius, posY + 3, posZ + radius));
ItemStack newStack = SpellUtils.instance.popStackStage(spellStack);
for (Entity e : possibleTargets) {
if (e == this || e == dummycaster || e.getEntityId() == casterEntityID)
continue;
if (e instanceof EntityDragonPart && ((EntityDragonPart) e).entityDragonObj instanceof EntityLivingBase)
e = (EntityLivingBase) ((EntityDragonPart) e).entityDragonObj;
AMVector3 target = new AMVector3(e);
double dirX = Math.cos(3.141 / 180 * (rotationYaw));
double dirZ = Math.sin(3.141 / 180 * (rotationYaw));
AMVector3 a = new AMVector3(this.posX - dirX * radius, this.posY, this.posZ - dirZ * radius);
AMVector3 b = new AMVector3(this.posX - dirX * -radius, this.posY, this.posZ - dirZ * -radius);
AMVector3 closest = new AMLineSegment(a, b).closestPointOnLine(target);
closest.y = 0;
target.y = 0;
double hDistance = closest.distanceTo(target);
double vDistance = Math.abs(this.posY - e.posY);
if (e instanceof EntityLivingBase && hDistance < 0.75f && vDistance < 2) {
//commented out in favor of line below so as to apply subsequent shapes as well
//uncomment and comment out below line to revert to direct target only, but mark wave/wall as terminus
//SpellHelper.instance.applyStageToEntity(spellStack, dummycaster, worldObj, e, 0, false);
SpellHelper.instance.applyStackStage(spellStack, dummycaster, (EntityLivingBase) e, this.posX, this.posY, this.posZ, 0, worldObj, false, false, 0);
}
}
}
}
}
use of am2.entities.EntityDummyCaster in project ArsMagica2 by Mithion.
the class BlockManaBattery method destroy.
private void destroy(World world, int i, int j, int k) {
TileEntityManaBattery te = getTileEntity(world, i, j, k);
if (te != null && !world.isRemote) {
float f = world.rand.nextFloat() * 0.8F + 0.1F;
float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
float f2 = world.rand.nextFloat() * 0.8F + 0.1F;
int dmg = (int) ((PowerNodeRegistry.For(world).getPower(te, te.getPowerType()) / te.getCapacity()) * 100);
if (dmg == 0)
dmg = 1;
ItemStack stack = new ItemStack(this);
stack.damageItem(stack.getMaxDamage() - dmg, new EntityDummyCaster(world));
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setFloat("mana_battery_charge", PowerNodeRegistry.For(world).getPower(te, te.getPowerType()));
stack.stackTagCompound.setInteger("mana_battery_powertype", te.getPowerType().ID());
if (!stack.stackTagCompound.hasKey("Lore"))
stack.stackTagCompound.setTag("Lore", new NBTTagList());
NBTTagList tagList = new NBTTagList();
PowerTypes powerType = te.getPowerType();
float amt = PowerNodeRegistry.For(world).getPower(te, powerType);
tagList.appendTag(new NBTTagString(String.format("Contains %.2f %s%s etherium", amt, powerType.chatColor(), powerType.name())));
stack.stackTagCompound.setTag("Lore", tagList);
EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, stack);
float f3 = 0.05F;
entityitem.motionX = (float) world.rand.nextGaussian() * f3;
entityitem.motionY = (float) world.rand.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) world.rand.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
}
}
use of am2.entities.EntityDummyCaster in project ArsMagica2 by Mithion.
the class EntitySpellEffect method waveUpdate.
private void waveUpdate() {
ticksToEffect = 0;
wallUpdate();
double dx = Math.cos(Math.toRadians(this.rotationYaw + 90));
double dz = Math.sin(Math.toRadians(this.rotationYaw + 90));
this.moveEntity(dx * moveSpeed, 0, dz * moveSpeed);
double dxH = Math.cos(Math.toRadians(this.rotationYaw));
double dzH = Math.sin(Math.toRadians(this.rotationYaw));
float radius = this.dataWatcher.getWatchableObjectFloat(WATCHER_RADIUS);
AMVector3 a = new AMVector3((this.posX + dx) - dxH * radius, this.posY, (this.posZ + dz) - dzH * radius);
AMVector3 b = new AMVector3((this.posX + dx) - dxH * -radius, this.posY, (this.posZ + dz) - dzH * -radius);
if (dummycaster == null) {
dummycaster = DummyEntityPlayer.fromEntityLiving(new EntityDummyCaster(worldObj));
}
AMVector3[] vecs = getAllBlockLocationsBetween(a, b);
for (AMVector3 vec : vecs) {
SpellHelper.instance.applyStageToGround(spellStack, dummycaster, worldObj, (int) vec.x, (int) vec.y, (int) vec.z, 0, vec.x + 0.5, vec.y + 0.5, vec.z + 0.5, 0, false);
}
}
use of am2.entities.EntityDummyCaster in project ArsMagica2 by Mithion.
the class EntitySpellEffect method zoneUpdate.
private void zoneUpdate() {
if (this.worldObj.isRemote) {
if (!AMCore.config.NoGFX()) {
this.rotation += this.rotationSpeed;
this.rotation %= 360;
double dist = this.dataWatcher.getWatchableObjectFloat(WATCHER_RADIUS);
double _rotation = rotation;
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);
}
}
}
if ((AMCore.config.FullGFX() && this.ticksExisted % 2 == 0) || this.ticksExisted % 8 == 0) {
for (int i = 0; i < 4; ++i) {
_rotation = (rotation + (90 * i)) % 360;
double x = this.posX - Math.cos(3.141 / 180 * (_rotation)) * dist;
double z = this.posZ - Math.sin(3.141 / 180 * (_rotation)) * dist;
AMParticle effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(worldObj, AMParticleIcons.instance.getParticleForAffinity(SpellUtils.instance.mainAffinityFor(spellStack)), x, posY, z);
if (effect != null) {
effect.setIgnoreMaxAge(false);
effect.setMaxAge(20);
effect.setParticleScale(0.15f);
effect.setRGBColorI(color);
effect.AddParticleController(new ParticleFloatUpward(effect, 0, 0.07f, 1, false));
if (AMCore.config.LowGFX()) {
effect.AddParticleController(new ParticleOrbitPoint(effect, posX, posY, posZ, 2, false).setIgnoreYCoordinate(true).SetOrbitSpeed(0.05f).SetTargetDistance(dist).setRotateDirection(true));
}
}
}
}
}
}
this.moveEntity(0, this.dataWatcher.getWatchableObjectInt(WATCHER_GRAVITY) / 100.0f, 0);
ticksToEffect--;
if (spellStack == null) {
if (!worldObj.isRemote) {
this.setDead();
}
return;
}
if (dummycaster == null) {
dummycaster = DummyEntityPlayer.fromEntityLiving(new EntityDummyCaster(worldObj));
}
if (ticksToEffect <= 0) {
ticksToEffect = maxTicksToEffect;
float radius = this.dataWatcher.getWatchableObjectFloat(WATCHER_RADIUS);
List<Entity> possibleTargets = worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(posX - radius, posY - 1, posZ - radius, posX + radius, posY + 3, posZ + radius));
for (Entity e : possibleTargets) {
if (e instanceof EntityDragonPart && ((EntityDragonPart) e).entityDragonObj instanceof EntityLivingBase)
e = (EntityLivingBase) ((EntityDragonPart) e).entityDragonObj;
if (e instanceof EntityLivingBase)
SpellHelper.instance.applyStageToEntity(spellStack, dummycaster, worldObj, e, 0, false);
}
if (this.dataWatcher.getWatchableObjectInt(WATCHER_GRAVITY) < 0 && !firstApply)
SpellHelper.instance.applyStackStage(spellStack, dummycaster, null, posX, posY - 1, posZ, 0, worldObj, false, false, this.ticksExisted);
else
SpellHelper.instance.applyStackStage(spellStack, dummycaster, null, posX, posY, posZ, 0, worldObj, false, false, this.ticksExisted);
firstApply = false;
}
}
Aggregations