diff options
author | EvilSeph <evilseph@unaligned.org> | 2011-06-17 03:16:18 -0400 |
---|---|---|
committer | EvilSeph <evilseph@unaligned.org> | 2011-06-17 03:16:18 -0400 |
commit | 39332e5c8747d1615a8d8efa9a7062f53e1dfe1d (patch) | |
tree | cb0083bb65a30731416279ad7908f4a03f0c63b0 /src/main/java/org/bukkit | |
parent | cc1b0a005cdb14007c4647599a984967ff637659 (diff) | |
download | craftbukkit-39332e5c8747d1615a8d8efa9a7062f53e1dfe1d.tar craftbukkit-39332e5c8747d1615a8d8efa9a7062f53e1dfe1d.tar.gz craftbukkit-39332e5c8747d1615a8d8efa9a7062f53e1dfe1d.tar.lz craftbukkit-39332e5c8747d1615a8d8efa9a7062f53e1dfe1d.tar.xz craftbukkit-39332e5c8747d1615a8d8efa9a7062f53e1dfe1d.zip |
Added Instrument enum, Note class and get/setNote functions. Thanks xZise!
Diffstat (limited to 'src/main/java/org/bukkit')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/block/CraftNoteBlock.java | 32 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java | 6 |
2 files changed, 36 insertions, 2 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftNoteBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftNoteBlock.java index 055c74fd..76364cc6 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftNoteBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftNoteBlock.java @@ -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; + } + } + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 56f9f6ce..d2001860 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -15,8 +15,10 @@ import net.minecraft.server.ServerConfigurationManager; import net.minecraft.server.WorldServer; import org.bukkit.Achievement; import org.bukkit.Effect; +import org.bukkit.Instrument; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Note; import org.bukkit.Statistic; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftWorld; @@ -150,6 +152,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player { getHandle().netServerHandler.sendPacket(new Packet54PlayNoteBlock(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), instrument, note)); } + public void playNote(Location loc, Instrument instrument, Note note) { + getHandle().netServerHandler.sendPacket(new Packet54PlayNoteBlock(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), instrument.getType(), note.getId())); + } + public void playEffect(Location loc, Effect effect, int data) { int packetData = effect.getId(); Packet61 packet = new Packet61(packetData, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), data); |