Added Instrument enum, Note class and get/setNote functions. Thanks xZise!

By: EvilSeph <evilseph@unaligned.org>
This commit is contained in:
CraftBukkit/Spigot
2011-06-17 03:16:18 -04:00
parent 51e0c1409b
commit 5b6c2eb1b3
2 changed files with 36 additions and 2 deletions

View File

@@ -1,15 +1,16 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.server.TileEntityNote;
import org.bukkit.Instrument;
import org.bukkit.Material;
import org.bukkit.Note;
import org.bukkit.block.Block;
import org.bukkit.block.NoteBlock;
import org.bukkit.craftbukkit.CraftWorld;
/**
* Represents a note block.
*
* @author sk89q
*/
public class CraftNoteBlock extends CraftBlockState implements NoteBlock {
private final CraftWorld world;
@@ -22,14 +23,28 @@ public class CraftNoteBlock extends CraftBlockState implements NoteBlock {
note = (TileEntityNote) world.getTileEntityAt(getX(), getY(), getZ());
}
@Deprecated
public byte getNote() {
return note.note;
}
public byte getRawNote() {
return note.note;
}
public void setNote(Note n) {
note.note = n.getId();
}
@Deprecated
public void setNote(byte n) {
note.note = n;
}
public void setRawNote(byte n) {
note.note = n;
}
public boolean play() {
Block block = getBlock();
@@ -55,4 +70,17 @@ public class CraftNoteBlock extends CraftBlockState implements NoteBlock {
}
}
}
public boolean play(Instrument instrument, Note note) {
Block block = getBlock();
synchronized (block) {
if (block.getType() == Material.NOTE_BLOCK) {
world.getHandle().d(getX(), getY(), getZ(), instrument.getType(), note.getId());
return true;
} else {
return false;
}
}
}
}