use of org.bukkit.Note in project Glowstone by GlowstoneMC.
the class GlowNoteBlock method play.
////////////////////////////////////////////////////////////////////////////
// Internals
@Override
public boolean play(Instrument instrument, Note note) {
if (getBlock().getType() != Material.NOTE_BLOCK) {
return false;
}
NotePlayEvent event = EventFactory.callEvent(new NotePlayEvent(getBlock(), instrument, note));
if (event.isCancelled()) {
return false;
}
Location location = getBlock().getLocation();
Key key = new Key(getX() >> 4, getZ() >> 4);
getWorld().getRawPlayers().stream().filter(player -> player.canSeeChunk(key)).forEach(player -> player.playNote(location, instrument, note));
return true;
}
use of org.bukkit.Note in project Glowstone by GlowstoneMC.
the class NoteblockEntity method loadNbt.
@Override
public void loadNbt(CompoundTag tag) {
super.loadNbt(tag);
note = new Note(tag.getByte("note"));
}
use of org.bukkit.Note in project Glowstone by GlowstoneMC.
the class BlockNote method blockInteract.
@Override
public boolean blockInteract(GlowPlayer player, GlowBlock block, BlockFace face, Vector clickedLoc) {
NoteBlock noteBlock = (NoteBlock) block.getState();
Note note = noteBlock.getNote();
noteBlock.setNote(new Note(note.getId() == 24 ? 0 : note.getId() + 1));
noteBlock.update();
return noteBlock.play();
}
Aggregations