Implementation of the Jukebox BlockState

Dieser Commit ist enthalten in:
Celtic Minstrel 2011-08-22 01:36:01 -04:00 committet von Dinnerbone
Ursprung 6c6eef8759
Commit aece687d01
2 geänderte Dateien mit 52 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -212,6 +212,8 @@ public class CraftBlock implements Block {
return new CraftCreatureSpawner(this); return new CraftCreatureSpawner(this);
case NOTE_BLOCK: case NOTE_BLOCK:
return new CraftNoteBlock(this); return new CraftNoteBlock(this);
case JUKEBOX:
return new CraftJukebox(this);
default: default:
return new CraftBlockState(this); return new CraftBlockState(this);
} }

Datei anzeigen

@ -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;
}
}