The bug
Jukeboxes that have been placed, broken, and then picked up again will not stack with jukeboxes that have never been placed.
Expected behaviour
Jukeboxes all stack.
How to reproduce
Get 2 jukeboxes
Place one of them on the ground
In survival mode, break it with the hand and pick it up
❌ The broken jukebox creates a new stack
Linked issues
is duplicated by 3
relates to 1
Attachments
Comments 14
I've tested this in vanilla single player in both 1.16.5 as well as the latest 21w07a. It still happens exactly as described, although it apparently has nothing to do with optifine so I removed that part.
In the setPlacedBy
method of net.minecraft.world.level.block.JukeboxBlock
(mojang mappings),
an empty compound tag is created on the item stack that is used to place the jukebox.
This issue seems to have been introduced in 1.16-pre5 when MC-180867 was fixed. That version added the following code to JukeboxBlock.setPlacedBy
(as noted by @unknown):
CompoundTag tag = stack.getOrCreateTag();
if (tag.contains("BlockEntityTag")) {
CompoundTag tag2 = tag.getCompound("BlockEntityTag");
if (tag.contains("RecordItem")) {
// Update has_record state
}
}
21w37a replaced that code with this:
CompoundTag tag = item.getBlockEntityData(stack);
// above is equivalent to stack.getTagElement("BlockEntityTag"), which doesn't create tag if there is no tag
if (tag != null && tag.contains("RecordItem")) {
// Update has_record state
}
I also am able to reproduce the issue in 1.17.1 but not in 21w37a, so I'm marking it as fixed. (MC-180867 also remains fixed.)
can confirm for non-optifine 1.16.5
[media]@Adan Chappuis Ideally remove the 'optifine' bit