mojira.dev
MC-151711

Adding items to a chest via "data modify append" only works with a Slot tag

When using the following command in a command block that has an empty chest on top, it correctly adds a stack of iron ingots.

/data modify block ~ ~1 ~ Items append value {id:"iron_ingot",Count:64b}

ACTUAL

Executing it another time does nothing. The command still outputs "Modified block data of x, y, z".

I assume that's because items gain a default Slot tag when added to a container, and that is always 1, instead of being incremented to the next free slot.

⚠️ This is not a duplicate of MC-150999.

It's not intuitive that the command requires a Slot tag for every other time. It also doesn't make sense, when using a command named append, which in all other contexts adds an item to the end of a list, whatever it's current size. (same for prepend with the start of the list)

On top of that, Slot isn't part of the normal Item NBT (e.g. item entities don't have a Slot). It's only a property of containers (or inventories) to give items a temporary and virtual Slot tag When an item is removed from a container, it'll immediately lose the Slot tag.

EXPECTED

It should add another stack of iron ingots to the chest (in the next free slot).

Linked issues

Comments 9

You need Slot to specify what slot the item is in.

Yes, it is part of the normal item NBT. Without it, the container doesn't know what slot to put it in.

@violine1101 how do you know that Mojang planned it to be this way? The name append implies that well.. the item gets appended, not that a Slot tag gets magically created with a value of 0 and thus sets the item in the first slot, instead of appending the provided item.

The container knows what items it contains, so it *does* know where to place the item.. in the next empty slot.

append just means that the command will append an NBT object to an NBT list. That's it. It won't change the default values of the attributes inside of that object.

Anything claiming that default behaviour should be otherwise is a feature request.

But it doesn't "append" an NBT object. It replaces / sets an NBT object, at the first slot.

Have you spoken with the Java devs or why are you so sure that it's the intended behavior?

"insert" and "prepend" exist for a reason, but with the current behavior they are useless for containers, since you always need to manually prepare a static Slot value. (i.e. They all do the same with containers.)

@violine1101 I'd like to speak with your manager.

Okay, but seriously 😉, is there a chance we could get an official statement from a Mojang dev about whether this is by design?

I can ask if they want to comment, but no promises that it'll be soon.

@violine1101 Not complaining, just out of curiosity: How long do they usually take to respond?

@violine1101 Any news? 🙂

Josh Miller

(Unassigned)

Unconfirmed

(Unassigned)

Minecraft 1.14.1

Retrieved