use of com.builtbroken.mc.imp.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class BlastEndothermic method doPostExplode.
@Override
public void doPostExplode() {
super.doPostExplode();
if (!this.world().isRemote) {
if (this.canFocusBeam(this.world(), position) && this.thread.isComplete) {
/*
* Freeze all nearby entities.
*/
List<EntityLiving> livingEntities = world().getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBox(position.x() - getRadius(), position.y() - getRadius(), position.z() - getRadius(), position.x() + getRadius(), position.y() + getRadius(), position.z() + getRadius()));
if (livingEntities != null && !livingEntities.isEmpty()) {
Iterator<EntityLiving> it = livingEntities.iterator();
while (it.hasNext()) {
EntityLiving entity = it.next();
if (entity != null && entity.isEntityAlive()) {
entity.addPotionEffect(new CustomPotionEffect(PoisonFrostBite.INSTANCE.getId(), 60 * 20, 1, null));
entity.addPotionEffect(new PotionEffect(Potion.confusion.id, 10 * 20, 2));
entity.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 120 * 20, 2));
entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 120 * 20, 4));
}
}
}
for (Pos targetPosition : this.thread.results) {
double distanceFromCenter = position.distance(targetPosition);
if (distanceFromCenter > this.getRadius()) {
continue;
}
/*
* Reduce the chance of setting blocks on fire based on distance from center.
*/
double chance = this.getRadius() - (Math.random() * distanceFromCenter);
if (chance > distanceFromCenter * 0.55) {
/*
* Place down ice blocks.
*/
Block blockID = this.world().getBlock(targetPosition.xi(), targetPosition.yi(), targetPosition.zi());
if (blockID.blockMaterial == Material.water) {
this.world().setBlock(targetPosition.xi(), targetPosition.yi(), targetPosition.zi(), Blocks.ice, 0, 3);
} else if (blockID == Blocks.fire || blockID == Blocks.flowing_lava || blockID == Blocks.lava) {
this.world().setBlock(targetPosition.xi(), targetPosition.yi(), targetPosition.zi(), Blocks.snow, 0, 3);
} else {
Block blockBellow = world().getBlock(targetPosition.xi(), targetPosition.yi() - 1, targetPosition.zi());
if ((blockID.isReplaceable(world(), targetPosition.xi(), targetPosition.yi(), targetPosition.zi())) && blockBellow.getMaterial().isSolid() && blockBellow.isSideSolid(world(), targetPosition.xi(), targetPosition.yi() - 1, targetPosition.zi(), ForgeDirection.UP)) {
if (MathUtility.rand.nextBoolean()) {
this.world().setBlock(targetPosition.xi(), targetPosition.yi(), targetPosition.zi(), Blocks.ice, 0, 3);
} else {
this.world().setBlock(targetPosition.xi(), targetPosition.yi(), targetPosition.zi(), Blocks.snow, 0, 3);
}
}
}
}
}
this.world().playSoundEffect(position.x() + 0.5D, position.y() + 0.5D, position.z() + 0.5D, ICBMClassic.PREFIX + "redmatter", 6.0F, (1.0F + (world().rand.nextFloat() - world().rand.nextFloat()) * 0.2F) * 1F);
}
if (!world().getGameRules().getGameRuleBooleanValue("doDaylightCycle")) {
this.world().setWorldTime(1200);
}
}
}
use of com.builtbroken.mc.imp.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class EntityGrenade method onUpdate.
/** Called to update the entity's position/logic. */
@Override
public void onUpdate() {
if (!this.worldObj.isRemote) {
ExplosionEvent.ExplosivePreDetonationEvent evt = new ExplosionEvent.ExplosivePreDetonationEvent(this.worldObj, this, ExplosiveType.ITEM, this.haoMa.handler);
MinecraftForge.EVENT_BUS.post(evt);
if (evt.isCanceled()) {
float var6 = 0.7F;
double var7 = this.worldObj.rand.nextFloat() * var6 + (1.0F - var6) * 0.5D;
double var9 = this.worldObj.rand.nextFloat() * var6 + (1.0F - var6) * 0.5D;
double var11 = this.worldObj.rand.nextFloat() * var6 + (1.0F - var6) * 0.5D;
EntityItem var13 = new EntityItem(this.worldObj, this.posX + var7, this.posY + var9, this.posZ + var11, new ItemStack(ICBMClassic.itemGrenade, 1, this.haoMa.ordinal()));
var13.delayBeforeCanPickup = 10;
this.worldObj.spawnEntityInWorld(var13);
this.setDead();
return;
}
}
this.lastTickPosX = this.posX;
this.lastTickPosY = this.posY;
this.lastTickPosZ = this.posZ;
super.onUpdate();
this.moveEntity(this.motionX, this.motionY, this.motionZ);
float var16 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
for (this.rotationPitch = (float) (Math.atan2(this.motionY, var16) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) {
;
}
while (this.rotationPitch - this.prevRotationPitch >= 180.0F) {
this.prevRotationPitch += 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw < -180.0F) {
this.prevRotationYaw -= 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw >= 180.0F) {
this.prevRotationYaw += 360.0F;
}
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
float var17 = 0.98F;
float gravity = 0.03F;
if (this.isInWater()) {
for (int var7 = 0; var7 < 4; ++var7) {
float var19 = 0.25F;
this.worldObj.spawnParticle("bubble", this.posX - this.motionX * var19, this.posY - this.motionY * var19, this.posZ - this.motionZ * var19, this.motionX, this.motionY, this.motionZ);
}
var17 = 0.8F;
}
this.motionX *= var17;
this.motionY *= var17;
this.motionZ *= var17;
if (this.onGround) {
this.motionX *= 0.5;
this.motionZ *= 0.5;
this.motionY *= 0.5;
} else {
this.motionY -= gravity;
//this.pushOutOfBlocks(this.posX, (this.boundingBox.minY + this.boundingBox.maxY) / 2.0D, this.posZ);
}
if (this.ticksExisted > Math.max(60, (haoMa.handler.getYinXin()))) {
this.worldObj.spawnParticle("hugeexplosion", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
(haoMa.handler).createExplosion(this.worldObj, this.posX, this.posY + 0.3f, this.posZ, this);
this.setDead();
return;
} else {
(haoMa.handler).onYinZha(this.worldObj, new Pos(this.posX, this.posY + 0.5, this.posZ), this.ticksExisted);
}
}
use of com.builtbroken.mc.imp.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class EntityMissile method readEntityFromNBT.
/** (abstract) Protected helper method to read subclass entity additionalMissileData from NBT. */
@Override
public void readEntityFromNBT(NBTTagCompound nbt) {
super.readEntityFromNBT(nbt);
this.targetVector = new Pos(nbt.getCompoundTag("target"));
this.launcherPos = new Pos(nbt.getCompoundTag("faSheQi"));
this.acceleration = nbt.getFloat("acceleration");
this.targetHeight = nbt.getInteger("targetHeight");
this.explosiveID = Explosives.get(nbt.getInteger("explosiveID"));
this.ticksInAir = nbt.getInteger("ticksInAir");
this.lockHeight = nbt.getDouble("lockHeight");
this.missileType = MissileType.values()[nbt.getInteger("missileType")];
this.nbtData = nbt.getCompoundTag("additionalMissileData");
}
use of com.builtbroken.mc.imp.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class EntityMissile method spawnMissileSmoke.
private void spawnMissileSmoke() {
if (this.worldObj.isRemote) {
Pos position = new Pos((IPos3D) this);
// The distance of the smoke relative
// to the missile.
double distance = -this.daoDanGaoDu - 0.2f;
// The delta Y of the smoke.
double y = Math.sin(Math.toRadians(this.rotationPitch)) * distance;
// The horizontal distance of the
// smoke.
double dH = Math.cos(Math.toRadians(this.rotationPitch)) * distance;
// The delta X and Z.
double x = Math.sin(Math.toRadians(this.rotationYaw)) * dH;
double z = Math.cos(Math.toRadians(this.rotationYaw)) * dH;
position = position.add(x, y, z);
this.worldObj.spawnParticle("flame", position.x(), position.y(), position.z(), 0, 0, 0);
ICBMClassic.proxy.spawnParticle("missile_smoke", this.worldObj, position, 4, 2);
position = position.multiply(1 - 0.001 * Math.random());
ICBMClassic.proxy.spawnParticle("missile_smoke", this.worldObj, position, 4, 2);
position = position.multiply(1 - 0.001 * Math.random());
ICBMClassic.proxy.spawnParticle("missile_smoke", this.worldObj, position, 4, 2);
position = position.multiply(1 - 0.001 * Math.random());
ICBMClassic.proxy.spawnParticle("missile_smoke", this.worldObj, position, 4, 2);
}
}
use of com.builtbroken.mc.imp.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class BlastRepulsive method pushEntities.
public void pushEntities(float radius, float force, int type) {
// Step 2: Damage all entities
Pos minCoord = position.toPos();
minCoord = minCoord.add(-radius - 1);
Pos maxCoord = position.toPos();
maxCoord = maxCoord.add(radius + 1);
Cube region = new Cube(minCoord, maxCoord);
List<Entity> entities = region.getEntities(this.world(), Entity.class);
for (Entity entity : entities) {
double var13 = entity.getDistance(position.x(), position.y(), position.z()) / radius;
if (var13 <= 1.0D) {
double xDifference = entity.posX - position.x();
double yDifference = entity.posY - position.y();
double zDifference = entity.posZ - position.z();
double distance = MathHelper.sqrt_double(xDifference * xDifference + yDifference * yDifference + zDifference * zDifference);
xDifference /= distance;
yDifference /= distance;
zDifference /= distance;
if (type == 1) {
double modifier = var13 * force * (entity instanceof EntityPlayer ? 0.5 : 1);
entity.addVelocity(-xDifference * modifier, -yDifference * modifier, -zDifference * modifier);
} else if (type == 2) {
double modifier = (1.0D - var13) * force * (entity instanceof EntityPlayer ? 0.5 : 1);
entity.addVelocity(xDifference * modifier, yDifference * modifier, zDifference * modifier);
}
}
}
}
Aggregations