0

So far I have this...

/scoreboard objectives add CrimDeath deathCount
/scoreboard objectives add CrimRespawn dummy

/give CrimsonCreates carrot_on_a_stick{display:{Name:"[{\"text\":\"Dash Attack\"}]"},Enchantments:[{id:"binding_curse",lvl:1},{id:"vanishing_curse",lvl:1}]} 1

/execute as @e[name=CrimsonCreates,scores={CrimRespawn=1..}] run replaceitem entity CrimsonCreates weapon.offhand carrot_on_a_stick{display:{Name:"[{\"text\":\"Dash Attack\"}]"},Enchantments:[{id:"binding_curse",lvl:1},{id:"vanishing_curse",lvl:1}]} 1
/execute as @e[name=CrimsonCreates,scores={CrimDeath=1..}] run scoreboard players add CrimsonCreates CrimRespawn
/scoreboard players reset @a[scores={CrimDeath=2..}] CrimDeath
/scoreboard players reset @a[scores={CrimRespawn=1..}] CrimRespawn

I tried it and it doesn't work, I'm pretty sure it has to do with the scoreboard reset commands. If possible, can somebody explain what I am doing wrong or tell me a better way to do it?

  • Keeping the item on death would work, but I don't want to keep the whole inventory, and do not want to delete the items dropped by me. – user239801 Dec 5 '19 at 1:03
  • I recommend solving each problem separately. First try to test for the item, then try giving items on respawning, then combine the two. Also consider that people can wait before they click "respawn". – Fabian Röling Dec 5 '19 at 1:24
0

Here it is all the commands you'll need:

One time activation:

 /scoreboard objectives add death deathCount
 /scoreboard objectives add dummydeath dummy

Here it is the chain, connected to a Repeat command block:

/scoreboard players set @a[scores={death=1}] dummydeath 3
/scoreboard players set @a[scores={death=1}] death 0
/execute as @a[scores={dummydeath=1..},nbt=!{Inventory:[{id:"minecraft:carrot_on_a_stick",tag:{display:{Name:"[{\"text\":\"Dash Attack\"}]"},Enchantments:[{id:"binding_curse",lvl:1},{id:"vanishing_curse",lvl:1}]}}]}] run scoreboard players remove @s dummydeath 1
/execute as @a[scores={dummydeath=1..},nbt=!{Inventory:[{id:"minecraft:carrot_on_a_stick",tag:{display:{Name:"[{\"text\":\"Dash Attack\"}]"},Enchantments:[{id:"binding_curse",lvl:1},{id:"vanishing_curse",lvl:1}]}}]}] run give @s carrot_on_a_stick{display:{Name:"[{\"text\":\"Dash Attack\"}]"},Enchantments:[{id:"binding_curse",lvl:1},{id:"vanishing_curse",lvl:1}]} 1
/scoreboard players remove @a[scores={dummydeath=1}] dummydeath 1

So, the game works in an interesting way: When you die, you drop your items and, after clicking in the respawn button, the game will clear your inventory;
You can give items to dead players;

We can abuse this the following way:

  • When a player dies, give them a score of 3 to dummydeath .
  • If they don't have the Carrot on a stick, remove 1 from their dummydeath score.
  • If they don't have the Carrot on a stick, give it to them.

(At this point, the player will be in the death screen with a carrot on a stick in their hands and with a dummy score of 2; Once they click respawn, they will have their inventory cleared)

  • If they don't have the Carrot on a stick, again, remove 1 from their dummydeath score.
  • If they don't have the Carrot on a stick, give it to them.
  • Remove 1 score from dummydeath from every player that has 1 score of dummydeath

Interestingly enough, this can work for anything related to respawing players, if there wasn't already a solution to it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy