5

So I'm trying to make a system that will kill any mob that doesn't have a squid on it's head (I'm starting with zombies as once I figure it out for one mob I can easily add a different mob). So how I started was I made a scoreboard objective that I called nearSquid.

/scoreboard objectives add nearSquid dummy

Then I rigged up some repeating/chain command blocks together and had them run these commands.

/execute @e[type=Zombie] ~ ~ ~ /scoreboard players set @e[type=Squid,r=2] nearSquid 1

/execute @e[type=Squid] ~ ~ ~ /scoreboard players set @e[type=Zombie,r=2] nearSquid 1

Therefore any zombies (that are near a squid) and squids (that are near zombies) get a score of 1. Now my problem is that how do I make the zombie/squid get a score of 0 when they aren't near the other one.

Now I know that this system has the flaw of if zombies are bunched close together they may be in the radius and be safe until the squid/zombie moves away. So if you have a different system that can fix this flaw I'd be happy to hear it. other wise how would I make the squids/zombies get a value of 0 when not near the other.

Hopefully I made myself clear. If not let me know and I'll will try to make it clearer.

2

In 1.9, the Passengers tag will hold a list of the entities riding a host (in which the riding stack is reversed from 1.8's Riding compound). You would first label the zombie as though they did not have a squid riding their head, and change their label if there actually was.

  1. Removing label from zombies by default first:

    /scoreboard players tag @e[type=Zombie,tag=hasSquid] remove hasSquid
    
  2. Adding label to zombies if squid is riding:

    /scoreboard players tag @e[type=Zombie,tag=!hasSquid] add hasSquid {Passengers:[{id:"Squid"}]}
    
  3. Example of a result, saying the names of zombie who did not have a squid riding them:

    /say @e[type=Zombie,tag=!hasSquid]
    

The opposite (giving the squid the label as well) is not feasible to do perfectly accurately in 1.9. You would have to rely on setting the score of the nearest squid to the zombie.

However, since only squids that do not have the label are being targeted, there will at least always be the same number of squids with the label as there are zombies. It does not necessarily mean that the squids with the label are those that are riding a zombie.

  1. Removing label from squids by default.

    /scoreboard players tag @e[type=Squid,tag=hasSquid] remove hasSquid
    
  2. Adding label to the nearest squids without labels.

    /execute @e[type=Zombie,tag=hasSquid] ~ ~ ~ /scoreboard players tag @e[type=Squid,tag=!hasSquid,c=1] add hasSquid
    

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.