2012-06-10 17:34:05 +02:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2012-06-10 17:39:18 +02:00
|
|
|
import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
|
|
|
|
2012-06-10 17:34:05 +02:00
|
|
|
public class TileEntityNote extends TileEntity {
|
|
|
|
|
|
|
|
public byte note = 0;
|
|
|
|
public boolean b = false;
|
|
|
|
|
|
|
|
public TileEntityNote() {}
|
|
|
|
|
|
|
|
public void b(NBTTagCompound nbttagcompound) {
|
|
|
|
super.b(nbttagcompound);
|
|
|
|
nbttagcompound.setByte("note", this.note);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
|
|
|
super.a(nbttagcompound);
|
|
|
|
this.note = nbttagcompound.getByte("note");
|
|
|
|
if (this.note < 0) {
|
|
|
|
this.note = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.note > 24) {
|
|
|
|
this.note = 24;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void c() {
|
|
|
|
this.note = (byte) ((this.note + 1) % 25);
|
|
|
|
this.update();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void play(World world, int i, int j, int k) {
|
|
|
|
if (world.getMaterial(i, j + 1, k) == Material.AIR) {
|
|
|
|
Material material = world.getMaterial(i, j - 1, k);
|
|
|
|
byte b0 = 0;
|
|
|
|
|
|
|
|
if (material == Material.STONE) {
|
|
|
|
b0 = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (material == Material.SAND) {
|
|
|
|
b0 = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (material == Material.SHATTERABLE) {
|
|
|
|
b0 = 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (material == Material.WOOD) {
|
|
|
|
b0 = 4;
|
|
|
|
}
|
|
|
|
|
2012-06-10 17:39:18 +02:00
|
|
|
// CraftBukkit start
|
|
|
|
org.bukkit.event.block.NotePlayEvent event = CraftEventFactory.callNotePlayEvent(this.world, i, j, k, b0, this.note);
|
|
|
|
if (!event.isCancelled()) {
|
|
|
|
this.world.playNote(i, j, k, event.getInstrument().getType(), event.getNote().getId());
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2012-06-10 17:34:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|