Minecraft Java Edition – How to Prevent a Jukebox from Dropping Its Disc

minecraft-commandsminecraft-java-edition

I'm trying to make a jukebox not drop its disc but instead make the disc disappear so that I am unable to pick it up. Are there such possible methods of doing so? I have tried adding a command block that placed lava on the same block as the Jukebox and a command block that replaced the Jukebox so when the Disc falls out of the Jukebox it burns but if you stand near the jukebox it is still possible to get the disc which is something that I don't want.

Best Answer

You could run a simple repeating command block killing all item entities in the area of the jukebox, replacing the X Y and Z values with that of the block above the jukebox:

/kill @e[type=Item,x=...,y=...,z=...,r=2]

This could invoke some other problems though, as all items nearby will be destroyed. There are ways around this, such as adding all of the item entities with the ID of music discs to a scoreboard.

/scoreboard objectives add discs dummy
/scoreboard players set @e[type=Item,x=...,y=...,z=...,r=5] disc 1 {Item:{id:"minecraft:record_chirp"}}

Note: this is specific to chirp music discs. To find the id of any other music disc, use F3 + H ingame to reveal all items' ids on their tooltips, or use an ID list.

Then killing only the item entities both nearby and that are actually music discs:

/kill @e[type=Item,x=...,y=...,z=...,r=2,score_discs_min=1]