use of net.minecraft.entity.boss.EntityDragonPart in project Trains-In-Motion-1.7.10 by EternalBlueFlame.
the class GenericRailTransport method attackEntityFrom.
@Override
public boolean attackEntityFrom(DamageSource damageSource, float p_70097_2_) {
//if its a creative player, destroy instantly
if (damageSource.getEntity() instanceof EntityPlayer && ((EntityPlayer) damageSource.getEntity()).capabilities.isCreativeMode && !damageSource.isProjectile()) {
health -= 20;
//if its reinforced and its not an explosion
} else if (isReinforced() && !damageSource.isProjectile() && !damageSource.isExplosion()) {
health -= 1;
//if it is an explosion and it's reinforced, or it's not an explosion and isn't reinforced
} else if ((damageSource.isExplosion() && isReinforced()) || (!isReinforced() && !damageSource.isProjectile())) {
health -= 5;
//if it isn't reinforced and is an explosion
} else if (damageSource.isExplosion() && !isReinforced()) {
health -= 20;
}
//cover overheating, or other damage to self.
if (damageSource.getSourceOfDamage() == this) {
health -= 20;
}
//on Destruction
if (health < 1) {
//remove bogies
frontBogie.isDead = true;
TrainsInMotion.keyChannel.sendToServer(new PacketRemove(frontBogie.getEntityId()));
worldObj.removeEntity(frontBogie);
backBogie.isDead = true;
TrainsInMotion.keyChannel.sendToServer(new PacketRemove(backBogie.getEntityId()));
worldObj.removeEntity(backBogie);
//remove seats
for (EntitySeat seat : seats) {
seat.isDead = true;
TrainsInMotion.keyChannel.sendToServer(new PacketRemove(seat.getEntityId()));
seat.worldObj.removeEntity(seat);
}
//remove hitboxes
for (EntityDragonPart hitbox : hitboxHandler.hitboxList) {
hitbox.isDead = true;
TrainsInMotion.keyChannel.sendToServer(new PacketRemove(hitbox.getEntityId()));
hitbox.worldObj.removeEntity(hitbox);
}
//if the damage source is an explosion, or this (from overheating as an example), we circumstantially blow up.
//radius is defined by whether or not it's a nuclear train, and fire spread creation is defined by whether or not it's diesel.
//remove this
isDead = true;
TrainsInMotion.keyChannel.sendToServer(new PacketRemove(getEntityId()));
worldObj.removeEntity(this);
}
return false;
}
use of net.minecraft.entity.boss.EntityDragonPart in project ArsMagica2 by Mithion.
the class Chain 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) {
MovingObjectPosition mop = item.getMovingObjectPosition(caster, world, 8.0f, true, false);
double range = SpellUtils.instance.getModifiedDouble_Mul(4, stack, caster, target, world, 0, SpellModifiers.RANGE);
int num_targets = SpellUtils.instance.getModifiedInt_Add(3, stack, caster, target, world, 0, SpellModifiers.PROCS);
ArrayList<EntityLivingBase> targets = new ArrayList<EntityLivingBase>();
if (target != null) {
mop = new MovingObjectPosition(target);
}
if (mop != null && mop.typeOfHit == MovingObjectType.ENTITY && mop.entityHit != null) {
Entity e = mop.entityHit;
if (e instanceof EntityDragonPart && ((EntityDragonPart) e).entityDragonObj instanceof EntityLivingBase)
e = (EntityLivingBase) ((EntityDragonPart) e).entityDragonObj;
if (e instanceof EntityLivingBase) {
do {
targets.add((EntityLivingBase) e);
List<EntityLivingBase> nearby = world.getEntitiesWithinAABB(EntityLivingBase.class, e.boundingBox.expand(range, range, range));
EntityLivingBase closest = null;
for (EntityLivingBase near : nearby) {
if (targets.contains(near) || near == caster)
continue;
if (closest == null || closest.getDistanceSqToEntity(e) > near.getDistanceSqToEntity(e)) {
closest = near;
}
}
e = closest;
} while (e != null && targets.size() < num_targets);
}
}
ItemStack newItemStack = SpellUtils.instance.popStackStage(stack);
boolean atLeastOneApplication = false;
SpellCastResult result = SpellCastResult.SUCCESS;
EntityLivingBase prevEntity = null;
for (EntityLivingBase e : targets) {
if (e == caster)
continue;
result = SpellHelper.instance.applyStageToEntity(stack, caster, world, e, 0, giveXP);
SpellHelper.instance.applyStackStage(newItemStack, caster, e, e.posX, e.posY, e.posZ, 0, world, true, giveXP, 0);
if (world.isRemote) {
if (prevEntity == null)
spawnChainParticles(world, x, y, z, e.posX, e.posY + e.getEyeHeight(), e.posZ, stack);
else
spawnChainParticles(world, prevEntity.posX, prevEntity.posY + e.getEyeHeight(), prevEntity.posZ, e.posX, e.posY + e.getEyeHeight(), e.posZ, stack);
}
prevEntity = e;
if (result == SpellCastResult.SUCCESS) {
atLeastOneApplication = true;
}
}
if (atLeastOneApplication) {
return SpellCastResult.SUCCESS;
}
return result;
}
use of net.minecraft.entity.boss.EntityDragonPart 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 net.minecraft.entity.boss.EntityDragonPart in project ArsMagica2 by Mithion.
the class EntitySpellEffect method blizzardUpdate.
private void blizzardUpdate() {
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 < 20; ++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, "snowflakes", x, y, z);
if (particle != null) {
particle.setMaxAge(20);
particle.setParticleScale(0.1f);
particle.addVelocity(rand.nextDouble() * 0.2f - 0.1f, 0, rand.nextDouble() * 0.2f - 0.1f);
particle.setAffectedByGravity();
particle.setRGBColorI(color);
particle.setDontRequireControllers();
particle.noClip = false;
}
}
double x = this.posX - radius + (rand.nextDouble() * radius * 2);
double z = this.posZ - radius + (rand.nextDouble() * radius * 2);
double y = this.posY + rand.nextDouble();
AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "smoke", x, y, z);
if (particle != null) {
particle.setParticleScale(2.0f);
particle.setMaxAge(20);
// particle.setRGBColorF(0.5f, 0.92f, 0.92f);
particle.setRGBColorF(0.5098f, 0.7843f, 0.7843f);
particle.SetParticleAlpha(0.6f);
particle.AddParticleController(new ParticleFleePoint(particle, new AMVector3(x, y, z), 0.1f, 3f, 1, false));
}
// TODO: SoundHelper.instance.loopSound(worldObj, (float)posX, (float)posY, (float)posZ, "arsmagica2:spell.loop.air", 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;
if (e instanceof EntityLivingBase)
((EntityLivingBase) e).addPotionEffect(new BuffEffectFrostSlowed(80, 3));
float damage = 1 * this.dataWatcher.getWatchableObjectFloat(WATCHER_DAMAGEBONUS);
double lastVelX = e.motionX;
double lastVelY = e.motionY;
double lastVelZ = e.motionZ;
if (SpellHelper.instance.attackTargetSpecial(null, e, DamageSources.causeEntityFrostDamage(dummycaster), damage) && !(e instanceof EntityPlayer))
e.hurtResistantTime = 15;
e.addVelocity(-(e.motionX - lastVelX), -(e.motionY - lastVelY), -(e.motionZ - lastVelZ));
}
}
if (rand.nextInt(10) < 2) {
int pX = (int) (posX - radius + rand.nextInt((int) Math.ceil(radius) * 2));
int pY = (int) posY + rand.nextInt(2);
int pZ = (int) (posZ - radius + rand.nextInt((int) Math.ceil(radius) * 2));
if (worldObj.isAirBlock(pX, pY, pZ) && !worldObj.isAirBlock(pX, pY - 1, pZ) && worldObj.getBlock(pX, pY, pZ).isOpaqueCube())
worldObj.setBlock(pX, pY, pZ, Blocks.snow);
}
}
}
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