This command will prevent your nighttime mobs from burning in the harsh daylight (this example is Zombies, you can change the mob).
The command is quite long, and I will explain each component below for those that are interested. I have created it below for you to freely copy it
into your command block (set to Repeat and Always Active for best results):
execute if entity @e[name="Zombie"] run replaceitem entity @e[name="Zombie"] armor.head stone_button{ArmorDropChances:[0.0f,0.0f,0.0f,0.0f]}
Firstly, the "execute" command identifies whether there are Zombies currently spawned on the map. Mobs will only spawn within the proximity of
the player, so as long as a palyer is near a possible spawn location, the command will work.
If a zombie is located, the "run replaceitem" command gives all zombies a hat with "armor.head stone_button". This hat will protect them from the sunlight, and still allows them to be set on fire or burned in lava. So the player doesn't see mobs wearing helmets or blocks, I have replaced the hat
with a stone button to make it look more natural (you can change this into any existing block/armor piece).
Finally, I didn't want players to pick up stone buttons after killing the mob, as it is now droppable. I simply used the "ArmorDropChances" command
to reduce the button's drop chance to 0% (sadly, this reduces the chance of mobs dropping any armor).
I hope this helps you in creating your own custom maps or other commands!
This command will prevent your nighttime mobs from burning in the harsh daylight (this example is Zombies, you can change the mob).
The command is quite long, and I will explain each component below for those that are interested. I have created it below for you to freely copy it
into your command block (set to Repeat and Always Active for best results):
Firstly, the "execute" command identifies whether there are Zombies currently spawned on the map. Mobs will only spawn within the proximity of
the player, so as long as a palyer is near a possible spawn location, the command will work.
If a zombie is located, the "run replaceitem" command gives all zombies a hat with "armor.head stone_button". This hat will protect them from the sunlight, and still allows them to be set on fire or burned in lava. So the player doesn't see mobs wearing helmets or blocks, I have replaced the hat
with a stone button to make it look more natural (you can change this into any existing block/armor piece).
Finally, I didn't want players to pick up stone buttons after killing the mob, as it is now droppable. I simply used the "ArmorDropChances" command
to reduce the button's drop chance to 0% (sadly, this reduces the chance of mobs dropping any armor).
I hope this helps you in creating your own custom maps or other commands!
Thanks,
Flipz
That is indeed a good idea. The only problem here is that my Zombie will not be able to wear a cool hat anymore !
I think it is doable to only place a button on the zombies who are not wearing any thing though...
It doesn't work.
If you're using this in 1.17, /replaceitem got changed into /item. This is the new syntax (without the execute):