use of com.builtbroken.mc.imp.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class BlastNuclear method doPreExplode.
@Override
public void doPreExplode() {
if (!this.world().isRemote) {
this.thread = new ThreadLargeExplosion(this.position, (int) this.getRadius(), this.energy, this.exploder);
this.thread.start();
} else if (this.spawnMoreParticles && ICBMClassic.proxy.isGaoQing()) {
// 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_double(x * x + z * z);
if (r > distance && r - 3 < distance) {
Location spawnPosition = position.add(new Pos(x * 2, (y - 2) * 2, z * 2));
float xDiff = (float) (spawnPosition.x() - position.x());
float zDiff = (float) (spawnPosition.z() - position.z());
ICBMClassic.proxy.spawnParticle("smoke", world(), spawnPosition, xDiff * 0.3 * world().rand.nextFloat(), -world().rand.nextFloat(), zDiff * 0.3 * world().rand.nextFloat(), (float) (distance / this.getRadius()) * world().rand.nextFloat(), 0, 0, 8F, 1.2F);
}
}
}
}
}
this.doDamageEntities(this.getRadius(), this.energy * 1000);
this.world().playSoundEffect(this.position.x(), this.position.y(), this.position.z(), ICBMClassic.PREFIX + "explosion", 7.0F, (1.0F + (this.world().rand.nextFloat() - this.world().rand.nextFloat()) * 0.2F) * 0.7F);
}
use of com.builtbroken.mc.imp.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class TileCruiseLauncherClient method readDescPacket.
@Override
public void readDescPacket(ByteBuf buf) {
super.readDescPacket(buf);
if (buf.readBoolean()) {
cachedMissileStack = ByteBufUtils.readItemStack(buf);
} else {
cachedMissileStack = null;
}
setTarget(new Pos(buf.readInt(), buf.readInt(), buf.readInt()));
}
use of com.builtbroken.mc.imp.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class TileLauncherBase method launchMissile.
/**
* Launches the missile
*
* @param target - The target in which the missile will land in
*/
public boolean launchMissile(Pos target, int gaoDu) {
final ItemStack stack = getMissileStack();
if (stack != null && stack.getItem() == ICBMClassic.itemMissile) {
Explosive ex = Explosives.get(stack.getItemDamage()).handler;
if (ex.hasMissileForm()) {
// Apply inaccuracy
int inaccuracy = 30;
//Get value from support frame
if (this.supportFrame != null) {
inaccuracy = this.supportFrame.getInaccuracy();
}
//Randomize distance
inaccuracy = world().rand.nextInt(inaccuracy);
//Randomize radius drop
angle.setYaw(world().rand.nextFloat() * 360);
//Update target
target = target.add(angle.x() * inaccuracy, 0, angle.z() * inaccuracy);
if (isServer()) {
EntityMissile missile = new EntityMissile(world());
missile.explosiveID = Explosives.get(stack.getItemDamage());
missile.launcherPos = new Pos((TileEntity) this);
missile.setPosition(xi(), yi() + 3, zi());
missile.launch(target, gaoDu);
world().spawnEntityInWorld(missile);
this.decrStackSize(0, 1);
}
return true;
}
}
return false;
}
use of com.builtbroken.mc.imp.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class TileLauncherBase method update.
/**
* Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner
* uses this to count ticks and creates a new spawn inside its implementation.
*/
@Override
public void update() {
super.update();
if (ticks % 20 == 0) {
if (this.supportFrame == null || launchScreen == null || launchScreen.isInvalid() || this.supportFrame.isInvalid()) {
this.supportFrame = null;
this.launchScreen = null;
for (byte i = 2; i < 6; i++) {
Pos position = new Pos(this.xCoord, this.yCoord, this.zCoord).add(ForgeDirection.getOrientation(i));
TileEntity tileEntity = this.worldObj.getTileEntity(position.xi(), position.yi(), position.zi());
if (tileEntity instanceof TileLauncherFrame) {
this.supportFrame = (TileLauncherFrame) tileEntity;
if (isServer()) {
this.supportFrame.setFacing(getDirection());
}
} else if (tileEntity instanceof TileLauncherScreen) {
this.launchScreen = (TileLauncherScreen) tileEntity;
}
}
}
}
}
use of com.builtbroken.mc.imp.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class TileCruiseLauncher method update.
@Override
public void update() {
super.update();
// time / time_tick, client uses different value
deltaTime = (System.nanoTime() - lastRotationUpdate) / 100000000.0;
lastRotationUpdate = System.nanoTime();
if (getTarget() != null && !getTarget().isZero()) {
Pos aimPoint = getTarget();
Pos center = toPos().add(0.5);
if (Engine.runningAsDev) {
sendPacket(new PacketSpawnParticleStream(world().provider.dimensionId, center, aimPoint));
}
aim.set(center.toEulerAngle(aimPoint).clampTo360());
currentAim.moveTowards(aim, ROTATION_SPEED, deltaTime).clampTo360();
if (!this.worldObj.isRemote) {
if (this.ticks % 40 == 0 && this.worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) {
this.launch();
}
}
}
}
Aggregations