Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.8] How do I prevent passive mobs from generating with terrain? [SOLVED]

Featured Replies

Posted

I'm trying to prevent the passive mobs (cows, etc.) from generating with the terrain, although I'll have them spawnable through other means later. I've run in a circle trying to figure this out. So far the only way I've found to do it is through this:

 

@SubscribeEvent
    public void onEntitySpawn(EntityJoinWorldEvent event){
        if (event.entity instanceof EntityChicken || event.entity instanceof EntityCow || event.entity instanceof EntitySheep || event.entity instanceof EntityPig || event.entity instanceof EntityRabbit || event.entity instanceof EntityWolf || event.entity instanceof EntityOcelot){
            event.setCanceled(true);
        }
    }

 

But that disables the creatures from ever spawning at all from any source. I have also tried the following, to no effect:

 

@SubscribeEvent
    public void spawnAnimals(LivingSpawnEvent.CheckSpawn event){
        if (event.entity instanceof EntityChicken || event.entity instanceof EntityCow || event.entity instanceof EntitySheep || event.entity instanceof EntityPig || event.entity instanceof EntityRabbit || event.entity instanceof EntityWolf || event.entity instanceof EntityOcelot){
            event.setCanceled(true);
            event.setResult(Event.Result.DENY);
        }
    }

    @SubscribeEvent
    public void genAnimals(PopulateChunkEvent.Populate event){
        if (event.type == PopulateChunkEvent.Populate.EventType.ANIMALS){
            event.setCanceled(true);
            event.setResult(Event.Result.DENY);
        }
    }

    @SubscribeEvent
    public void onEntitySpawn(EntityJoinWorldEvent event){
        if (event.entity instanceof EntityChicken || event.entity instanceof EntityCow || event.entity instanceof EntitySheep || event.entity instanceof EntityPig || event.entity instanceof EntityRabbit || event.entity instanceof EntityWolf || event.entity instanceof EntityOcelot){
            event.setResult(Event.Result.DENY);
        }
    }

 

So what is the proper way to do this? It looks to my research like I'd have to somehow change the spawn lists within the biome classes, and if I'm correct I have no idea how to do that. I hope I'm not correct.

I think it would be more "correct" to simply remove them from the natural spawning list.

Except that also stops them from spawning naturally, later.

Which as I understood is exactly not what OP wants.

 

The OP said he wanted them to spawn later "through other means". I understood that to mean he would spawn them explicitly. Basically nothing auto-spawned. But you're right he might have meant something else.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

  • Author

My plan is to have the persistent mobs (cows, dogs, etc.) spawnable only by taming non-persistent mobs, or through creative/command methods. The only way I want them to not spawn is through terrain generation.

 

EDIT: Thank you Diesieben, that was the problem! The animals no longer spawn.

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.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.