How to make an area unspawnable?

Started by Toma400 on

Topic category: Help with modding (Java Edition)

How to make an area unspawnable?

As in title: I want to make a block which disables spawning of any typical mob (zombie, skeleton, spider, creeper) when activated, and that should affect only specific area (let's say, 10 blocks in each direction of mentioned block).

It's important that I don't want to make world peaceful, nor despawn any mob that's already in that area (for example, zombie which I tagged to use in iron farm).


Is it possible to do that only by procedures/commands, or should I code something? And if so, can someone explain me the way, like you would explain to total noob?

I'd be so grateful, because I thought that "spawn disablers" would be great as an option for city builders <3

Last seen on 09:28, 16. May 2021
Joined May 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You could make a biome that…
Mon, 03/22/2021 - 10:52

You could make a biome that looks like any default biome and just make it so nothing spawns there, Test that first, but it might not work since I believe that default mob spawning at night is already coded into the game itself. I hope I could help :)

Sadly that's not what I…
Mon, 03/22/2021 - 19:13

Sadly that's not what I meant :< this would mean I have to redo whole game and all biome-adding mods, and that's still just making everything similar to mushroom biome, which is not great. Because I didn't want specific area to be "mobproof" by default, but only when this mob-blocking block is active.
So, you would decide whether it is affected by that or not - just like beacons with its effect. Whole idea came from lack of that mechanic in vanilla beacons, to be honest.

I imagine solution being that block despawning all entities with specific name (like, "Zombie"), so that would keep safe nametagged ones. But still I don't know how to make that affect specific area and how to trigger it correctly ("on client tick" block trigger would be cool, but that doesn't have "entity in area" dependency).

Last seen on 05:29, 31. Jan 2022
Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
if you know how to code,…
Tue, 03/23/2021 - 12:10

if you know how to code, block classes have a method called "canEntitySpawn" which determines if a type of entity can spawn on it. all mob's spawning process will call that method to check if spawning allowed.

The point is that I don't…
Tue, 03/23/2021 - 18:25

The point is that I don't know how to code, this is why I mention procedures mainly. But thanks for the tip, if I ever have time for learning such, I will know the way :) 

Last seen on 01:18, 28. Mar 2024
Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hello Toma400 Took some…
Tue, 03/23/2021 - 23:42

Hello Toma400

Took some research and some fiddling but i've managed to come up with something that just might be the solution.

> Here < is a small demonstration of how it works

> Here < is how it works

In the SS the parts highlighted in red are whats important.

In SS #2 - tag @e[tag=!Named,type=zombie,distance=..4] add Named - The 4 is a radius in which the mob will be tagged may need to lower it so you don't tag multiple mobs when using a Name Tag in-game.

In SS #4 - kill @e[type=zombie,distance=..8,tag=!Named] - The 8 is the radius in which mobs get killed around the block.

Just tested it, and it works…
Wed, 03/24/2021 - 15:36

Just tested it, and it works perfectly. With additional procedure I made activated and inactive version of block, and it's exactly as in your video. The only thing remaining about mob's loot still being dropped, but I can live with that, it can even help with mob farms in some sense.

My sir, I am just out of words, thanks for everything! You even gave me precise tutorial and video for that, that's such a generosity. Thanks for making my day, and glowing obsidian a purpose <3

Do you want to have your name in "thank you" list in mod's description? I will gladly do that, if you don't have anything against it ^^

Last seen on 01:18, 28. Mar 2024
Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
:D No problem, I just really…
Wed, 03/24/2021 - 22:05

:D No problem, I just really enjoy helping others, especially when I'm stuck on something myself. It also helps me because now I know how to do this as well. As for the thankyou in your mod list thats completely up to you :)