Today I was trying to make an "Evil bread" that, when eaten, gives a player slowness. The system I set up was I did /scoreboard objectives add evilBread stat.useItem.minecraft.bread. Then, on a clock I have /effect @a[score_evilBread_min=1] minecraft:slowness 20 5 and /scoreboard players set @a[score_evilBread_min=1] evilBread 0. This works, when a player eats bread, it gives them slowness. Simple. But I need a way where if a player eats a bread named Evil Bread with a lore of "Eat this" it will give them slowness, but if they eat bread without this name and/or lore, nothing will happen. If anyone knows a way to do this, please put it down below. Thanks!
You'll just have to make sure command blocks are in correct alinement on clock and the ebread set score 3 is enough time to allow bread score to trigger and you should be good.
You'll just have to make sure command blocks are in correct alinement on clock and the ebread set score 3 is enough time to allow bread score to trigger and you should be good.
There is no need for an execute at all, much less need for a dual execute. As well, the targeting in that command is flawed due to the mix of target selectors; @a can target dead players but @p cannot, which can result in the wrong player receiving slowness. Even moreso it will exponentially increase in the number of targets since you're affecting all players twice in a row.
/effect itself has a target selector you can use. You can specify the scores with the "score" parameter inside that selector. Avoid using /execute when it is not necessary. /execute's main purpose is to change the origin of the command, which is not needed at all in this case. Misusing it will contribute to server lag due to the amount of commands being processed.
So I have an objective called holdingevilBread. The command running for that is /scoreboard players set @a holdingevilBread 1 {SelectedItem:{id:"minecraft:bread",tag:{display:{Name:"Evil Bread",Lore:["Eat this"]}}}}
Then I have an objective called evilBread that has stat.useItem.minecraft.bread and the commands is /scoreboard players set @a[score_evilBread_min=1] evilBread 0 and
/effect @a[score_evilBread_min=1,score_holdingevilBread_min=1] minecraft:slowness. However, this last effect command doesn't work. Well, it does, but it sets off when a player eats any bread, even if it's not evil bread. Does anyone have a fix for this?
Now I remember why I use the execute. Granted the double execute is not needed but putting two scores in the /effect target criteria will not trigger correctly multiplayer. I tested the following with more than one person. For some reason I needed to put the _min=1 criteria on the eatBread score search even though it only goes to a max of 1.
With scoreboard objectives, holdingevilBread(dummy), eatBread(stat.useitem.minecraft:bread)
Run the following on a clock in correct alignment:
Hello again!
Today I was trying to make an "Evil bread" that, when eaten, gives a player slowness. The system I set up was I did /scoreboard objectives add evilBread stat.useItem.minecraft.bread. Then, on a clock I have /effect @a[score_evilBread_min=1] minecraft:slowness 20 5 and /scoreboard players set @a[score_evilBread_min=1] evilBread 0. This works, when a player eats bread, it gives them slowness. Simple. But I need a way where if a player eats a bread named Evil Bread with a lore of "Eat this" it will give them slowness, but if they eat bread without this name and/or lore, nothing will happen. If anyone knows a way to do this, please put it down below. Thanks!
Hey I recently was thinking of a way to help you so I dont know if this will work but try this.
Before those command blocks setup a command block which will testfor the evilBread in an active slot of the players inventory.
/testfor @p {SelectedItemSlot:0,Inventory:[{Slot:0b,tag:{display:{Name:"Evil Bread"}}}]}
Replace the selected slot of the player to yours choice.
Hey FreeMotion! Thanks for the idea, this should work for me.
No problem. Was glad to help!
Better way of doing this is by using the command that detects what the player is holding with the name you want.
Give a score(ebread) of about 3 to the player holding that named bread.
Have score(ebread) remove 1
Execute at player with stat.useItem.minecraft.bread(bread)
execute @a[score_bread=1] ~ ~ ~ execute @p[score_ebread_min=1] ~ ~ ~ effect @p slowness 20 5
set bread score back to 0
You'll just have to make sure command blocks are in correct alinement on clock and the ebread set score 3 is enough time to allow bread score to trigger and you should be good.
Guys, I already figured it out and used it
There is no need for an execute at all, much less need for a dual execute. As well, the targeting in that command is flawed due to the mix of target selectors; @a can target dead players but @p cannot, which can result in the wrong player receiving slowness. Even moreso it will exponentially increase in the number of targets since you're affecting all players twice in a row.
/effect itself has a target selector you can use. You can specify the scores with the "score" parameter inside that selector. Avoid using /execute when it is not necessary. /execute's main purpose is to change the origin of the command, which is not needed at all in this case. Misusing it will contribute to server lag due to the amount of commands being processed.
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/
Actually, I need some help.
So I have an objective called holdingevilBread. The command running for that is /scoreboard players set @a holdingevilBread 1 {SelectedItem:{id:"minecraft:bread",tag:{display:{Name:"Evil Bread",Lore:["Eat this"]}}}}
Then I have an objective called evilBread that has stat.useItem.minecraft.bread and the commands is /scoreboard players set @a[score_evilBread_min=1] evilBread 0 and
/effect @a[score_evilBread_min=1,score_holdingevilBread_min=1] minecraft:slowness. However, this last effect command doesn't work. Well, it does, but it sets off when a player eats any bread, even if it's not evil bread. Does anyone have a fix for this?
I had it working then it fails agian. Back to bug check.
Now I remember why I use the execute. Granted the double execute is not needed but putting two scores in the /effect target criteria will not trigger correctly multiplayer. I tested the following with more than one person. For some reason I needed to put the _min=1 criteria on the eatBread score search even though it only goes to a max of 1.
With scoreboard objectives, holdingevilBread(dummy), eatBread(stat.useitem.minecraft:bread)
Run the following on a clock in correct alignment:
/scoreboard players set @a holdingevilBread 2 {SelectedItem:{id:minecraft:bread,tag:{display:{Name:"Evil Bread"}}}}
/scoreboard players remove @a[score_holdingevilBread_min=1] holdingevilBread 1
/execute @a[score_holdingevilBread_min=1,score_eatBread_min=1] ~ ~ ~ effect @p[r=0] slowness 20 5
/scoreboard players set @a[score_eatBread_min=1] eatBread 0