0

In the map I'm making, Pvt. Rabbit (You) must try not to crush any planted carrots underfoot. If he does, I want it to be detected and then +1 to a scoreboard counting the number of times he has done it. My question is what is what would be the correct command to detect if he has crushed any planted carrots. At first I tried:

 execute @p[r=1000] ~ ~ ~ detect ~ ~0 ~ minecraft:carrot say ... 

I won't use the say command once I've figured it out, but now I'll use that. It says that "there is no such block with name minecraft:carrot" which I completely get. Any Ideas about what to do?

  • Would checking for a dropped carrot item at the player's feet be enough, or are there other situations where carrots may be dropped that you want to avoid detecting? – SirBenet Jan 23 '16 at 19:24
  • No, there wouldnt be any other carrot dropped throughout the map. It is just for that one situation. – SMILIECHICKEN Jan 23 '16 at 19:55
2

First, create a dummy objective that we'll use to track items that are carrots:

/scoreboard objectives add isCarrot dummy

Then, on a clock, in this order:

1. Set that objective to 1 for all items that are carrots:

scoreboard players set @e[type=Item] isCarrot 1 {Item:{id:"minecraft:carrot"}}

2. Have all carrots add a point to the nearest player:

execute @e[type=Item,score_isCarrot_min=1] ~ ~ ~ scoreboard players add @p carrotsCrushed 1

3. And then kill all carrot items:

kill @e[type=Item,score_isCarrot_min=1]
| improve this answer | |
0

You could detect whether the player is standing on dirt. A simple command to do that would be:

execute @p ~ ~-1 ~ testforblock ~ ~ ~ dirt

If they crush the crop, it turns the farmland under them into dirt, and the command block will output true.

| improve this answer | |
  • I guess I should have made the question a little clearer. You know when you fall down from a height onto crops they break, and that it what I what to try to detect. In my command above, I was trying to test for the actual dropped item 'minecraft:carrot' – SMILIECHICKEN Jan 23 '16 at 18:48
  • I don't think there's a way to detect dropped items of a particular type. I think I know another way to do this though, I'll work on it. – FlyingPiMonster Jan 23 '16 at 19:08
  • @kittycat3141 You can detect an entity based on its NBT data with /testfor or apply a label with /scoreboard to target the item afterwards. Example: /scoreboard players set @e[type=Item] OBJ 1 {Item:{id:"minecraft:carrot"}} – Skylinerw Jan 23 '16 at 19:25
  • @Skylinerw For some reason I thought that was impossible. Good to know. – FlyingPiMonster Jan 23 '16 at 19:29
  • Thanks @kittycat3141! It works well, but I dont want the player to be able to go back over the dirt after the crop has been crushed. Is there anyway to fix that? At first I tried using [ /execute @e[type=Carrots] ~ ~ ~ detect ~ ~ ~ minecraft:carrots setblock ~ ~ ~ carrots ] but [ Entity type 'carrots' is invalid ] Any ideas? – SMILIECHICKEN Jan 23 '16 at 20:08

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.