3

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.

2
  • 2
    You can either have all mobs off or all mobs on. You can't specific with just the gamrule.
    – Aaron128l
    Commented May 20, 2015 at 23:16
  • You can make it so ghasts dont do environment damage (but that also applies to creepers and TNT I believe) as a mid-way if that is the issue.
    – James
    Commented May 21, 2015 at 0:02

3 Answers 3

6

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).

/tp @e[type=Zombie] ~ ~-600 ~
/tp @e[type=Ghast] ~ ~-600 ~

Setting up a custom gamerule

Now, if you want to be able to toggle this, we need to create a custom gamerule, by running

/gamerule noZombieOrGhast 1

As of now, this does absolutely nothing. Let's get ourselves a dummy armorstand called #handle (replace however you like) and a dummy objective:

/summon ArmorStand ~ ~ ~ {CustomName:#handle,Invulnerable:1,NoGravity:1,Marker:1,Invisible:1}
/scoreboard objectives add noZombieOrGhast dummy

Now create another clock to query the value of the custom GameRule noZombieOrGhast

/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:

/stats block x y z set QueryResult @e[name=#handle] noZombieOrGhast

Finally, place a third command block into this clock to test for the armor stand with the score of 0:

/testfor @e[name=#handle,score_noZombieOrGhast=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.

/gamerule noZombieOrGhast 0
/gamerule noZombieOrGhast 1
0
0

You can set up a simple redstone timer, and use the command block (obtained by /give @p command_block) and use the command /kill @e [type=undesiredMobNameHere] if set on a timer, the mob will die instantly after spawning.

0

The easiest and best way to do this is get a command block and set it to repeat, then do /tp @e[MobName] ~ ~-600 ~ so you don't have to build a redstone clock and don't have to see mob drops all around! Hope this helped! Oh and make sure to do /gamerule commandBlockOutput false so you don't get text all over your chat! :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.