Minecraft only have one item in the inventory?

gl
13

How can you do it so that on the one hand you have infinite items, for example firework rockets, on the other hand you only ever have one firework rocket, that is not 2 and not 0?

Te

With the replace item command, you can put something in a slot.

That in ne function or n repeating command block and done

oc

Change creative mode or something in the EN

EN = settings

gl

You didn't understand what I mean. I mean that every player always has a firework rocket, even if they use it.

gl

And what should the command look like?

/ replaceitem entity @ a… (slot 1 and firework rocket to be replaced by air)

oc

Ah there's a command! You have to enter it in a command block and you're done. Should be on the Internet ^^

Ma

Which version is it about? 1.15.2?

Te

I don't understand now why you want to take the rocket out… But I think the slot is called slot.hotbar.0 because the numbering starts with 0

gl

Bruh I exchanged fireworks rocket for air. So what should the whole command look like?

gl

Yes

gl

I'm looking for this command

Be

The best way to do this is with this command:

/ execute as @a [nbt =! {Inventory: [{id: "minecraft: firework_rocket"}]}] run replaceitem entity @s inventory.1 minecraft: firework_rocket 1

This has the advantage that you can still move the fireworks rocket freely in the inventory without getting a new one.

You can select the slot in the inventory by adding the 1 after inventory. Replaced with the number of slots. 1 is the slot on the top left and then it goes from left to right and then down.

Ma

Just like that!

gl

Thank you!