How do i make mobs to only spawn in caves?

Started by Callofmc on

Topic category: Help with Minecraft modding (Java Edition)

Active 6 years ago
Joined Jun 2019
Points:
677

User statistics:

  • Modifications: 0
  • Forum topics: 2
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 3
How do i make mobs to only spawn in caves?

I have this mob i want to only spawn underground/caves however i do not see a way to do it now i could be blind but i don't see a way to do it

Active 4 months ago
Joined May 2014
Points:
1033

User statistics:

  • Modifications: 3
  • Forum topics: 24
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 321
A safe way to do this would…
Wed, 06/12/2019 - 18:02

A safe way to do this would be to make the entity spawn below y = 50 or so. This is below sea level so they will not spawn above ground.

Active 6 years ago
Joined Jun 2019
Points:
677

User statistics:

  • Modifications: 0
  • Forum topics: 2
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 3
Where is this at, thank you
Thu, 06/20/2019 - 18:44

Where is this at, thank you

Active 5 years ago
Joined Jul 2019
Points:
673

User statistics:

  • Modifications: 0
  • Forum topics: 2
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 1
rmsandegs, but how to do it?
Mon, 02/17/2020 - 13:05

rmsandegs, but how to do it?

Active 5 years ago
Joined Jun 2020
Points:
657

User statistics:

  • Modifications: 0
  • Forum topics: 4
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 13
How do we make it spawn…
Thu, 06/25/2020 - 08:56

How do we make it spawn below y=50 ??

 

Active 4 months ago
Joined May 2014
Points:
1033

User statistics:

  • Modifications: 3
  • Forum topics: 24
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 321
Dang, this is dedication. I…
Thu, 06/25/2020 - 16:44

Dang, this is dedication. I didn't get email notifications for the other ones but I did for that last one.

Anyways, create a procedure that triggers "on entity initial spawn" that checks "if y >= 50" if that is true, then your mob is above the ground, so despawn it using the "despawn mob" block.

Active 4 months ago
Joined May 2014
Points:
1033

User statistics:

  • Modifications: 3
  • Forum topics: 24
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 321
Oh, and you can also check…
Thu, 06/25/2020 - 16:46

Oh, and you can also check if "get block at x y z = CAVE_AIR", which is a special kind of air that only spawns in caves underground. 

Active 5 years ago
Joined Jun 2020
Points:
657

User statistics:

  • Modifications: 0
  • Forum topics: 4
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 13
rmsandegs Thx a lot dude   
Fri, 06/26/2020 - 11:58

rmsandegs Thx a lot dude 

 

Active 5 years ago
Joined Jun 2020
Points:
657

User statistics:

  • Modifications: 0
  • Forum topics: 4
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 13
rmsandegs can you teach me…
Fri, 06/26/2020 - 17:03

rmsandegs can you teach me how to do everything you just explained (i just started MCreator 3 days ago and im a huge noob sorry)

Active 4 months ago
Joined May 2014
Points:
1033

User statistics:

  • Modifications: 3
  • Forum topics: 24
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 321
Sure, so in the "triggers"…
Sun, 06/28/2020 - 18:34

Sure, so in the "triggers" section of your entity, create a procedure in the "initial entity spawn" section that detects if

A. Y is less than 50 or so (Y can be found in the Minecraft section of the procedure menu), or

B. Block at x, y, z == Cave Air

I suggest B because it is a little more versatile, for example ground level is much higher in extreme hills than, say, the ocean. So a hard value of y = 50 might not be ideal for a "one-size-fits-all" solution.

https://imgur.com/a/KkYErQf

Active 5 years ago
Joined Jun 2020
Points:
636

User statistics:

  • Modifications: 0
  • Forum topics: 1
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 3
Hey,  I recently came across…
Mon, 06/29/2020 - 17:16

Hey, 

I recently came across this post and honestly Option B worked amazingly, however, is there a way to make it so if the mob is deliberately spawned (Spawn Egg or command) that they don't despawn? So this way they can only spawn naturally in caves but can be spawned elsewhere (kind of like bats)

Active 4 months ago
Joined May 2014
Points:
1033

User statistics:

  • Modifications: 3
  • Forum topics: 24
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 321
Hmm... This is an…
Mon, 06/29/2020 - 17:51

Hmm... This is an interesting one. With commands, you can force a mob to never despawn by using the NBT tag {PersistenceRequired:1}. This works for all mobs.

As for spawn eggs, though, the only way I could see this being done is to detect a player within 5 blocks of where the entity spawns (this procedure block is only available in the 2020.4 snapshots), then setting the PersistenceRequired tag to 1 using the /data merge command in the "execute command" procedure block. This shouldn't have any false positives because mobs are programmed to spawn a minimum of 20 blocks away from any players.

Active 5 years ago
Joined Jun 2020
Points:
636

User statistics:

  • Modifications: 0
  • Forum topics: 1
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 3
Alright, I'm going to try…
Mon, 06/29/2020 - 18:42

Alright, I'm going to try this, thank you!

Also as someone who is new to modding and Mcreator, I just want to ask will I be able to update my current project to the latest updates, and will switching to newer snapshots mess stuff up?

Thanks again!

Active 4 months ago
Joined May 2014
Points:
1033

User statistics:

  • Modifications: 3
  • Forum topics: 24
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 321
I would always back up you…
Mon, 06/29/2020 - 18:48

I would always back up you project before updating to snapshots, I learned that the hard way :p

So far, I've been using 2020.4 since the first snapshot launched and I haven't had problems, but you never know.

Active 4 years ago
Joined Jan 2021
Points:
607

User statistics:

  • Modifications: 0
  • Forum topics: 1
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 2
Hello! I have problems with…
Fri, 01/22/2021 - 15:37

Hello! I have problems with the construction of the procedure itself, could you attach a screenshot, option B please?