geforkt von Mirrors/Paper
Implementation of the Jukebox BlockState
Dieser Commit ist enthalten in:
Ursprung
6c6eef8759
Commit
aece687d01
@ -212,6 +212,8 @@ public class CraftBlock implements Block {
|
||||
return new CraftCreatureSpawner(this);
|
||||
case NOTE_BLOCK:
|
||||
return new CraftNoteBlock(this);
|
||||
case JUKEBOX:
|
||||
return new CraftJukebox(this);
|
||||
default:
|
||||
return new CraftBlockState(this);
|
||||
}
|
||||
|
50
src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java
Normale Datei
50
src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java
Normale Datei
@ -0,0 +1,50 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Jukebox;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
|
||||
import net.minecraft.server.BlockJukeBox;
|
||||
import net.minecraft.server.TileEntityRecordPlayer;
|
||||
|
||||
public class CraftJukebox extends CraftBlockState implements Jukebox {
|
||||
private final CraftWorld world;
|
||||
private final TileEntityRecordPlayer jukebox;
|
||||
|
||||
public CraftJukebox(final Block block) {
|
||||
super(block);
|
||||
|
||||
world = (CraftWorld) block.getWorld();
|
||||
jukebox = (TileEntityRecordPlayer) world.getTileEntityAt(getX(), getY(), getZ());
|
||||
}
|
||||
|
||||
public Material getPlaying() {
|
||||
return Material.getMaterial(jukebox.a);
|
||||
}
|
||||
|
||||
public void setPlaying(Material record) {
|
||||
if (record == null) {
|
||||
record = Material.AIR;
|
||||
}
|
||||
jukebox.a = record.getId();
|
||||
jukebox.update();
|
||||
if (record == Material.AIR) {
|
||||
world.getHandle().setData(getX(), getY(), getZ(), 0);
|
||||
} else {
|
||||
world.getHandle().setData(getX(), getY(), getZ(), 1);
|
||||
}
|
||||
world.playEffect(getLocation(), Effect.RECORD_PLAY, record.getId());
|
||||
}
|
||||
|
||||
public boolean isPlaying() {
|
||||
return getRawData() == 1;
|
||||
}
|
||||
|
||||
public boolean eject() {
|
||||
boolean result = isPlaying();
|
||||
((BlockJukeBox)net.minecraft.server.Block.JUKEBOX).c_(world.getHandle(), getX(), getY(), getZ());
|
||||
return result;
|
||||
}
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren