public class Jukebox extends VanillaBlockComponent {
@Override
public void onInteract(final EntityInteractEvent event) {
super.onInteract(event);
if (event instanceof PlayerInteractEntityEvent) {
final PlayerInteractEntityEvent pie = (PlayerInteractEntityEvent) event;
switch (pie.getAction()) {
case RIGHT_CLICK:
Slot inv = PlayerUtil.getHeldSlot(pie.getEntity());
if (inv != null && this.canPlay(inv.get())) {
this.setPlayedItem(inv.get().clone().setAmount(1));
if (!PlayerUtil.isCostSuppressed(pie.getEntity())) {
inv.addAmount(-1);
}
} else {
this.eject();
}