only cancel natural entity spawns

Started by willmod4food on

Topic category: Help with Minecraft modding (Java Edition)

Joined Nov 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
only cancel natural entity spawns

I made a sort of infected version of a cow and I want it to spawn instead of cows naturally.

I have sort of pulled it off with a procedure that's called on the "Entity Spawns" global trigger, and it checks if the entity is a cow and if it is it spawns the infected cow and cancels the event so the normal cow doesint spawn. But it does this when a cow spawns in ANY way but I want you to be able to spawn normal cows from eggs and mob spawners.

I only want to replace the cow when it is spawned naturally by the world. 

Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
you can use this custom code…
Fri, 11/07/2025 - 09:07

you can use this custom code snippet,

entity instanceof Mob _mob && _mob.getSpawnType() == EntitySpawnReason.NATURAL

 

this is for NeoForge 1.21.8. If you're on a different version, just say so and I'll figure it out