Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 20:40:07 +01:00
Added CraftNoteBlock.play
Dieser Commit ist enthalten in:
Ursprung
e0416ca7fb
Commit
21b8ef4435
@ -1,31 +1,45 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.TileEntityNote;
|
||||
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;
|
||||
private final TileEntityNote note;
|
||||
|
||||
public CraftNoteBlock(final Block block) {
|
||||
super(block);
|
||||
|
||||
world = (CraftWorld)block.getWorld();
|
||||
note = (TileEntityNote)world.getTileEntityAt(getX(), getY(), getZ());
|
||||
}
|
||||
|
||||
public byte getNote() {
|
||||
return note.e;
|
||||
}
|
||||
|
||||
public void setNote(byte n) {
|
||||
note.e = n;
|
||||
}
|
||||
}
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.TileEntityNote;
|
||||
import org.bukkit.Material;
|
||||
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;
|
||||
private final TileEntityNote note;
|
||||
|
||||
public CraftNoteBlock(final Block block) {
|
||||
super(block);
|
||||
|
||||
world = (CraftWorld)block.getWorld();
|
||||
note = (TileEntityNote)world.getTileEntityAt(getX(), getY(), getZ());
|
||||
}
|
||||
|
||||
public byte getNote() {
|
||||
return note.e;
|
||||
}
|
||||
|
||||
public void setNote(byte n) {
|
||||
note.e = n;
|
||||
}
|
||||
|
||||
public boolean play() {
|
||||
Block block = getBlock();
|
||||
|
||||
synchronized (block) {
|
||||
if (block.getType() == Material.NOTE_BLOCK) {
|
||||
note.a(world.getHandle(), getX(), getY(), getZ());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren