Jump to content

[SOLVED] Removing Vanilla Spawns


Recommended Posts



So I figured out how to do this.  It's actually pretty simple.  First, create a new class anywhere in your mod, and call it "EntityJoinWorldHandler" or "SpawnHandler" or "SpawnEvent" or whatever you want, as long as it makes sense to you.  The class should look like this:


package your.own.package.here;

import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntitySpider;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;

public class EntityJoinWorldHandler {
public void onEntitySpawn(EntityJoinWorldEvent event)
	if(event.entity instanceof EntitySkeleton || event.entity instanceof EntityZombie || event.entity instanceof EntitySpider) {


Note: "onEntitySpawn()" can be named whatever you want, too.  The method name does not actually matter.


The class above sets up an event listener that listens for EntityJoinWorldEvent events, which means anytime an entity (like a mob) is spawned into the world, this event triggers.  The if statement within the class checks if the entity spawning is an EntitySkeleton, EntityZombie, or an EntitySpider, and if it's any of those, it cancels the event.  As a result, the mob doesn't spawn in.


But you're not done yet.  You still have to register this listener with your mod!  To do that, go into your mod's base class and, in the load() method (under @Init), add this line:


MinecraftForge.EVENT_BUS.register(new EntityJoinWorldHandler());


Note: "EntityJoinWorldHandler()" should be whatever you named the class above.  Eclipse will probably ask you to import your new class into your base class.  And that's it!  When you run your mod, skeletons, zombies, and spiders will no longer spawn.


Now you can add your own mobs to replace them if you like, or do whatever else your mod needs.  :)  Ciao!


Original post below:


So in net.minecraft.world.SpawnerAnimals.java there's an array that, I'm guessing, tells the game what mobs to spawn at night.  The array is:


/** An array of entity classes that spawn at night. */
    protected static final Class[] nightSpawnEntities = new Class[] {EntitySpider.class, EntityZombie.class, EntitySkeleton.class};


Is there a way, without editing the base classes, to access and modify this array from within my mod?  I do something similar with the Block.blocksList[] array by removing vanilla blocks from it and registering my own blocks in their places.  Can I do something like that here, to modify this nightSpawnEntities array?


Or, is there a different way to remove vanilla spawns that I haven't considered yet?

Link to comment
Share on other sites

You *might* try using events to cancel the spawns. It'll certainly be more ugly, but at least you wouldn't have to use a coremod.


Thanks for the response.  :)  I actually already resolved this on my own (I feel the need to mention that because it's significant for me!) and indeed I did do it with an event.  I'll update the original post with how to do it so others who might be looking to do this can hopefully find a resolution.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.