use of net.minecraft.entity.boss.EntityDragonPart in project ArsMagica2 by Mithion.
the class Beam method beginStackStage.
@Override
public SpellCastResult beginStackStage(ItemSpellBase item, ItemStack stack, EntityLivingBase caster, EntityLivingBase target, World world, double x, double y, double z, int side, boolean giveXP, int useCount) {
boolean shouldApplyEffect = useCount % 10 == 0;
double range = SpellUtils.instance.getModifiedDouble_Add(SpellModifiers.RANGE, stack, caster, target, world, 0);
boolean targetWater = SpellUtils.instance.modifierIsPresent(SpellModifiers.TARGET_NONSOLID_BLOCKS, stack, 0);
MovingObjectPosition mop = item.getMovingObjectPosition(caster, world, range, true, targetWater);
SpellCastResult result = null;
Vec3 beamHitVec = null;
Vec3 spellVec = null;
if (mop == null) {
beamHitVec = MathUtilities.extrapolateEntityLook(world, caster, range);
spellVec = beamHitVec;
} else if (mop.typeOfHit == MovingObjectType.ENTITY) {
if (shouldApplyEffect) {
Entity e = mop.entityHit;
if (e instanceof EntityDragonPart && ((EntityDragonPart) e).entityDragonObj instanceof EntityLivingBase)
e = (EntityLivingBase) ((EntityDragonPart) e).entityDragonObj;
result = SpellHelper.instance.applyStageToEntity(stack, caster, world, e, 0, giveXP);
if (result != SpellCastResult.SUCCESS) {
return result;
}
}
float rng = (float) mop.hitVec.distanceTo(Vec3.createVectorHelper(caster.posX, caster.posY, caster.posZ));
beamHitVec = MathUtilities.extrapolateEntityLook(world, caster, rng);
spellVec = beamHitVec;
} else {
if (shouldApplyEffect) {
result = SpellHelper.instance.applyStageToGround(stack, caster, world, mop.blockX, mop.blockY, mop.blockZ, mop.sideHit, mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord, 0, giveXP);
if (result != SpellCastResult.SUCCESS) {
return result;
}
}
beamHitVec = mop.hitVec;
spellVec = Vec3.createVectorHelper(mop.blockX, mop.blockY, mop.blockZ);
}
if (world.isRemote && beamHitVec != null) {
AMBeam beam = (AMBeam) beams.get(caster.getEntityId());
double startX = caster.posX;
double startY = caster.posY + caster.getEyeHeight() - 0.2f;
double startZ = caster.posZ;
Affinity affinity = SpellUtils.instance.mainAffinityFor(stack);
int color = -1;
if (SpellUtils.instance.modifierIsPresent(SpellModifiers.COLOR, stack, 0)) {
ISpellModifier[] mods = SpellUtils.instance.getModifiersForStage(stack, 0);
int ordinalCount = 0;
for (ISpellModifier mod : mods) {
if (mod instanceof Colour) {
byte[] meta = SpellUtils.instance.getModifierMetadataFromStack(stack, mod, 0, ordinalCount++);
color = (int) mod.getModifier(SpellModifiers.COLOR, null, null, null, meta);
}
}
}
if (beam != null) {
if (beam.isDead || beam.getDistanceSqToEntity(caster) > 4) {
beams.remove(caster.getEntityId());
} else {
beam.setBeamLocationAndTarget(startX, startY, startZ, beamHitVec.xCoord, beamHitVec.yCoord, beamHitVec.zCoord);
}
} else {
if (affinity == Affinity.LIGHTNING) {
AMCore.instance.proxy.particleManager.BoltFromEntityToPoint(world, caster, beamHitVec.xCoord, beamHitVec.yCoord, beamHitVec.zCoord, 1, color == -1 ? affinity.color : color);
} else {
beam = (AMBeam) AMCore.instance.proxy.particleManager.BeamFromEntityToPoint(world, caster, beamHitVec.xCoord, beamHitVec.yCoord, beamHitVec.zCoord, color == -1 ? affinity.color : color);
if (beam != null) {
if (AMCore.instance.proxy.getProxyUtils().isLocalPlayerInFirstPerson())
beam.setFirstPersonPlayerCast();
beams.put(caster.getEntityId(), beam);
}
}
}
for (int i = 0; i < AMCore.config.getGFXLevel() + 1; ++i) {
AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(world, AMParticleIcons.instance.getParticleForAffinity(affinity), beamHitVec.xCoord, beamHitVec.yCoord, beamHitVec.zCoord);
if (particle != null) {
particle.setMaxAge(2);
particle.setParticleScale(0.1f);
particle.setIgnoreMaxAge(false);
if (color != -1)
particle.setRGBColorI(color);
particle.AddParticleController(new ParticleMoveOnHeading(particle, world.rand.nextDouble() * 360, world.rand.nextDouble() * 360, world.rand.nextDouble() * 0.2 + 0.02f, 1, false));
}
}
}
if (result != null && spellVec != null && shouldApplyEffect) {
ItemStack newItemStack = SpellUtils.instance.popStackStage(stack);
return SpellHelper.instance.applyStackStage(newItemStack, caster, target, spellVec.xCoord, spellVec.yCoord, spellVec.zCoord, mop != null ? mop.sideHit : 0, world, true, giveXP, 0);
} else {
return SpellCastResult.SUCCESS_REDUCE_MANA;
}
}
use of net.minecraft.entity.boss.EntityDragonPart in project ArsMagica2 by Mithion.
the class Touch method beginStackStage.
@Override
public SpellCastResult beginStackStage(ItemSpellBase item, ItemStack stack, EntityLivingBase caster, EntityLivingBase target, World world, double x, double y, double z, int side, boolean giveXP, int useCount) {
if (target != null) {
Entity e = target;
if (e instanceof EntityDragonPart && ((EntityDragonPart) e).entityDragonObj instanceof EntityLivingBase)
e = (EntityLivingBase) ((EntityDragonPart) e).entityDragonObj;
SpellCastResult result = SpellHelper.instance.applyStageToEntity(stack, caster, world, e, 0, giveXP);
return result;
}
boolean targetWater = SpellUtils.instance.modifierIsPresent(SpellModifiers.TARGET_NONSOLID_BLOCKS, stack, 0);
MovingObjectPosition mop = item.getMovingObjectPosition(caster, world, 2.5f, true, targetWater);
if (mop == null) {
return SpellCastResult.EFFECT_FAILED;
} else {
if (mop.typeOfHit == MovingObjectType.ENTITY) {
Entity e = mop.entityHit;
if (e instanceof EntityDragonPart && ((EntityDragonPart) e).entityDragonObj instanceof EntityLivingBase)
e = (EntityLivingBase) ((EntityDragonPart) e).entityDragonObj;
SpellCastResult result = SpellHelper.instance.applyStageToEntity(stack, caster, world, (target == null) ? e : target, 0, giveXP);
if (result != SpellCastResult.SUCCESS) {
return result;
}
ItemStack newItemStack = SpellUtils.instance.popStackStage(stack);
return SpellHelper.instance.applyStackStage(newItemStack, caster, target, mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord, 0, world, true, giveXP, 0);
} else {
SpellCastResult result = SpellHelper.instance.applyStageToGround(stack, caster, world, mop.blockX, mop.blockY, mop.blockZ, mop.sideHit, mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord, 0, giveXP);
if (result != SpellCastResult.SUCCESS) {
return result;
}
ItemStack newItemStack = SpellUtils.instance.popStackStage(stack);
return SpellHelper.instance.applyStackStage(newItemStack, caster, target, mop.blockX, mop.blockY, mop.blockZ, mop.sideHit, world, true, giveXP, 0);
}
}
}
use of net.minecraft.entity.boss.EntityDragonPart 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;
}
}
use of net.minecraft.entity.boss.EntityDragonPart 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 net.minecraft.entity.boss.EntityDragonPart in project ArsMagica2 by Mithion.
the class EntitySpellProjectile method HitObject.
protected void HitObject(MovingObjectPosition movingobjectposition, boolean pierce) {
if (movingobjectposition.entityHit != null) {
if (movingobjectposition.entityHit == getShootingEntity() || getShootingEntity() == null)
return;
Entity e = movingobjectposition.entityHit;
if (e instanceof EntityDragonPart && ((EntityDragonPart) e).entityDragonObj instanceof EntityLivingBase)
e = (EntityLivingBase) ((EntityDragonPart) e).entityDragonObj;
if (e instanceof EntityLivingBase && getShootingEntity() != null && !this.entityHits.contains(movingobjectposition.entityHit.getEntityId())) {
SpellHelper.instance.applyStageToEntity(this.getEffectStack(), getShootingEntity(), this.worldObj, e, 0, true);
SpellHelper.instance.applyStackStage(SpellUtils.instance.popStackStage(getEffectStack()), getShootingEntity(), (EntityLivingBase) e, movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord, 0, worldObj, false, true, 0);
this.entityHits.add(movingobjectposition.entityHit.getEntityId());
}
} else {
AMVector3 blockLoc = new AMVector3(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ);
if (getShootingEntity() != null && !this.blockhits.contains(blockLoc)) {
SpellHelper.instance.applyStageToGround(getEffectStack(), getShootingEntity(), worldObj, movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ, movingobjectposition.sideHit, movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord, 0, true);
SpellHelper.instance.applyStackStage(SpellUtils.instance.popStackStage(getEffectStack()), getShootingEntity(), getShootingEntity(), movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ, movingobjectposition.sideHit, worldObj, false, true, 0);
this.blockhits.add(blockLoc);
}
}
this.setNumPierces(this.getNumPierces() - 1);
if (!worldObj.isRemote && !pierce) {
this.setDead();
}
}
Aggregations