0

I am making a game on Minecraft when someone starts holding one item. If they get hit by someone they lose the item, and it goes on until a timer finishes. How can I do this? I am still new to command blocks, so any help will be appreciated.

3
  • 4
    Have you made any attempt to solve this yourself? Arqade works better when askers show effort to solve their own problems; we see that you have a problem you've worked on, and answerers respond to that. You also get a more specific answer that's tailored exactly to the part you're stuck, and Arqade gets a very specific question. Everybody wins!
    – Frank
    Jan 27, 2016 at 12:53
  • 1
    The problem is, I don't know where to get started.
    – Miko
    Jan 27, 2016 at 19:41
  • That's where a little bit of research comes in. You don't have to solve it yourself, but an effort to do so goes a very long way.
    – Frank
    Jan 27, 2016 at 22:47

2 Answers 2

1

You could have them via command blocks equip a piece of armour with half a hitpoint on it, so when they get hit the armour breaks, this could trigger the "clear" command to remove the item, and then spawn @players feet the item in question

1

You can delete the item there holding if they get it, and you can make them drop the item if you know what item there holding. To do this you need a scoreboard objective testing for when they get hit,

/scoreboard objectives add damage stat.damageTaken

Then in command block do,

/testfor @a[score_damage_min=1]

Then a comparator coming out of that into a command block do,

/replaceitem entity @a slot.weapon.mainhand air

Then with a repeater coming out of that into a command block,

/scoreboard players reset @a damage

Though if you know what item there holding add before the scoreboard reset do,

/execute @a[score_damage_min=1] ~ ~ ~ /summon Item ~ ~ ~ {PickupDelay:60s,Item:{id:"minecraft:grass"},Motion:[0.2,0.5,0.2]}

And replace "grass" in minecraft:grass with the item you want dropped.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .