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.

Featured Replies

Posted

So I want to deny all mob spawns, so that i can add in specific mobs to each biome.

I've already tried handling this event.

 

@SubscribeEvent

public void onCheckSpawn(LivingSpawnEvent.CheckSpawn event)

{

event.setResult(Result.DENY);

}

 

but it doesn't work, am i missing something?

i want to avoid despawning if possible and just deny the spawn from occurring in the first place.

 

Not that I know of, you can look at how Minecraft does it with the difficulties.

 

The only way (complex) I can think of right now is EntityJoinWorldEvent. You can check for mobs and cancel the event.

  • Author

Does any know how the LivingSpawnEvent.CheckEvent actually works, in the code it has this

 

    /**

    * Fires before mob spawn events.

    *

    * Result is significant:

    *    DEFAULT: use vanilla spawn rules

    *    ALLOW:  allow the spawn

    *    DENY:    deny the spawn

    *

    */

 

sounds like what I'm after but it doesn't work, as in mobs continue to spawn like normal, is this a bug, or am i using it wrong?

println confirms that it is being called, but it doesn't deny any spawns.

 

 

  • Author

just like this, not sure if that's the correct event bus?

 

@EventHandler

public void init(FMLInitializationEvent event)

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

}

That's exactly the problem, wrong event bus.

The event is an FML event.

 

You should use:

FMLCommonHandler.instance().bus().register(Object obj);

 

#obj = your event handler class.

  • Author

ok so now i have this in the main class file

 

@EventHandler

public void init(FMLInitializationEvent event)

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

    FMLCommonHandler.instance().bus().register(new NGUFMLHandler());

}

 

and this in a new class file.

 

public class NGUFMLHandler {

 

@SubscribeEvent

public void onLivingSpawnCheckSpawn(LivingSpawnEvent.CheckSpawn event)

{

System.out.println("denied");

event.setResult(Result.DENY);

}

 

problem is it never gets called!

Tell me why the heck you didn't remove:

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

 

I usually post my events on postInit(FMLPostInitializationEvent event)

  • Author

because i have other events handled there, but i tried commenting it out anyway and posting the event to postInit, preInit and load, none of which were being called.

 

looks like i'll just have to use the EntityJoinWorldEvent and cancel it when necessary.

This is a server side only, MinecraftForge.EVENT_BUS event.

Make sure there is nothing related to client side on your event listener.

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.