If instruction in Minecraft? Bla bla bla

No
13

I have built a minecraft map in the last few days, but after a while I came across a problem: How can you trigger a button that, for example, 5 slides are deleted from the inventory and you get an effect - but if you do not get 5 Slides have no 5 slides subtracted and the effect does not appear. If one of you knows how to do it please write me.

fl

Is this a map in which you determine where the slides are (Adventure Map like) or a kind of survival map with extras?

Be

First of all you need a scoreboard as intermediate storage. You create this by executing the following command once:

/ scoreboard objectives add inv_dia dummy

With this command you count the number of slides in the inventory and save the result on the scoreboad

/ execute as @a store score @s inv_dia run clear @s diamond 0

With the next command you can have all your effects carried out, which then happen like the slides clear. For this you have to put the command behind the run

/ execute as @a [scores = {inv_dia = 5.}] run your command

gl

Can you have a maximum of 5 diamonds, or is it possible that you can have more? If you can only have a maximum of 5, then I can help you!

No

It's just like this: you do a jump and run, you get slides with every attempt you make and can then spend them on items. However, permanent effects can't be obtained by a potion, only you can get a command - otherwise I would simply put a Villager for the tradet

No

It doesn't matter - if you have more than 4 slides - than 5+ - then 5 slides are subtracted and you get a permanent effect

gl

So you place a command block (impulse | unconditional | always active):

/ execute if entity @p [nbt = {Inventory: [{id: "minecraft: diamond", Count: 5-2304b}]}] run clear @p minecraft: diamond 5

This command ensures that 5 diamonds are taken away if he has between 5 and 2304 diamonds (maximum number of items you can have in your inventory).

The next command block (chain | conditional | always active) must be placed next to the first command block so that the first command block looks at the second one and both are looking in the same direction.

Then write in the second command block:

/ effect give @ p…

No

It is not marked in red, but if I triggered it, no slide will be removed

gl

Give it a try

/ execute if entity @p [nbt = {Inventory: [{id: "minecraft: diamond", Count: 5b}]}] run clear @p minecraft: diamond 5

in the first command block

No

Ah now it works - just one more question - how can I get 5 slides deducted if I have 5 slides or more in my inventory?

gl

I don't know how to do that if you have more than 5 diamonds. That would work with plugins, I think.

No

Is there not a possibility in minecraft to give a from-to instruction - from 5 slides to 2000 slides for example - I thought the gienge somehow with points so 5.2000 but that didn't work

gl

Ah wait, that's possible with scoreboards!

But this only works if the player picks up the diamonds, not if they get them with / give.

First you create the scoreboards:

/ scoreboard objectives add diamonds minecraft.picked_up: minecraft.diamond
/ scoreboard objectives add removediamonds minecraft.dropped: minecraft.diamond

Then you place a command block somewhere underground (Repeat | Absolutely | Always active) and write in:

/ scoreboard players operation @a diamonds - = @a removediamonds

Then you place a command block (chain | conditional | always active) on the purple command block so that both look in the same direction and the purple looks at the green one and writes in the green one:

/ scoreboard players set @a removediamonds 0

Then you can (optional!)

/ scoreboard objectives set display sidebar diamonds

Enter in the chat so you can see how many diamonds the scoreboard sees in your inventory while testing.

To undo that, you have to

/ scoreobard objectives set display sidebar

enter.

Now you can just test how many diamonds a player has. To do this, write in the first command block from my first comment of this answer:

/ execute if entity @p [scores = {diamonds = 5.}] run clear @p minecraft: diamond 5

This is how it should work.

No

Couldn't you also create a Villager that trades a potion?

I know websites where you can put together a Villager for 1.16 and another where you can have your own potions generated. So if I entered in… Sell: {id: minecraft: potion {…} it would have to work. At first I tried that too, but continuously everything was red

https://www.digminecraft.com/generators/villager_trade_1_15.php

https://minecraftcommand.science/de/potion-generator#0.9e74llq586t