org.bukkit.block.NoteBlock Java Examples

The following examples show how to use org.bukkit.block.NoteBlock. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MusicBot.java    From NeuralNetworkAPI with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setInputs(CommandSender initiator, String[] args) {
	//
	final Player player = (Player) initiator;
	final int ticksMax = (args.length > 1) ? Integer.parseInt(args[1]) : 20;

	final Location base = player.getLocation().clone();

	final int channels = this.trainingValues.length;

	for (int i = 0; i < channels; i++) {
		base.clone().add(i, 0, 0).getBlock().setType(Material.NOTE_BLOCK);
	}
	new BukkitRunnable() {
		int tick = 0;

		@SuppressWarnings("deprecation")
		@Override
		public void run() {
			tick++;
			int row = 0;
			for (Neuron n : ai.getOutputNeurons()) {
				if (n.isTriggered()) {
					((NoteBlock) base.clone().add(row, 0, 0).getBlock()
							.getState()).setRawNote((byte) n.getID());
					((NoteBlock) base.clone().add(row, 0, 0).getBlock()
							.getState()).play();
					row++;

				}
			}

			if (tick > ticksMax)
				cancel();
		}
	}.runTaskTimer(Main.getMainClass(), 30, 9);

}