6

Is there a way to spawn a usually passive mob (like a cow) hostile?

More specifically, I want to summon an Iron Golem that will automatically lock onto a player and attack them. I'm not a master at this kind of "advanced command block programming", so I'll leave it up to you guys... any ideas?

4

As of 1.9, if a mob is the passenger of another mob, it will control the pathfinding of its host. For example, if you had a zombie riding an iron golem, the iron golem will chase the player due to the zombie targeting the player.

However, the iron golem will still attempt to attack enemy mobs. While normally you can circumvent this by adding both mobs to the same team, which is intended to prevent hostility between the two, this does not work with iron golems while an enemy is its passenger. Even setting the iron golem's generic.followRange attribute to 0 will not prevent it from trying to attack the enemy mob riding it.

What you can use instead is a mob that the golem will not attack but will still target players, being a creeper. You can give the creeper a Fuse value of 32767 to make it take roughly 27 minutes before it explodes, which resets if the player moves out of range, just to ensure it does not explode.

An example command that summons an iron golem being controlled by a creeper:

/summon VillagerGolem ~ ~1 ~ {Passengers:[{id:"Creeper",Silent:1b,Invulnerable:1b,Fuse:32767,ActiveEffects:[{Id:14,Duration:2147483647,ShowParticles:0b}]}]}

Unfortunately this type of control does not include attacking, so the golem will simply get as close to the player as possible while its rider attempts to attack (which, in this case, it cannot). You could try to simulate attacking by using the /effect command around the golem:

/execute @e[type=VillagerGolem] ~ ~ ~ /effect @a[r=1] minecraft:instant_damage
  • 1
    Right, well I'm not using 1.9 (yet), and I'm guessing this way wouldnt work in 1.8.8. Your second suggestion is a good idea though, ill see what I can do! – SMILIECHICKEN Dec 30 '15 at 2:38
  • @SMILIECHICKEN Yes, there isnt a "Passengers" tag below 1.9(or 1.9 snapshots), but the "Passengers" tag is a replacement for the "Riding" tag, which is exactly the same, except, you have to change the order of entities (Zombie riding a Golem = Golem with a Zombie as passenger) Also, below 1.9, the bottom-most entity controls the movement. So take a cow or whatever and make it ride an invisible (and maybe silent) baby zombie, using the riding tag. – Mystery Jan 5 '16 at 22:57
0

Unfortunately this is impossible without having to dive into minecrafts coding. However with your iron golem problem there is a way, its just a pain to do. According to the wikia iron golems created by the player will not harm the player who built it. Iron golems that have spawned naturally, such as in villages, will go aggro if the player hits villagers or the iron golem itself.

So in theory, you could take the iron golem from a village and hit it, that would make it aggro. Unfortunately that is the only way i can think of that you could possibly do something like that.

In conclusion. No, there isn't a well known way of turning a passive mob into a hostile mob using command blocks. Sorry.

Good luck with whatever your doing though!

  • I tried this with summoning an iron golem via command block, and when I attacked it, it aggro'd on to me and attacked me. However, even the golems attack animation went through, I didnt take any damage... and I dont exactly feel like hunting down an iron golem from some village, especially since I have villages disabled on my superflat :) – SMILIECHICKEN Dec 30 '15 at 2:41
  • Yeah sorry, there is nothing else I can really suggest at the moment. :P Stuff like this can be a real pain. – TooLazyToLogIn Dec 30 '15 at 5:28
-1

You need to make a new team via /scoreboard, and then go to this site to create an iron golem summon command that will make the iron golem target you.

  • 1
    Why can't you just write a command instead of just redirecting them to another site? – Vemonus Sep 21 '17 at 15:56

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.