1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
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;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
public class CraftNoteBlock extends CraftBlockState implements NoteBlock {
private final CraftWorld world;
private final TileEntityNote note;
public CraftNoteBlock(final Block block) {
super(block);
world = (CraftWorld) block.getWorld();
note = (TileEntityNote) world.getTileEntityAt(getX(), getY(), getZ());
}
public Note getNote() {
return new Note(note.note);
}
public byte getRawNote() {
return note.note;
}
public void setNote(Note n) {
note.note = n.getId();
}
public void setRawNote(byte n) {
note.note = n;
}
public boolean play() {
Block block = getBlock();
if (block.getType() == Material.NOTE_BLOCK) {
note.play(world.getHandle(), getX(), getY(), getZ());
return true;
} else {
return false;
}
}
@Override
public boolean play(byte instrument, byte note) {
Block block = getBlock();
if (block.getType() == Material.NOTE_BLOCK) {
world.getHandle().playNote(getX(), getY(), getZ(), CraftMagicNumbers.getBlock(block), instrument, note);
return true;
} else {
return false;
}
}
@Override
public boolean play(Instrument instrument, Note note) {
Block block = getBlock();
if (block.getType() == Material.NOTE_BLOCK) {
world.getHandle().playNote(getX(), getY(), getZ(), CraftMagicNumbers.getBlock(block), instrument.getType(), note.getId());
return true;
} else {
return false;
}
}
}
|