use of net.minecraft.entity.boss.EntityDragonPart in project ArsMagica2 by Mithion.
the class EntitySpellProjectile method onUpdate.
@Override
public void onUpdate() {
//super.onUpdate();
if (!worldObj.isRemote && (getShootingEntity() == null || getShootingEntity().isDead)) {
setDead();
} else {
ticksExisted++;
int maxTicksToLive = maxTicksToExist > -1 ? maxTicksToExist : 100;
if (ticksExisted >= maxTicksToLive && !worldObj.isRemote) {
setDead();
return;
}
}
//TODO Fix homing
if (this.dataWatcher.getWatchableObjectByte(DW_HOMING) != (byte) 0 && this.ticksExisted > 10) {
if (this.dataWatcher.getWatchableObjectInt(DW_HOMING_TARGET) == -1) {
findHomingTarget();
} else {
EntityLivingBase homingTarget = getHomingEntity();
//AMCore.log.info("%.2f, %.2f, %.2f", posX, posY, posZ);
LogHelper.trace("Homing Target: " + getHomingEntity());
if (homingTarget != null && new AMVector3(this).distanceSqTo(new AMVector3(homingTarget)) > 2) {
this.moveTowards(homingTarget, 60, 60);
}
}
}
Vec3 vec3d = Vec3.createVectorHelper(posX, posY, posZ);
Vec3 vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
MovingObjectPosition movingobjectposition = null;
movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1, true);
vec3d = Vec3.createVectorHelper(posX, posY, posZ);
vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
if (movingobjectposition != null) {
vec3d1 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
}
Entity entity = null;
List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
double d = 0.0D;
for (int j = 0; j < list.size(); j++) {
Entity entity1 = (Entity) list.get(j);
if (!entity1.canBeCollidedWith() || entity1.isEntityEqual(getShootingEntity())) {
continue;
}
float f2 = 0.3F;
AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f2, f2, f2);
MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3d, vec3d1);
if (movingobjectposition1 == null) {
continue;
}
double d1 = vec3d.distanceTo(movingobjectposition1.hitVec);
if (d1 < d || d == 0.0D) {
entity = entity1;
d = d1;
}
}
if (entity != null) {
if (entity instanceof EntityDragonPart && ((EntityDragonPart) entity).entityDragonObj != null && ((EntityDragonPart) entity).entityDragonObj instanceof EntityLivingBase) {
entity = (EntityLivingBase) ((EntityDragonPart) entity).entityDragonObj;
}
movingobjectposition = new MovingObjectPosition(entity);
}
if (movingobjectposition != null) {
boolean doHit = true;
boolean pierce = this.getNumPierces() > 0;
if (movingobjectposition.typeOfHit == MovingObjectType.ENTITY && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityLivingBase) {
EntityLivingBase ent = (EntityLivingBase) movingobjectposition.entityHit;
if (ent.isPotionActive(BuffList.spellReflect.id) && !pierce) {
doHit = false;
this.setShootingEntity(ent);
this.motionX = -this.motionX;
this.motionY = -this.motionY;
this.motionZ = -this.motionZ;
if (!worldObj.isRemote)
ent.removePotionEffect(BuffList.spellReflect.id);
setBounces(originalBounceCount);
if (worldObj.isRemote) {
for (int i = 0; i < 13; ++i) {
AMParticle effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(worldObj, "hr_lensflare", ent.posX + rand.nextDouble() - 0.5, ent.posY + ent.getEyeHeight() + rand.nextDouble() - 0.5, ent.posZ + rand.nextDouble() - 0.5);
if (effect != null) {
EntityPlayer player = AMCore.instance.proxy.getLocalPlayer();
effect.setIgnoreMaxAge(true);
if (player != null && ent != player) {
effect.setParticleScale(1.5f);
}
effect.setRGBColorF(0.5f + rand.nextFloat() * 0.5f, 0.2f, 0.5f + rand.nextFloat() * 0.5f);
effect.AddParticleController(new ParticleHoldPosition(effect, 100, 1, false));
}
}
}
}
} else if (movingobjectposition.typeOfHit == MovingObjectType.BLOCK && getBounces() > 0) {
doHit = false;
switch(movingobjectposition.sideHit) {
case 0:
case 1:
motionY = motionY * friction_coefficient * -1;
break;
case 2:
case 3:
motionZ = motionZ * friction_coefficient * -1;
break;
case 4:
case 5:
motionX = motionX * friction_coefficient * -1;
break;
}
this.setBounces(getBounces() - 1);
}
if (movingobjectposition.typeOfHit == MovingObjectType.BLOCK) {
Block block = worldObj.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ);
AxisAlignedBB bb = block.getCollisionBoundingBoxFromPool(worldObj, movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ);
if (bb == null && !SpellUtils.instance.modifierIsPresent(SpellModifiers.TARGET_NONSOLID_BLOCKS, getEffectStack(), 0))
doHit = false;
}
if (doHit)
HitObject(movingobjectposition, pierce);
}
if (getGravity() < 0 && motionY > GRAVITY_TERMINAL_VELOCITY) {
this.motionY += getGravity();
} else if (getGravity() > 0 && motionY < -GRAVITY_TERMINAL_VELOCITY) {
this.motionY -= getGravity();
}
posX += motionX;
posY += motionY;
posZ += motionZ;
float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
rotationYaw = (float) (Math.atan2(motionX, motionZ));
for (rotationPitch = (float) (Math.atan2(motionY, f)); rotationPitch - prevRotationPitch < -180F; prevRotationPitch -= 360F) {
}
for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F) {
}
for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F) {
}
for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F) {
}
rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
float f1 = 0.95F;
if (isInWater()) {
for (int k = 0; k < 4; k++) {
float f3 = 0.25F;
worldObj.spawnParticle("bubble", posX - motionX * f3, posY - motionY * f3, posZ - motionZ * f3, motionX, motionY, motionZ);
}
f1 = 0.8F;
}
if (!AMCore.config.NoGFX() && worldObj.isRemote && this.getShootingEntity() instanceof EntityPlayer) {
if (this.particleType == null || this.particleType.isEmpty())
particleType = AMParticleIcons.instance.getSecondaryParticleForAffinity(SpellUtils.instance.mainAffinityFor(getEffectStack()));
AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, particleType, this.posX, this.posY, this.posZ);
if (particle != null) {
particle.addRandomOffset(0.3f, 0.3f, 0.3f);
particle.AddParticleController(new ParticleFloatUpward(particle, 0.1f, 0, 1, false));
particle.setMaxAge(10);
particle.setParticleScale(0.05f);
}
}
setPosition(posX, posY, posZ);
}
Aggregations