TransWikia.com

Disable mob spawn in a specific area of a multiplayer map

Arqade Asked by user185350 on February 16, 2021

I run a private server for my friends, and want to make a specific area mob-safe, without placing any block or light it. Changing the global difficulty or mob-spawning server property with command block is not an option: even if somebody is insed the area (enterieur of a huge building, actually), I need the mob spawning on the rest of the map work normally.
Changing the biom to mushroom island is also not very good, because it is in the middle of a huge desert, and I want weather to work the same as its surroundings (ie. the rest of the desert).

Is there any way to do this, via command block, map edition, or maybe modding, scripting, etc.?

One Answer

This doesn't disable spawning, exactly, but it will kill all mobs within a certain radius. First, you have to create a team for your friends and you to stop yourselves getting killed when you enter that location. So, run a repeating command block with this command:

/kill @e[type=!Player,r=RADIUS]

Replace RADIUS with the amount of blocks you want the command block to check for in each direction. For example, if you had a 5x5x5 room, and the command block was in the center of the room, your radius would be two.

So, now, whenever mobs that are not players spawn in that area, it'll kill them.

However, mobs count as both hostile ones (like creepers) and docile ones (like chickens). If you, for example, want sheep to survive in that area, change the command to this:

/kill @e[type=!Player,type=!Sheep,r=RADIUS]

So now, the command block will allow sheep to spawn in that area. If you wanted to add a pig, do the same for the entity type Pig:

/kill @e[type=!Player,type=!Sheep,type=!Pig,r=RADIUS]

And so on.

If the command block output in the chat is getting annoying, type this into the chat, not the command block:

/gamerule commandBlockOutput false

Hope this helps!

Answered by rappatic on February 16, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP