Help to make entity spawn in a certain radius near the player

Started by DasenSenju on

Topic category: Help with Minecraft modding (Java Edition)

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Help to make entity spawn in a certain radius near the player

I am making a mod that is similar to "man in the fog" since that mod was also made in mcreator. My current issue is spawning conditions of my entity. I want to make it so that it spawns near the player in certain biomes but currently it is only spawning in those biomes and not near the player. I would love to have help with this!

I am not very experienced with spawn conditions so I would need some help visually.

If you can help I would greatly appreciate it!

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Natural spawn conditions…
Fri, 10/13/2023 - 15:29

Natural spawn conditions probably wouldn't work for this- you'd instead want to make a procedure that spawns the entity near the player on player update tick, under certain conditions. (This'll also give you much greater control over the specifics.) 

Essentially, you'd make a procedure with the player-tick-update global trigger that checks the player's conditions, (depending on when you want it to appear- if it's dark out, if they're low on health, if they're in a certain biome, if there's already one nearby, etc.) If they are, do a very low random chance check. (There's a 'do with 70% chance' procedure template. You want this to be much, much, much lower, since player this procedure is going to trigger twenty times per second.) 

If all of these pass, then you can spawn the entity with random offsets from the player's position. If it's on the surface, this is as easy as doing random numbers for x/z offset, and spawning the entity at world-surface-height. (Probably making sure it's a minimum distance away.) Configuring this to work underground is a bit trickier, but you essentially just also need to take y position and air/solid blocks into account. 

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Is there a way to make it so…
Fri, 10/13/2023 - 16:13

Is there a way to make it so that only 1 entity can exists in the word at a time?

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
...You could make a global…
Fri, 10/13/2023 - 16:17

...You could make a global variable that becomes true when the entity spawns, and false when it despawns, but there's always the risk that it somehow dies in a way that doesn't reset the variable, and then wouldn't be able to spawn again. If it's more that you just want one per player, you could just have it do a 'does entity of (type) exist in (radius)' check whenever it spawns, and set the radius really high, checking for your custom entity.

Joined Feb 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
i know this is an old post…
Sun, 03/31/2024 - 02:04

i know this is an old post but when i use the spawn entity block nothing happens