How to make mob spawn in a custom feature

Started by pichugirl11 on

Topic category: Help with modding (Java Edition)

Last seen on 07:10, 8. Jun 2024
Joined Mar 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to make mob spawn in a custom feature

I want to make my mob spawn exclusively inside of a custom geode i've made using the preset geode feature. i've tried a lot of things but have failed at all my attempts, would anyone smarter at modding like to give me some much needed advice?

Last seen on 18:38, 16. Jul 2024
Joined Jan 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I have a mob that spawns…
Thu, 07/11/2024 - 04:44

I have a mob that spawns exclusively in one of my custom structures, but I use a big of a hack job way of getting it to work. I don't think this would work too well for what I'm imagining you're trying to do, but it's worth trying...

I have a custom structure generate in one specific biome. I have a mob set to spawn there, with a high spawn weight.
However, I have a spawn condition. The game has to search the area it's attempting to spawn the mob in and check for certain blocks to see if the structure is in that location.
I also run a couple checks to make sure that if you're simply trying to spawn the mob from a spawn egg, or via command, close enough to yourself, it works without checking for the structure- as well as making sure that the mob doesn't attempt to spawn too close to the player after the procedure looks at a different elevation to the height the game originally tried spawning the mob at...
It's a little messy, but it works well enough for what I wanted to do.


Here's the on initial entity spawn procedure. It's almost identical. This gets a random height value from 0-50 and then starts checking every block down from that position, looking for the correct block to spawn the mob on. If it finds it, it immediately teleports the mob there when it spawns. If it doesn't, it teleports the mob outside of the world. (My custom dimension cuts off at y=0, so -16 is out of the world there.)


Depending on how you have things set up and what you're trying to achieve, you could try adding a unique block to your structure, disguised as some other block, but actually acts as a spawner. Not a mob spawner in the traditional sense, though. You could have a block set to tick randomly and use a procedure that rarely spawns the entity you want on or around the block. Just make sure to have a 'for each entity in range' block in the procedure and count how many entities there already are before you spawn another one, so you don't have geodes spawn too many.