properly randomized the sheep spawn coordinates
This commit is contained in:
parent
df9bab0fef
commit
d947c62c6a
@ -77,12 +77,16 @@ public class DiscoParty {
|
||||
World world = player.getWorld();
|
||||
|
||||
for (int i = 0; i < num; i++) {
|
||||
double x, y, z;
|
||||
double x = player.getLocation().getX();
|
||||
double z = player.getLocation().getZ();
|
||||
double y;
|
||||
|
||||
// random point on circle with polar coordinates
|
||||
double r = Math.sqrt(Math.random()) * sheepSpawnRadius; // sqrt for uniform distribution
|
||||
double azimuth = Math.random() * 2 * Math.PI; // radians
|
||||
x += r * Math.cos(azimuth);
|
||||
z += r * Math.sin(azimuth);
|
||||
|
||||
// random x, z, and yaw
|
||||
// safe y-coordinate
|
||||
x = -sheepSpawnRadius + (Math.random() * ((sheepSpawnRadius * 2) + 1)) + player.getLocation().getX();
|
||||
z = -sheepSpawnRadius + (Math.random() * ((sheepSpawnRadius * 2) + 1)) + player.getLocation().getZ();
|
||||
y = world.getHighestBlockYAt((int) x, (int) z);
|
||||
loc = new Location(world, x, y, z);
|
||||
//loc.setYaw(0);
|
||||
|
Loading…
Reference in New Issue
Block a user