Posted March 13, 201411 yr 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.
March 13, 201411 yr 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.
March 14, 201411 yr 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.
March 14, 201411 yr 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()); }
March 14, 201411 yr 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.
March 14, 201411 yr 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!
March 14, 201411 yr Tell me why the heck you didn't remove: MinecraftForge.EVENT_BUS.register(new NGUEventHandler()); I usually post my events on postInit(FMLPostInitializationEvent event)
March 14, 201411 yr 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.
March 14, 201411 yr I have never done that before. I usually do seperate event classes if it uses another bus. Try and seperate them apart.
March 14, 201411 yr 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.