I like the /gamerule
command, but how would I make it so only zombies or ghasts don't spawn? Ghasts are really annoying… I'm sure you understand.
Minecraft – How to prevent certain mobs from spawning in vanilla minecraft
minecraft-java-edition
Related Topic
- Minecraft – How to prevent all hostile mobs from spawning except for skeletons
- Minecraft – How to make your minecraft not spawn hostile mobs but spawning friendly mobs and still get hungry
- Minecraft – Stopping bats from spawning in vanilla minecraft–Without killing them
- Minecraft – way to effectively prevent phantoms from spawning (1.14)
Best Answer
There is no vanilla game rule that can disable zombie and ghast spawning, but you can achieve something similar with a custom game rule and a killing clock.
The kill clock
First, set up a fast clock that triggers the following commands to teleport all Zombies and Ghasts into the void, killing them without them dropping any loot (This will prevent you from ever making Regeneration Potions).
Setting up a custom gamerule
Now, if you want to be able to toggle this, we need to create a custom gamerule, by running
As of now, this does absolutely nothing. Let's get ourselves a dummy armorstand called
#handle
(replace however you like) and a dummy objective:Now create another clock to query the value of the custom GameRule noZombieOrGhast
Make the command block output the queried result to the armor stand (x y z is the coordinates for the last command block:
Finally, place a third command block into this clock to test for the armor stand with the score of 0:
Put a comparator on this last command block, and make the output disable the killing clock.
Set the custom gamerule to 0 or 1 to allow or disallow Zombie and Ghast spawning, respectively.