added sheepSpawnRadius, configurable later

This commit is contained in:
Charlie Wang 2013-06-30 14:27:46 -04:00
parent d7b075d507
commit bf15d90dcd

View File

@ -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);
} }
} }