use of net.minecraft.util.AxisAlignedBB in project ICBM-Classic by BuiltBrokenModding.
the class BlastRedmatter method doEntityMovement.
protected void doEntityMovement() {
float entityRadius = this.getRadius() * 2;
Cube cube = new Cube(position.add(0.5).sub(entityRadius), position.add(0.5).add(entityRadius));
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(cube.min().x(), cube.min().y(), cube.min().z(), cube.max().x(), cube.max().y(), cube.max().z());
List<Entity> allEntities = this.world().getEntitiesWithinAABB(Entity.class, bounds);
boolean doExplosion = true;
for (Entity entity : allEntities) {
doExplosion = !this.affectEntity(entityRadius, entity, doExplosion);
}
}
use of net.minecraft.util.AxisAlignedBB in project ICBM-Classic by BuiltBrokenModding.
the class BlastSonic method doExplode.
@Override
public void doExplode() {
int r = this.callCount;
if (!this.world().isRemote) {
if (this.thread != null && this.thread.isComplete) {
Iterator<Pos> it = this.thread.results.iterator();
while (it.hasNext()) {
Pos targetPosition = it.next();
double distance = targetPosition.distance(position);
if (distance > r || distance < r - 3) {
continue;
}
Block blockID = this.world().getBlock(targetPosition.xi(), targetPosition.yi(), targetPosition.zi());
if (blockID == Blocks.air || blockID.blockHardness < 0) {
continue;
}
//if (block instanceof IForceFieldBlock)
//{
// continue;
//}
int metadata = this.world().getBlockMetadata(targetPosition.xi(), targetPosition.yi(), targetPosition.zi());
if (distance < r - 1 || this.world().rand.nextInt(3) > 0) {
if (blockID == ICBMClassic.blockExplosive) {
BlockExplosive.triggerExplosive(this.world(), targetPosition.xi(), targetPosition.yi(), targetPosition.zi(), ((TileEntityExplosive) this.world().getTileEntity(targetPosition.xi(), targetPosition.yi(), targetPosition.zi())).explosive, 1);
} else {
this.world().setBlockToAir(targetPosition.xi(), targetPosition.yi(), targetPosition.zi());
}
targetPosition = targetPosition.add(0.5D);
if (this.world().rand.nextFloat() < 0.3 * (this.getRadius() - r)) {
EntityFlyingBlock entity = new EntityFlyingBlock(this.world(), targetPosition, blockID, metadata);
this.world().spawnEntityInWorld(entity);
entity.yawChange = 50 * this.world().rand.nextFloat();
entity.pitchChange = 100 * this.world().rand.nextFloat();
}
it.remove();
}
}
}
}
int radius = 2 * this.callCount;
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(position.x() - radius, position.y() - radius, position.z() - radius, position.x() + radius, position.y() + radius, position.z() + radius);
List<Entity> allEntities = this.world().getEntitiesWithinAABB(Entity.class, bounds);
synchronized (allEntities) {
for (Iterator it = allEntities.iterator(); it.hasNext(); ) {
Entity entity = (Entity) it.next();
if (entity instanceof EntityMissile) {
((EntityMissile) entity).setExplode();
break;
} else {
double xDifference = entity.posX - position.x();
double zDifference = entity.posZ - position.z();
r = (int) this.getRadius();
if (xDifference < 0) {
r = (int) -this.getRadius();
}
entity.motionX += (r - xDifference) * 0.02 * this.world().rand.nextFloat();
entity.motionY += 3 * this.world().rand.nextFloat();
r = (int) this.getRadius();
if (zDifference < 0) {
r = (int) -this.getRadius();
}
entity.motionZ += (r - zDifference) * 0.02 * this.world().rand.nextFloat();
}
}
}
if (this.callCount > this.getRadius()) {
this.controller.endExplosion();
}
}
use of net.minecraft.util.AxisAlignedBB in project ICBM-Classic by BuiltBrokenModding.
the class BlastMutation method doExplode.
@Override
public void doExplode() {
if (!this.world().isRemote) {
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(position.x() - this.getRadius(), position.y() - this.getRadius(), position.z() - this.getRadius(), position.x() + this.getRadius(), position.y() + this.getRadius(), position.z() + this.getRadius());
List<EntityLiving> entitiesNearby = world().getEntitiesWithinAABB(EntityLiving.class, bounds);
for (EntityLiving entity : entitiesNearby) {
if (entity instanceof EntityPig) {
EntityPigZombie newEntity = new EntityPigZombie(world());
newEntity.preventEntitySpawning = true;
newEntity.setPosition(entity.posX, entity.posY, entity.posZ);
entity.setDead();
} else if (entity instanceof EntityVillager) {
EntityZombie newEntity = new EntityZombie(world());
newEntity.preventEntitySpawning = true;
newEntity.setPosition(entity.posX, entity.posY, entity.posZ);
entity.setDead();
}
}
}
}
use of net.minecraft.util.AxisAlignedBB in project ICBM-Classic by BuiltBrokenModding.
the class BlastEnderman method doExplode.
@Override
public void doExplode() {
if (this.world().isRemote) {
int r = (int) (this.getRadius() - ((double) this.callCount / (double) this.duration) * this.getRadius());
for (int x = -r; x < r; x++) {
for (int z = -r; z < r; z++) {
for (int y = -r; y < r; y++) {
Location targetPosition = position.add(new Pos(x, y, z));
double distance = targetPosition.distance(position);
if (distance < r && distance > r - 1) {
if (targetPosition.getBlock(world()) != Blocks.air)
continue;
if (this.world().rand.nextFloat() < Math.max(0.001 * r, 0.01)) {
float velX = (float) ((targetPosition.x() - position.x()) * 0.6);
float velY = (float) ((targetPosition.y() - position.y()) * 0.6);
float velZ = (float) ((targetPosition.z() - position.z()) * 0.6);
ICBMClassic.proxy.spawnParticle("portal", world(), targetPosition, velX, velY, velZ, 5f, 1);
}
}
}
}
}
}
int radius = (int) this.getRadius();
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(position.x() - radius, position.y() - radius, position.z() - radius, position.x() + radius, position.y() + radius, position.z() + radius);
List<Entity> allEntities = world().getEntitiesWithinAABB(Entity.class, bounds);
boolean explosionCreated = false;
for (Entity entity : allEntities) {
if (entity != this.controller) {
double xDifference = entity.posX - position.x();
double yDifference = entity.posY - position.y();
double zDifference = entity.posZ - position.z();
int r = (int) this.getRadius();
if (xDifference < 0)
r = (int) -this.getRadius();
entity.motionX -= (r - xDifference) * Math.abs(xDifference) * 0.0006;
r = (int) this.getRadius();
if (entity.posY > position.y())
r = (int) -this.getRadius();
entity.motionY += (r - yDifference) * Math.abs(yDifference) * 0.0011;
r = (int) this.getRadius();
if (zDifference < 0)
r = (int) -this.getRadius();
entity.motionZ -= (r - zDifference) * Math.abs(zDifference) * 0.0006;
if (new Pos(entity.posX, entity.posY, entity.posZ).distance(position) < 4) {
if (!explosionCreated && callCount % 5 == 0) {
world().spawnParticle("hugeexplosion", entity.posX, entity.posY, entity.posZ, 0.0D, 0.0D, 0.0D);
explosionCreated = true;
}
try {
/** If a target doesn't exist, search for a random one within 100 block
* range. */
if (this.teleportTarget == null) {
int checkY;
int checkX = this.world().rand.nextInt(300) - 150 + (int) this.controller.posX;
int checkZ = this.world().rand.nextInt(300) - 150 + (int) this.controller.posZ;
for (checkY = 63; !this.world().isAirBlock(checkX, checkY, checkZ) && !this.world().isAirBlock(checkX, checkY + 1, checkZ); ++checkY) {
;
}
this.teleportTarget = new Pos(checkX, checkY, checkZ);
}
this.world().playSoundAtEntity(entity, "mob.endermen.portal", 1.0F, 1.0F);
if (entity instanceof EntityPlayerMP) {
((EntityPlayerMP) entity).playerNetServerHandler.setPlayerLocation(this.teleportTarget.x() + 0.5, this.teleportTarget.y() + 0.5, this.teleportTarget.z() + 0.5, entity.rotationYaw, entity.rotationPitch);
} else {
entity.setPosition(this.teleportTarget.x() + 0.5, this.teleportTarget.y() + 0.5, this.teleportTarget.z() + 0.5);
}
} catch (Exception e) {
ICBMClassic.INSTANCE.logger().error("Failed to teleport entity to the End.", e);
}
}
}
}
this.world().playSound(this.position.x(), this.position.y(), this.position.z(), "portal.portal", 2F, world().rand.nextFloat() * 0.4F + 0.8F, false);
if (this.callCount > this.duration) {
this.controller.endExplosion();
}
}
use of net.minecraft.util.AxisAlignedBB in project ICBM-Classic by BuiltBrokenModding.
the class MissileAnti method update.
@Override
public void update(EntityMissile missileObj) {
if (missileObj.lockedTarget != null) {
Pos target = new Pos(missileObj.lockedTarget);
if (missileObj.lockedTarget.isDead) {
missileObj.explode();
return;
}
if (missileObj.lockedTarget instanceof EntityMissile) {
target = ((EntityMissile) missileObj.lockedTarget).getPredictedPosition(4);
}
missileObj.motionX = (target.x() - missileObj.posX) * (0.3F);
missileObj.motionY = (target.y() - missileObj.posY) * (0.3F);
missileObj.motionZ = (target.z() - missileObj.posZ) * (0.3F);
return;
}
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(missileObj.posX - ABMRange, missileObj.posY - ABMRange, missileObj.posZ - ABMRange, missileObj.posX + ABMRange, missileObj.posY + ABMRange, missileObj.posZ + ABMRange);
// TODO: Check if this works.
Entity nearestEntity = missileObj.worldObj.findNearestEntityWithinAABB(EntityMissile.class, bounds, missileObj);
if (nearestEntity instanceof EntityMissile) {
// Lock target onto missileObj missile
missileObj.lockedTarget = nearestEntity;
missileObj.didTargetLockBefore = true;
missileObj.worldObj.playSoundAtEntity(missileObj, ICBMClassic.PREFIX + "targetlocked", 5F, 0.9F);
} else {
missileObj.motionX = missileObj.deltaPathX / missileObj.missileFlightTime;
missileObj.motionZ = missileObj.deltaPathZ / missileObj.missileFlightTime;
if (missileObj.didTargetLockBefore == true) {
missileObj.explode();
}
}
}
Aggregations