mojira.dev
MC-268999

Container Item Component Doesn't Work with Containers that aren't Shulker Boxes

When using a give command to give yourself a chest with a container component the contents of that component are not set to the chest when placed.

/give @s minecraft:chest[minecraft:container=[{slot:0,item:{id:"minecraft:dirt"}}]]

gives a chest that won't have a dirt block inside it when placed

/give @s minecraft:shulker_box[minecraft:container=[{slot:0,item:{id:"minecraft:dirt"}}]]

gives a shulker box that will have a dirt block when placed

Other components can be used across many items as long as it's applicable

Comments 3

'container' is specifically used for shulker boxes as noted in the changelog:

MINECRAFT:CONTAINER
Holds the contents of Shulker Boxes in item form
Copied to Shulker Box block when placed
Replaces BlockEntityTag.Items tag
Format: list of slots
slot: integer [0; 255], representing a slot in the container
item: item stack
e.g. container=[{slot:7,item:{id:'diamond_pickaxe',components:{'minecraft:unbreakable':{}}}}]
On Shulker Boxes, has an implicit default value of: []

container_loot should be used instead for chests.

This doesn't allow for explicit or inline item definitions for the container though, you must create a loot table for the items that you want in your chest item. This makes what you can have as the item contents for the chest less dynamic as you have to point to a static loot table.

Thank you for your report!
After consideration, the issue is being closed as Invalid.

You have posted a feature request or a suggestion. This site is for bug reports only.
For suggestions, please visit The official Minecraft feedback site or visit the Minecraft Feedback Discord server.

Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support (Technical Issues) – 📧 Microsoft Support (Account Issues)
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki

bayugoon

gegy

Confirmed

(Unassigned)

24w09a

Retrieved