added sheepSpawnRadius, configurable later
This commit is contained in:
parent
d7b075d507
commit
bf15d90dcd
@ -13,6 +13,8 @@ public final class DiscoSheep extends JavaPlugin {
|
|||||||
|
|
||||||
private ArrayList<Sheep> sheepArray = new ArrayList<>();
|
private ArrayList<Sheep> sheepArray = new ArrayList<>();
|
||||||
private DiscoUpdater updater = new DiscoUpdater(this);
|
private DiscoUpdater updater = new DiscoUpdater(this);
|
||||||
|
// radius for random sheep spawns around player
|
||||||
|
private static int sheepSpawnRadius = 5;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
@ -41,11 +43,10 @@ public final class DiscoSheep extends JavaPlugin {
|
|||||||
|
|
||||||
// random x and z coordinates within a 5 block radius
|
// random x and z coordinates within a 5 block radius
|
||||||
// safe y-coordinate
|
// safe y-coordinate
|
||||||
x = -5 + (Math.random() * ((5 - (-5)) + 1)) + player.getLocation().getX();
|
x = -sheepSpawnRadius + (Math.random() * ((sheepSpawnRadius * 2) + 1)) + player.getLocation().getX();
|
||||||
z = -5 + (Math.random() * ((5 - (-5)) + 1)) + player.getLocation().getZ();
|
z = -sheepSpawnRadius + (Math.random() * ((sheepSpawnRadius * 2) + 1)) + player.getLocation().getZ();
|
||||||
y = world.getHighestBlockYAt((int) x, (int) z);
|
y = world.getHighestBlockYAt((int) x, (int) z);
|
||||||
loc = new Location(world, x, y, z);
|
loc = new Location(world, x, y, z);
|
||||||
|
|
||||||
spawnSheep(world, loc);
|
spawnSheep(world, loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user