use of icbm.classic.lib.transform.vector.Location in project ICBM-Classic by BuiltBrokenModding.
the class ExplosiveInit method enderMissileCoordSet.
private static boolean enderMissileCoordSet(Entity entity, EntityPlayer player, EnumHand hand) {
if (entity.hasCapability(ICBMClassicAPI.EXPLOSIVE_CAPABILITY, null)) {
final IExplosive provider = entity.getCapability(ICBMClassicAPI.EXPLOSIVE_CAPABILITY, null);
final NBTTagCompound tag = provider.getCustomBlastData();
if (tag != null) {
final ItemStack heldItem = player.getHeldItem(hand);
if (heldItem.getItem() instanceof IWorldPosItem) {
final IWorldPosItem posItem = ((IWorldPosItem) heldItem.getItem());
final IWorldPosition link = posItem.getLocation(heldItem);
if (link instanceof Location) {
((Location) link).writeIntNBT(tag);
if (!entity.world.isRemote) {
// TODO translate
player.sendMessage(new TextComponentString("Coordinates encoded into entity"));
}
return true;
}
}
}
}
return false;
}
use of icbm.classic.lib.transform.vector.Location in project ICBM-Classic by BuiltBrokenModding.
the class BlastEnderman method doExplode.
@Override
public boolean doExplode(int callCount) {
if (this.world().isRemote) {
int r = (int) (this.getBlastRadius() - ((double) this.callCount / (double) this.duration) * this.getBlastRadius());
for (int x = -r; x < r; x++) {
for (int z = -r; z < r; z++) {
for (int y = -r; y < r; y++) {
// TODO replace with mutable blockpos
Location targetPosition = location.add(new Pos(x, y, z));
double distance = targetPosition.distance(location);
if (distance < r && distance > r - 1) {
if (!targetPosition.getBlock(world()).isAir(targetPosition.getBlockState(world()), world(), targetPosition.toBlockPos())) {
continue;
}
if (this.world().rand.nextFloat() < Math.max(0.001 * r, 0.01)) {
float velX = (float) ((targetPosition.x() - location.x()) * 0.6);
float velY = (float) ((targetPosition.y() - location.y()) * 0.6);
float velZ = (float) ((targetPosition.z() - location.z()) * 0.6);
world.spawnParticle(EnumParticleTypes.PORTAL, targetPosition.x(), targetPosition.y(), targetPosition.z(), velX, velY, velZ);
}
}
}
}
}
}
int radius = (int) this.getBlastRadius();
AxisAlignedBB bounds = new AxisAlignedBB(location.x() - radius, location.y() - radius, location.z() - radius, location.x() + radius, location.y() + radius, location.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 - location.x();
double yDifference = entity.posY - location.y();
double zDifference = entity.posZ - location.z();
int r = (int) this.getBlastRadius();
if (xDifference < 0) {
r = (int) -this.getBlastRadius();
}
entity.motionX -= (r - xDifference) * Math.abs(xDifference) * 0.0006;
r = (int) this.getBlastRadius();
if (entity.posY > location.y()) {
r = (int) -this.getBlastRadius();
}
entity.motionY += (r - yDifference) * Math.abs(yDifference) * 0.0011;
r = (int) this.getBlastRadius();
if (zDifference < 0) {
r = (int) -this.getBlastRadius();
}
entity.motionZ -= (r - zDifference) * Math.abs(zDifference) * 0.0006;
if (new Pos(entity.posX, entity.posY, entity.posZ).distance(location) < 4) {
if (!explosionCreated && callCount % 5 == 0) {
world().spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, 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) Math.floor(this.controller.posY);
int checkX = this.world().rand.nextInt(300) - 150 + (int) this.controller.posX;
int checkZ = this.world().rand.nextInt(300) - 150 + (int) this.controller.posZ;
// Look for space with air gap
BlockPos pos;
BlockPos pos2;
do {
pos = new BlockPos(checkX, checkY, checkZ);
pos2 = pos.up();
checkY++;
} while (this.world().isAirBlock(pos) && !this.world().isAirBlock(pos2) && checkY < 254);
this.teleportTarget = new Pos(checkX, checkY, checkZ);
}
this.world().playSound(null, entity.posX, entity.posY, entity.posZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.BLOCKS, 1.0F, 1.0F);
if (entity instanceof EntityPlayerMP) {
((EntityPlayerMP) entity).connection.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.logger().error("Failed to teleport entity to the End.", e);
}
}
}
}
this.world().playSound(null, this.location.x(), this.location.y(), this.location.z(), SoundEvents.BLOCK_PORTAL_AMBIENT, SoundCategory.BLOCKS, 2F, world().rand.nextFloat() * 0.4F + 0.8F);
return this.callCount > this.duration;
}
use of icbm.classic.lib.transform.vector.Location in project ICBM-Classic by BuiltBrokenModding.
the class BlastNuclear method setupBlast.
@Override
public boolean setupBlast() {
super.setupBlast();
if (this.world() != null) {
if (this.spawnMoreParticles) {
// Spawn nuclear cloud.
for (int y = 0; y < 26; y++) {
int r = 4;
if (y < 8) {
r = Math.max(Math.min((8 - y) * 2, 10), 4);
} else if (y > 15) {
r = Math.max(Math.min((y - 15) * 2, 15), 5);
}
for (int x = -r; x < r; x++) {
for (int z = -r; z < r; z++) {
double distance = MathHelper.sqrt(x * x + z * z);
if (r > distance && r - 3 < distance) {
Location spawnPosition = location.add(new Pos(x * 2, (y - 2) * 2, z * 2));
float xDiff = (float) (spawnPosition.x() - location.x());
float zDiff = (float) (spawnPosition.z() - location.z());
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, spawnPosition.x(), spawnPosition.y(), spawnPosition.z(), xDiff * 0.3 * world().rand.nextFloat(), -world().rand.nextFloat(), // (float) (distance / this.getRadius()) * oldWorld().rand.nextFloat(), 0, //0, 8F, 1.2F);
zDiff * 0.3 * world().rand.nextFloat());
}
}
}
}
}
this.doDamageEntities(this.getBlastRadius(), this.energy * 1000);
ICBMSounds.EXPLOSION.play(world, this.location.x(), this.location.y(), this.location.z(), 7.0F, (1.0F + (this.world().rand.nextFloat() - this.world().rand.nextFloat()) * 0.2F) * 0.7F, true);
}
return true;
}
use of icbm.classic.lib.transform.vector.Location in project ICBM-Classic by BuiltBrokenModding.
the class BlastNuclear method doExplode.
@Override
public boolean doExplode(int callCount) {
super.doExplode(callCount);
int r = this.callCount;
if (this.world().isRemote) {
for (int x = -r; x < r; x++) {
for (int z = -r; z < r; z++) {
double distance = MathHelper.sqrt(x * x + z * z);
if (distance < r && distance > r - 1) {
Location targetPosition = this.location.add(new Pos(x, 0, z));
if (this.world().rand.nextFloat() < Math.max(0.001 * r, 0.05)) {
// 5F, 1F);
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, targetPosition.x(), targetPosition.y(), targetPosition.z(), 0, 0, 0);
}
}
}
}
}
return false;
}
use of icbm.classic.lib.transform.vector.Location in project ICBM-Classic by BuiltBrokenModding.
the class Blast method setPosition.
/**
* Called to set the position of the blast. Only call this for initialization, anything
* that happens during world tick should call {@link #onPositionUpdate(double, double, double)}
*
* @param posX
* @param posY
* @param posZ
*/
public Blast setPosition(double posX, double posY, double posZ) {
this.x = posX;
this.y = posY;
this.z = posZ;
location = new Location(world, posX, posY, posZ);
// TODO super contains a vec3 also called position, we need to set that value instead of overriding the return
return this;
}
Aggregations