use of cn.nukkit.blockentity.BlockEntityJukebox in project Nukkit by Nukkit.
the class BlockJukebox method onActivate.
@Override
public boolean onActivate(Item item, Player player) {
BlockEntity blockEntity = this.getLevel().getBlockEntity(this);
if (blockEntity == null || !(blockEntity instanceof BlockEntityJukebox)) {
blockEntity = this.createBlockEntity();
}
BlockEntityJukebox jukebox = (BlockEntityJukebox) blockEntity;
if (jukebox.getRecordItem().getId() != 0) {
jukebox.dropItem();
} else if (item instanceof ItemRecord) {
jukebox.setRecordItem(item);
jukebox.play();
player.getInventory().decreaseCount(player.getInventory().getHeldItemIndex());
}
return false;
}
Aggregations