5

I am making a wireworld cellular automata, and everything is going well except for one thing: placing "wire" cells on both sides of an "empty" cell and filling the gap afterwards causes TWO "WireCell" entities instead of one because of the flood-fill method that I am using. How can I remove all but one entity from each block?

  • I'm pretty sure you would have to do a command per all types of entities. If that's not a problem, you can have a scoreboard and use (once) scoreboard players add @r[type=<ENTITY_TYPE>] <SCOREBOARD_NAME> 1 and kill @e[type=<ENTITY_TYPE>,score_<SCOREBOARD_NAME>=0] or any other killing technique. – deprilula28 May 9 '16 at 17:58
  • With a little bit of tweaking, I managed to make that work (I added executions with r=0, and some tags). thanks! – zane49er May 9 '16 at 20:02
  • @zane49er If you want, you can post an answer to your own question and accept it. You can gain more reputation, and help others who have the same problem get to the answer quick! :) – APCoding May 14 '16 at 15:48
2

you said you found out how to do it, but I'll just give this answer to show other people how to do it,

I did it in three command blocks (five if you include the two command blocks I used to make it loop, could make it loop with only one extra though)

first you'll need a scoreboard objective

/scoreboard objectives add near dummy

first set all of the sheep's scores to zero

/scoreboard players set @e[type=Sheep] near 0

this command makes each sheep in a stack add one to one other sheep in the stack, basically it counts how many is in each stack

/execute @e[type=Sheep,r=50] ~ ~ ~ /execute @e[r=0,type=Sheep,c=1] ~ ~ ~ /scoreboard players add @e[r=1,type=Sheep] near 1

then you kill one sheep that has a score that is more then two

/execute @e[type=Sheep,c=1,score_near_min=2] ~ ~ ~ /kill @e[r=0,c=1,type=Sheep]

loop the above three commands, until all sheep have a score of 1

note: I used the scoreboard objective "near" but you can use what ever you want, as long as you change the name in each command

same with the entity type, just make sure you get every time it says type=Sheep, I counted six occurrences

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.