Hello! I'm coding a plugin which spawn gold ingots around a ceratin area randomly but ingots never spawn and theres not error in console. Heres code: Code: public void onRandomSpawn(){ int radius = 7; World w = Bukkit.getServer().getWorld(settings.getData().getString("center.world")); double x = settings.getData().getDouble("center.x"); double z = settings.getData().getDouble("center.z"); Random random = new Random(); int xNew = (int) (x + random.nextInt(random.nextBoolean() ? radius : 1)); int zNew = (int) (z + random.nextInt(random.nextBoolean() ? radius : 1)); int yNew = Bukkit.getServer().getWorld("world").getHighestBlockYAt(zNew, xNew); w.dropItemNaturally(new Location(w, xNew, zNew, yNew), new ItemStack(Material.GOLD_INGOT,1)); } ALso tryed: Code: public void onRandomSpawn(){ int radius = 4; World w = Bukkit.getServer().getWorld(settings.getData().getString("center.world")); double x = settings.getData().getDouble("center.x"); double z = settings.getData().getDouble("center.z"); Random random = new Random(); int xNew = (int) (x + random.nextInt(random.nextBoolean() ? radius : 1)); int zNew = (int) (z + random.nextInt(random.nextBoolean() ? radius : 1)); int yNew = (85); w.dropItemNaturally(new Location(w, xNew, zNew, yNew), new ItemStack(Material.GOLD_INGOT,1)); } The only diference between the 2 is the int yNew. Main class: Code: public void onEnable(){ BukkitScheduler scheduler = getServer().getScheduler(); scheduler.scheduleSyncRepeatingTask(this, new Runnable() { @Override public void run() { Tk.onRandomSpawn(); } }, 0L, 80L); } Thanks!
@danichef new Location(world, x, y, z); you are switching the Z and Y. you are getting the hightest block from the world 'world' and apply it to the world w