How do I add a radius syntax to gamerule commands in Minecraft?

I was wondering how to add a radius to:/gamerule doMobspawning
false.
I've tried doing it like this: /gamerule doMobspawning[r=200]
false, but it doesn't seem to work.
Best Answer
You unfortunately can't set gamerules to a specific area- they are global and apply to every part of your world.
What you want to do is to set up a command block loop and run this command:
/kill @e[r=20,type=!Player]
20 is the radius.
But it will kill friendly mobs/horses too. Do this to avoid that:
Run this in chat once:
/scoreboard objectives add blackList dummy
then make a redstone clock and add as much as (but must be enough to hold them all, so you need 14) command blocks you want to it, put one line on every command block:
/scoreboard players set @e blackList 1
/scoreboard players set @e[type=Player] blackList 0
/scoreboard players set @e[type=ArmorStand] blackList 0
/scoreboard players set @e[type=EntityHorse] blackList 0
/scoreboard players set @e[type=Villager] blackList 0
/scoreboard players set @e[type=Bat] blackList 0
/scoreboard players set @e[type=Cow] blackList 0
/scoreboard players set @e[type=Pig] blackList 0
/scoreboard players set @e[type=Rabbit] blackList 0
/scoreboard players set @e[type=Villager] blackList 0
/scoreboard players set @e[type=Chicken] blackList 0
/scoreboard players set @e[type=Squid] blackList 0
/scoreboard players set @e[type=Sheep] blackList 0
/kill @e[score_blackList_min = 1, r = 20]
Thanks to @user3878893 for providing the simpler answer.
Thanks to @ModDL for covering the long answer.
Pictures about "How do I add a radius syntax to gamerule commands in Minecraft?"



How do you do radius commands?
When in-game, game rules can be changed using the /gamerule command, using the syntax /gamerule <rule> [<value>] , where <rule> is the name of the game rule and <value> is an allowed value, which depends on the type of the game rule.How do you write Gamerule in Minecraft?
A spawn radius of 1 will ensure all players spawn at the same place each time. The default is set as 10 blocks. Please note that this command is case sensitive. That's it! No more spawn kills when new players join your server!What is Gamerule spawn radius in Minecraft?
doMobSpawning - Whether mobs should naturally spawn. doTileDrops - Whether blocks should have drops.Minecraft 1.16 - All Gamerules
More answers regarding how do I add a radius syntax to gamerule commands in Minecraft?
Answer 2
You can't. There are other things that you can do at a more localized level, but /gamerule
s are global and effect the entire world.
But if preventing mob spawning in a particular area is what you want, you can set up a kill
command on a fast (preferably 20Hz) clock. For instance, you would use the command kill @e[0,64,0,200,type=Zombie]
to continuously kill any zombie that spawns or wanders into the area that's within 200 blocks of [0,0].
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Brett Jordan, Brett Jordan, Anna Shvets, Klaus Nielsen