3

Some of the people on my Minecraft server want to be able to explore caves etc on peaceful mode, and while I don't have a problem with turning the server to peaceful once in a while, it may become an issue once people have farms that use hostile mobs (i.e. iron farms).

Ideally, I would like to have a command or mod which stops hostile mobs from attacking players but still allow them to spawn normally. Howwever, I would also be okay with just preventing new hostile mobs from spawning while that command/mod is enabled.

I also need to be able to switch it on and off, since most of the time we like playing on normal difficulty.

I know I could make a mob switch, but I'd prefer something a little easier.

3 Answers 3

3

There is no way to explicitly disable hostile mobs via a single command...

...but you can;

  1. ...set up a datapack to either kill or teleport into the void a hostile mob while a specific scoreboard value is set,
  2. ...set up a mob switch, as you mention,
  3. ...disable all mobspawns with gamerule doMobSpawning.
1

Another option in addition to those above. If you have access to the server folder, you can find there a "server.properties" file, which includes.. properties of the server. There is a property called "spawn-monsters", which by default is set to true, changing it to false should disable hostile mobs from spawning naturally.

0

This might not be exactly what you asked for, but it is the best I've thought of that wasn't already mentioned. You can use the invisibility effect to greatly reduce the detection radius of mobs.

effect give @a invisibility infinite

# To get rid of the effect when you are done.
effect clear @a invisibility

This gives all players currently online infinite invisibility. While this does not completely prevent mobs from attacking you, it reduces the detection radius. (You can further fine tune who this applies to using the /effect command; read more on the wiki.

Mobs do not attack or sense the player until the player is a lot closer than normal.

  • A player with no armor can be detected at 7% of the usual detection distance.
  • Each piece of armor increases this by another 17.5% of the usual distance. Full armor thus results in a 70% detection range.
  • After detecting the player, a mob continues to follow as if the player is visible.

The following methods of reducing mob detection can stack with Invisibility:

  • Sneaking reduces the detection range to 80% of the usual.
  • Wearing the corresponding mob head reduces the detection range of skeletons, zombies, creepers, and piglins to 50% of usual, although mob head does count as an armor piece. Wearing a mob head with Invisibility effect results in a larger detection range compared to having just the effect.

So for the best results, wear no armor and avoid mobs, and mobs will not notice you until you are much, much closer than usual.

For your convenience, I have placed the detection radius of a couple mobs commonly found in caves below.

Mob Original Detection Radius DR With Invisibility (ODR*.07)
Spider, Skeleton, Creeper 16 Blocks 1.12
Zombie 35 Blocks (only 16 in BE)* 2.45
Cave Spider (Not on the wiki page, but just avoid the spawners)

*The zombie's detection radius depends on the target. This value is for when chasing players.

In summary, with invisibility and while wearing no armor, just stay at least 3 blocks away from all mobs and you will not be targeted.

2
  • To whoever downvoted: I'm not sure why you would downvote? Is something missing from this answer? OP was asking "Ideally, I would like to have a command or mod which stops hostile mobs from attacking players but still allow them to spawn normally," and having invis does indeed prevent them from attacking unless you get very close to them, which is relatively easy when exploring caves. Also, downvoting a question without saying why is unlikely to cause the question to improve.
    – AdamRaichu
    Commented Feb 3 at 19:43
  • In short: I can't improve the question if I don't know why it's bad; please explain why when you downvote an answer.
    – AdamRaichu
    Commented Feb 3 at 19:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .