use of icbm.classic.lib.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class Cube method expand.
public Cube expand(int range) {
Pos start = min().sub(range);
Pos end = max().add(range);
set(start, end);
return this;
}
use of icbm.classic.lib.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class EntityProjectile method readEntityFromNBT.
@Override
public void readEntityFromNBT(NBTTagCompound nbt) {
if (nbt.hasKey(NBTConstants.X_TILE)) {
// Legacy
tilePos = new BlockPos(nbt.getShort(NBTConstants.X_TILE), nbt.getShort(NBTConstants.Y_TILE), nbt.getShort(NBTConstants.Z_TILE));
} else if (nbt.hasKey(NBTConstants.X_TILE_POS)) {
tilePos = new BlockPos(nbt.getInteger(NBTConstants.X_TILE_POS), nbt.getInteger(NBTConstants.Y_TILE_POS), nbt.getInteger(NBTConstants.Z_TILE_POS));
}
if (nbt.hasKey(NBTConstants.SIDE_TILE)) {
// Legacy
this.sideTile = EnumFacing.byIndex(nbt.getShort(NBTConstants.SIDE_TILE));
} else {
this.sideTile = EnumFacing.byIndex(nbt.getByte(NBTConstants.SIDE_TILE_POS));
}
this.ticksInGround = nbt.getShort(NBTConstants.LIFE);
if (nbt.hasKey(NBTConstants.IN_TILE)) {
// Legacy
Block block = Block.getBlockById(nbt.getByte(NBTConstants.IN_TILE));
if (block != null) {
int meta = nbt.getByte(NBTConstants.IN_DATA);
this.blockInside = block.getStateFromMeta(meta);
}
} else if (nbt.hasKey(NBTConstants.IN_TILE_STATE)) {
this.blockInside = Block.getStateById(nbt.getInteger(NBTConstants.IN_TILE_STATE));
}
this.inGround = nbt.getByte(NBTConstants.IN_GROUND) == 1;
if (nbt.hasKey(NBTConstants.SOURCE_POS)) {
sourceOfProjectile = new Pos(nbt.getCompoundTag(NBTConstants.SOURCE_POS));
}
if (nbt.hasKey(NBTConstants.SHOOTER_UUID)) {
shootingEntityUUID = UUID.fromString(nbt.getString(NBTConstants.SHOOTER_UUID));
}
}
use of icbm.classic.lib.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class ExplosiveHandler method removeNear.
/**
* Called to remove blasts near the location
*
* @param world = position
* @param x - position
* @param y - position
* @param z - position
* @param range - distance from position, less than zero will turn into global
* @return number of blasts removed
*/
public static int removeNear(World world, double x, double y, double z, double range) {
final Pos pos = new Pos(x, y, z);
// Collect blasts marked for removal
final List<IBlast> toRemove = ExplosiveHandler.activeBlasts.stream().filter(blast -> blast.world() == world).filter(blast -> range < 0 || range > 0 && range > pos.distance(blast)).collect(Collectors.toList());
// Do removals
activeBlasts.removeAll(toRemove);
toRemove.forEach(IBlast::clearBlast);
return toRemove.size();
}
use of icbm.classic.lib.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class PosDistanceSorter method compare.
@Override
public int compare(BlockPos o1, BlockPos o2) {
if (!sortY || o1.getY() == o2.getY()) {
double d = new Pos(o1).distance(center);
double d2 = new Pos(o2).distance(center);
return d > d2 ? 1 : d == d2 ? 0 : -1;
}
return Integer.compare(o1.getY(), o2.getY());
}
use of icbm.classic.lib.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class EntityMissile method launch.
/**
* Used {@link #capabilityMissile} {@link CapabilityMissile#launch(double, double, double, double)}
*
* @param target
*/
protected void launch(Pos target) {
// Start motion
if (ticksInAir <= 0) {
this.ticksInAir = 2;
}
// Update data
// TODO get source of launch
this.sourceOfProjectile = new Pos((IPos3D) this);
this.targetPos = target;
this.targetHeight = this.targetPos != null ? this.targetPos.yi() : -1;
// Trigger events
// TODO add generic event
ICBMClassicAPI.EX_MISSILE_REGISTRY.triggerLaunch(capabilityMissile);
// Trigger code
this.recalculatePath();
this.updateMotion();
// Play audio
ICBMSounds.MISSILE_LAUNCH.play(world, posX, posY, posZ, 1F, (1.0F + CalculationHelpers.randFloatRange(this.world.rand, 0.2F)) * 0.7F, true);
// Trigger events
// TODO add an event system here
RadarRegistry.add(this);
if (ConfigDebug.DEBUG_MISSILE_LAUNCHES) {
if (target != null) {
ICBMClassic.logger().info("Launching " + this.getEntityName() + " (" + this.getEntityId() + ") from " + sourceOfProjectile.xi() + ", " + sourceOfProjectile.yi() + ", " + sourceOfProjectile.zi() + " to " + targetPos.xi() + ", " + targetPos.yi() + ", " + targetPos.zi());
} else {
ICBMClassic.logger().info("Launching " + this.getEntityName() + " (" + this.getEntityId() + ") from " + sourceOfProjectile.xi() + ", " + sourceOfProjectile.yi() + ", " + sourceOfProjectile.zi());
}
}
}
Aggregations