下面列出了org.bukkit.util.Vector#multiply ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void onRun() {
Location location = getLocation();
float radius = 3 * innerRadius / MathUtils.SQRT_3;
for (int i = 0; i < spikesHalf * 2; i++) {
double xRotation = i * Math.PI / spikesHalf;
for (int x = 0; x < particles; x++) {
double angle = 2 * Math.PI * x / particles;
float height = RandomUtils.random.nextFloat() * spikeHeight;
Vector v = new Vector(Math.cos(angle), 0, Math.sin(angle));
v.multiply((spikeHeight - height) * radius / spikeHeight);
v.setY(innerRadius + height);
VectorUtils.rotateAroundAxisX(v, xRotation);
location.add(v);
display(particle, location);
location.subtract(v);
VectorUtils.rotateAroundAxisX(v, Math.PI);
VectorUtils.rotateAroundAxisY(v, Math.PI / 2);
location.add(v);
display(particle, location);
location.subtract(v);
}
}
}
public static void entityPush(Entity entity, Location to, double velocity) {
Location from = entity.getLocation();
Vector test = to.clone().subtract(from).toVector();
double elevation = test.getY();
Double launchAngle = calculateLaunchAngle(from, to, velocity, elevation, 20.0D);
double distance = Math.sqrt(Math.pow(test.getX(), 2.0D) + Math.pow(test.getZ(), 2.0D));
if (distance != 0.0D) {
if (launchAngle == null) {
launchAngle = Math.atan((40.0D * elevation + Math.pow(velocity, 2.0D)) / (40.0D * elevation + 2.0D * Math.pow(velocity, 2.0D)));
}
double hangTime = calculateHangTime(launchAngle, velocity, elevation, 20.0D);
test.setY(Math.tan(launchAngle) * distance);
test = normalizeVector(test);
Vector noise = Vector.getRandom();
noise = noise.multiply(0.1D);
test.add(noise);
velocity = velocity + 1.188D * Math.pow(hangTime, 2.0D) + (Numbers.getRandom().nextDouble() - 0.8D) / 2.0D;
test = test.multiply(velocity / 20.0D);
entity.setVelocity(test);
}
}
public Location getHistoryLocation(int rewindMillisecs, Entity entity) {
List<Pair<Location, Long>> times = trackedEntities.get(entity);
if (times == null || times.size() == 0) {
return entity.getLocation();
}
long currentTime = System.currentTimeMillis();
int rewindTime = rewindMillisecs + pingOffset; //player a + avg processing time.
for (int i = times.size() - 1; i >= 0; i--) { //loop backwards
int elapsedTime = (int) (currentTime - times.get(i).getValue());
if (elapsedTime >= rewindTime) {
if (i == times.size() - 1) {
return times.get(i).getKey();
}
double nextMoveWeight = (elapsedTime - rewindTime) / (double) (elapsedTime - (currentTime - times.get(i + 1).getValue()));
Location before = times.get(i).getKey().clone();
Location after = times.get(i + 1).getKey();
Vector interpolate = after.toVector().subtract(before.toVector());
interpolate.multiply(nextMoveWeight);
before.add(interpolate);
return before;
}
}
return times.get(0).getKey().clone(); //ran out of historical data; return oldest entry
}
/**
* Checks whether or not the line between the two points is obstructed
*
* @param loc1 first location
* @param loc2 second location
* @return the location of obstruction or null if not obstructed
*/
public boolean isObstructed(Location loc1, Location loc2) {
if (loc1.getX() == loc2.getX() && loc1.getY() == loc2.getY() && loc1.getZ() == loc2.getZ()) {
return false;
}
Vector slope = loc2.clone().subtract(loc1).toVector();
int steps = (int) (slope.length() * 4) + 1;
slope.multiply(1.0 / steps);
Location temp = loc1.clone();
for (int i = 0; i < steps; i++) {
temp.add(slope);
if (temp.getBlock().getType().isSolid() && !temp.getBlock().getType().toString().contains("FENCE") && !temp.getBlock().getType().toString().contains("GLASS")) {
return true;
}
}
return false;
}
private void rotateItem(Object itemObject, Vector vector, EliteMobEntity eliteMobEntity) {
Item item = (Item) itemObject;
if (!item.isValid())
return;
Location currentLocation = item.getLocation().clone();
Location newLocation = eliteMobEntity.getLivingEntity().getLocation().clone().add(new Vector(0, 1, 0)).add(vector);
// if (currentLocation.distanceSquared(newLocation) > Math.pow(3, 2)) {
// item.teleport(newLocation);
// item.setVelocity(new Vector(0.01, 0.01, 0.01));
// return;
// }
Vector movementVector = (newLocation.subtract(currentLocation)).toVector();
movementVector = movementVector.multiply(0.3);
// if (Math.abs(movementVector.getX()) > 3 || Math.abs(movementVector.getY()) > 3 || Math.abs(movementVector.getZ()) > 3) {
// item.teleport(newLocation);
// } else {
item.setVelocity(movementVector);
// }
}
@EventHandler
public void onPlayerToggleFly(PlayerToggleFlightEvent event) {
if (!enabled) return;
Player player = event.getPlayer();
if (!players.contains(player.getUniqueId()) || player.getExp() > 1.0f || !event.isFlying()) return;
player.setAllowFlight(false);
player.setExp(0.0f);
event.setCancelled(true);
Vector normal = player.getEyeLocation().getDirection();
normal.setY(0.75 + Math.max(normal.getY() * 0.5, 0));
normal.multiply(power / 2);
event.getPlayer().setVelocity(normal);
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ZOMBIE_INFECT, 0.5f, 1.8f);
update();
}
@Override
protected void executeTask() {
if (p.getInventory().getChestplate() == null || p.getInventory().getChestplate().getType() == Material.AIR) {
return;
}
if (jetpack.removeItemCharge(p.getInventory().getChestplate(), COST)) {
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, (float) 0.25, 1);
p.getWorld().playEffect(p.getLocation(), Effect.SMOKE, 1, 1);
p.setFallDistance(0F);
Vector vector = new Vector(0, 1, 0);
vector.multiply(jetpack.getThrust());
vector.add(p.getEyeLocation().getDirection().multiply(0.2F));
p.setVelocity(vector);
}
else {
Bukkit.getScheduler().cancelTask(id);
}
}
private Vector computeWaterFlowForce() {
Vector finalForce = new Vector();
for(Pair<Block, Vector> liquid : liquidsAndDirections) {
Material mat = liquid.getKey().getType();
if(mat == Material.STATIONARY_WATER || mat == Material.WATER) {
finalForce.add(liquid.getValue());
}
}
if(finalForce.lengthSquared() > 0 && !pp.isFlying()) {
finalForce.normalize();
finalForce.multiply(Physics.WATER_FLOW_FORCE_MULTIPLIER);
return finalForce;
}
return finalForce;
}
@Override
protected void executeTask() {
Vector vector = new Vector(0, 1, 0);
vector.multiply(-0.1);
p.setVelocity(vector);
p.setFallDistance(0F);
if (!p.isSneaking()) {
Bukkit.getScheduler().cancelTask(id);
}
}
/**
* @param e - event
* This event check throws the boat at a player when they hit it
* unless someone is in it
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onClick(VehicleDamageEvent e) {
// plugin.getLogger().info("Damage event " + e.getDamage());
// Find out what block is being clicked
Vehicle boat = e.getVehicle();
if (!(boat instanceof Boat)) {
return;
}
if (!boat.isEmpty()) {
return;
}
final World playerWorld = boat.getWorld();
if (!playerWorld.getName().equalsIgnoreCase(Settings.worldName)) {
// Not the right world
return;
}
// plugin.getLogger().info("Boat ");
// Find out who is doing the clicking
if (!(e.getAttacker() instanceof Player)) {
// If a creeper blows up the boat, tough cookies!
return;
}
Player p = (Player) e.getAttacker();
if (p == null) {
return;
}
// Try to remove the boat and throw it at the player
Location boatSpot = new Location(boat.getWorld(), boat.getLocation().getX(), boat.getLocation().getY() + 2, boat.getLocation().getZ());
Location throwTo = new Location(boat.getWorld(), p.getLocation().getX(), p.getLocation().getY() + 1, p.getLocation().getZ());
ItemStack newBoat = new ItemStack(Material.BOAT, 1);
// Find the direction the boat should move in
Vector dir = throwTo.toVector().subtract(boatSpot.toVector()).normalize();
dir = dir.multiply(0.5);
Entity newB = boat.getWorld().dropItem(boatSpot, newBoat);
newB.setVelocity(dir);
boat.remove();
e.setCancelled(true);
}
/**
* Knocks a target back from damage received (for hacked-in damage applications when required by config).
*/
public void knockback(LivingEntity entity) {
Vector relative = entity.getLocation().toVector().subtract(getLivingEntity().getLocation().toVector());
if (relative.lengthSquared() > 0) {
relative = relative.normalize();
}
relative.setY(0.75);
relative.multiply(0.5 / Math.max(1.0, entity.getVelocity().length()));
entity.setVelocity(entity.getVelocity().multiply(0.25).add(relative));
if (SentinelPlugin.debugMe) {
debug("applied knockback velocity adder of " + relative);
}
}
private void pushEntity(Player p, Entity entity) {
Vector vector = entity.getLocation().toVector().subtract(p.getLocation().toVector()).normalize();
vector.multiply(STRENGTH);
vector.setY(0.9);
entity.setVelocity(vector);
if (entity.getType() != EntityType.PLAYER || p.getWorld().getPVP()) {
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(p, entity, DamageCause.ENTITY_ATTACK, 6D);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
((LivingEntity) entity).damage(DAMAGE);
}
}
}
@EventHandler
@SuppressWarnings("unused")
public void onPlayerMove(PlayerMoveEvent e) {
if (e.getTo() == null || !plugin.getWorldManager().isSkyAssociatedWorld(e.getTo().getWorld())) {
return;
}
String islandNameAt = WorldGuardHandler.getIslandNameAt(e.getTo());
if (islandNameAt == null) {
return;
}
IslandInfo islandInfo = plugin.getIslandInfo(islandNameAt);
if (islandInfo == null || islandInfo.getBans().isEmpty()) {
return;
}
Player player = e.getPlayer();
if (!player.isOp() && !player.hasPermission("usb.mod.bypassprotection") && isBlockedFromEntry(player, islandInfo)) {
e.setCancelled(true);
Location l = e.getTo().clone();
l.subtract(islandInfo.getIslandLocation());
Vector v = new Vector(l.getX(), l.getY(), l.getZ());
v.normalize();
v.multiply(1.5); // Bounce
player.setVelocity(v);
if (islandInfo.isBanned(player)) {
plugin.notifyPlayer(player, tr("\u00a7cBanned:\u00a7e You are banned from this island."));
} else {
plugin.notifyPlayer(player, tr("\u00a7cLocked:\u00a7e That island is locked! No entry allowed."));
}
}
}
@Override
public void onRun() {
Location location = getLocation();
if (sideRatio == 0) {
calculateSideRatio();
}
Random r = RandomUtils.random;
double xRotation = rotationX, yRotation = rotationY, zRotation = rotationZ;
if (orient) {
xRotation = Math.toRadians(90 - location.getPitch()) + rotationX;
yRotation = Math.toRadians(180 - location.getYaw()) + rotationY;
}
if (enableRotation) {
xRotation += step * angularVelocityX;
yRotation += step * angularVelocityY;
zRotation += step * angularVelocityZ;
}
for (int i = 0; i < particles; i++) {
float multi = (solid) ? r.nextFloat() : 1;
Vector v = RandomUtils.getRandomCircleVector().multiply(radius);
if (r.nextFloat() <= sideRatio) {
// SIDE PARTICLE
v.multiply(multi);
v.setY((r.nextFloat() * 2 - 1) * (height / 2));
} else {
// GROUND PARTICLE
v.multiply(r.nextFloat());
if (r.nextFloat() < 0.5) {
// TOP
v.setY(multi * (height / 2));
} else {
// BOTTOM
v.setY(-multi * (height / 2));
}
}
if (enableRotation || orient) {
VectorUtils.rotateVector(v, xRotation, yRotation, zRotation);
}
display(particle, location.add(v));
location.subtract(v);
}
display(particle, location);
step++;
}
private static Vector normalizeVector(Vector victor) {
double mag = Math.sqrt(Math.pow(victor.getX(), 2.0D) + Math.pow(victor.getY(), 2.0D) + Math.pow(victor.getZ(), 2.0D));
return mag != 0.0D ? victor.multiply(1.0D / mag) : victor.multiply(0);
}
@Override
protected void check(MoveEvent e) {
HawkPlayer pp = e.getHawkPlayer();
boolean bounced = bouncedSet.contains(pp.getUuid());
boolean collidingHorizontally = collidingHorizontally(e);
Block footBlock = ServerUtils.getBlockAsync(pp.getPlayer().getLocation().clone().add(0, -0.1, 0));
if(footBlock == null)
return;
long ticksSinceIdle = pp.getCurrentTick() - lastIdleTick.getOrDefault(pp.getUuid(), pp.getCurrentTick());
double friction = e.getFriction();
//A really rough check to handle sneaking on edge of blocks.
boolean sneakEdge = pp.isSneaking() && !WrappedBlock.getWrappedBlock(footBlock, pp.getClientVersion()).isSolid() && e.isOnGround();
Vector prevVelocity = pp.getVelocity().clone();
if(e.hasHitSlowdown()) {
prevVelocity.multiply(0.6);
}
Set<Material> collidedMats = WrappedEntity.getWrappedEntity(e.getPlayer()).getCollisionBox(e.getFrom().toVector()).getMaterials(pp.getWorld());
if(collidedMats.contains(Material.SOUL_SAND)) {
prevVelocity.multiply(0.4);
}
boolean nearLiquid = testLiquid(collidedMats);
if(Math.abs(prevVelocity.getX() * friction) < 0.005) {
prevVelocity.setX(0);
}
if(Math.abs(prevVelocity.getZ() * friction) < 0.005) {
prevVelocity.setZ(0);
}
double dX = e.getTo().getX() - e.getFrom().getX();
double dZ = e.getTo().getZ() - e.getFrom().getZ();
dX /= friction;
dZ /= friction;
dX -= prevVelocity.getX();
dZ -= prevVelocity.getZ();
Vector accelDir = new Vector(dX, 0, dZ);
Vector yaw = MathPlus.getDirection(e.getTo().getYaw(), 0);
//Return if player hasn't sent at least 2 moves in a row. Let Speed handle any bypasses for this.
if(e.hasTeleported() || e.hasAcceptedKnockback() || bounced || collidingHorizontally ||
!e.isUpdatePos() || sneakEdge || e.isJump() || ticksSinceIdle <= 2 || nearLiquid || //TODO get rid of e.isJump() from here and actually try to handle it
pp.getCurrentTick() - pp.getLastVelocityAcceptTick() == 1 || collidedMats.contains(Material.LADDER) ||
collidedMats.contains(Material.VINE)) {
prepareNextMove(e, pp, pp.getCurrentTick());
return;
}
//You aren't pressing a WASD key
if(accelDir.lengthSquared() < 0.000001) {
prepareNextMove(e, pp, pp.getCurrentTick());
return;
}
boolean vectorDir = accelDir.clone().crossProduct(yaw).dot(new Vector(0, 1, 0)) >= 0;
double angle = (vectorDir ? 1 : -1) * MathPlus.angle(accelDir, yaw);
if(!isValidStrafe(angle)) {
Debug.broadcastMessage(pp.isSneaking());
punishAndTryRubberband(pp, e);
}
else
reward(pp);
prepareNextMove(e, pp, pp.getCurrentTick());
}
@Override
protected void check(MoveEvent e) {
HawkPlayer pp = e.getHawkPlayer();
boolean collisionHorizontal = collidingHorizontally(e);
Vector moveHoriz = e.getTo().toVector().subtract(e.getFrom().toVector()).setY(0);
if(!pp.isSprinting())
lastSprintTickMap.put(pp.getUuid(), pp.getCurrentTick());
Set<Material> collidedMats = WrappedEntity.getWrappedEntity(e.getPlayer()).getCollisionBox(e.getFrom().toVector()).getMaterials(pp.getWorld());
if(pp.isSwimming() || e.hasTeleported() || e.hasAcceptedKnockback() ||
(collisionHorizontal && !collisionHorizontalSet.contains(pp.getUuid())) ||
pp.getCurrentTick() - lastSprintTickMap.getOrDefault(pp.getUuid(), pp.getCurrentTick()) < 2 ||
moveHoriz.lengthSquared() < 0.04 || collidedMats.contains(Material.LADDER) ||
collidedMats.contains(Material.VINE)) {
return;
}
float yaw = e.getTo().getYaw();
Vector prevVelocity = pp.getVelocity().clone();
if(e.hasHitSlowdown()) {
prevVelocity.multiply(0.6);
}
double dX = e.getTo().getX() - e.getFrom().getX();
double dZ = e.getTo().getZ() - e.getFrom().getZ();
float friction = e.getFriction();
dX /= friction;
dZ /= friction;
if(e.isJump()) {
float yawRadians = yaw * 0.017453292F;
dX += (MathPlus.sin(yawRadians) * 0.2F);
dZ -= (MathPlus.cos(yawRadians) * 0.2F);
}
//Div by 1.7948708571637845???? What the hell are these numbers?
dX -= prevVelocity.getX();
dZ -= prevVelocity.getZ();
Vector moveForce = new Vector(dX, 0, dZ);
Vector yawVec = MathPlus.getDirection(yaw, 0);
if(MathPlus.angle(yawVec, moveForce) > Math.PI / 4 + 0.3) { //0.3 is arbitrary. Prevents falses due to silly stuff in game
punishAndTryRubberband(pp, e);
}
else {
reward(pp);
}
if(collisionHorizontal)
collisionHorizontalSet.add(pp.getUuid());
else
collisionHorizontalSet.remove(pp.getUuid());
}
/**
* Fires an arrow from the NPC at a target.
*/
public void fireArrow(ItemStack type, Location target, Vector lead) {
Location launchStart;
Vector baseVelocity;
if (SentinelVersionCompat.v1_14 && type.getType() == Material.FIREWORK_ROCKET) {
launchStart = sentinel.getLivingEntity().getEyeLocation();
launchStart = launchStart.clone().add(launchStart.getDirection());
baseVelocity = target.toVector().subtract(launchStart.toVector().add(lead));
if (baseVelocity.lengthSquared() > 0) {
baseVelocity = baseVelocity.normalize();
}
baseVelocity = baseVelocity.multiply(2);
}
else {
HashMap.SimpleEntry<Location, Vector> start = sentinel.getLaunchDetail(target, lead);
if (start == null || start.getKey() == null) {
return;
}
launchStart = start.getKey();
baseVelocity = start.getValue();
}
Vector velocity = sentinel.fixForAcc(baseVelocity);
sentinel.stats_arrowsFired++;
Entity arrow;
if (SentinelVersionCompat.v1_9) {
if (SentinelVersionCompat.v1_14) {
double length = Math.max(1.0, velocity.length());
if (type.getType() == Material.FIREWORK_ROCKET) {
FireworkMeta meta = (FireworkMeta) type.getItemMeta();
meta.setPower(3);
arrow = launchStart.getWorld().spawn(launchStart, EntityType.FIREWORK.getEntityClass(), (e) -> {
((Firework) e).setShotAtAngle(true);
((Firework) e).setFireworkMeta(meta);
e.setVelocity(velocity);
});
}
else {
Class toShoot;
toShoot = type.getType() == Material.SPECTRAL_ARROW ? SpectralArrow.class :
(type.getType() == Material.TIPPED_ARROW ? TippedArrow.class : Arrow.class);
arrow = launchStart.getWorld().spawnArrow(launchStart, velocity.multiply(1.0 / length), (float) length, 0f, toShoot);
((Projectile) arrow).setShooter(getLivingEntity());
((Arrow) arrow).setPickupStatus(Arrow.PickupStatus.DISALLOWED);
if (type.getItemMeta() instanceof PotionMeta) {
PotionData data = ((PotionMeta) type.getItemMeta()).getBasePotionData();
if (data.getType() == null || data.getType() == PotionType.UNCRAFTABLE) {
if (SentinelPlugin.debugMe) {
sentinel.debug("Potion data '" + data + "' for '" + type.toString() + "' is invalid.");
}
}
else {
((Arrow) arrow).setBasePotionData(data);
for (PotionEffect effect : ((PotionMeta) type.getItemMeta()).getCustomEffects()) {
((Arrow) arrow).addCustomEffect(effect, true);
}
}
}
}
}
else {
arrow = launchStart.getWorld().spawnEntity(launchStart,
type.getType() == Material.SPECTRAL_ARROW ? EntityType.SPECTRAL_ARROW :
(type.getType() == Material.TIPPED_ARROW ? TIPPED_ARROW : EntityType.ARROW));
arrow.setVelocity(velocity);
((Projectile) arrow).setShooter(getLivingEntity());
}
}
else {
arrow = launchStart.getWorld().spawnEntity(launchStart, EntityType.ARROW);
((Projectile) arrow).setShooter(getLivingEntity());
arrow.setVelocity(velocity);
}
if (sentinel.itemHelper.getHeldItem().containsEnchantment(Enchantment.ARROW_FIRE)) {
arrow.setFireTicks(10000);
}
sentinel.useItem();
}
@Subscribe
public void onPlayerInteractGame(PlayerInteractGameEvent event) {
HeavySpleef heavySpleef = getHeavySpleef();
SpleefPlayer player = event.getPlayer();
Action action = event.getAction();
if (action != Action.RIGHT_CLICK_AIR && action != Action.RIGHT_CLICK_BLOCK) {
return;
}
GameManager manager = heavySpleef.getGameManager();
Game game = manager.getGame(player);
if (game == null || game.getGameState() != GameState.INGAME) {
return;
}
Player bukkitPlayer = player.getBukkitPlayer();
ItemStack inHand = bukkitPlayer.getItemInHand();
if (inHand.getType() != SPLEGG_LAUNCHER_MATERIAL) {
return;
}
if (spleggCooldownTimes.containsKey(player)) {
long cooldown = config.getFlagSection().getSpleggEggCooldown() * 50L;
long lastUse = spleggCooldownTimes.get(player);
if (System.currentTimeMillis() - lastUse < cooldown) {
return;
}
}
spleggCooldownTimes.put(player, System.currentTimeMillis());
Vector vector = bukkitPlayer.getLocation().getDirection();
double vectorFactor = config.getFlagSection().getSpleggEggVelocityFactor();
vector.multiply(vectorFactor);
bukkitPlayer.launchProjectile(Egg.class, vector);
Sound ghastFireballSound = Game.getSoundEnumType("GHAST_FIREBALL", "GHAST_SHOOT");
if (ghastFireballSound != null) {
bukkitPlayer.playSound(bukkitPlayer.getLocation(), ghastFireballSound, 0.4f, 2f);
}
}
private int buildRoadSegment(Player player, Location locFirst, Location locSecond, int blockCount,
HashMap<String, SimpleBlock> simpleBlocks, int segments) throws CivException {
Vector dir = new Vector(locFirst.getX() - locSecond.getX(),
locFirst.getY() - locSecond.getY(),
locFirst.getZ() - locSecond.getZ());
dir.normalize();
dir.multiply(0.5);
getHorizontalSegment(player, locSecond, simpleBlocks);
segments++;
/* Increment towards the first location. */
double distance = locSecond.distance(locFirst);
BlockCoord lastBlockCoord = new BlockCoord(locSecond);
BlockCoord currentBlockCoord = new BlockCoord(locSecond);
int lastY = locSecond.getBlockY();
while (locSecond.distance(locFirst) > 1.0) {
locSecond.add(dir);
currentBlockCoord.setFromLocation(locSecond);
if (lastBlockCoord.distance(currentBlockCoord) < Road.WIDTH) {
continue; /* Didn't move far enough, keep going. */
} else {
lastBlockCoord.setFromLocation(locSecond);
}
/* Make sure the Y doesnt get too steep. */
if (Math.abs(lastY - locSecond.getBlockY()) > 1.0 ) {
throw new CivException("Road is too steep to be built here. Try lowering the one of the end points to make the road less steep.");
}
if (locSecond.getBlockY() < 5) {
throw new CivException("Cannot build road blocks within 5 blocks of bedrock.");
}
lastY = locSecond.getBlockY();
blockCount++;
if (blockCount > Road.RECURSION_LIMIT) {
throw new CivException("ERROR: Building road blocks exceeded recursion limit! Halted to keep server alive.");
}
getHorizontalSegment(player, locSecond, simpleBlocks);
// Road.DEBUG_DATA++;
// if (Road.DEBUG_DATA > 15) {
// Road.DEBUG_DATA = 0;
// }
segments++;
//Distance should always be going down, as a failsave
//check that it is. Abort if our distance goes up.
double tmpDist = locSecond.distance(locFirst);
if (tmpDist > distance) {
break;
}
}
/*
* Build last road segment
*/
getHorizontalSegment(player, locFirst, simpleBlocks);
return segments;
}