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.

[SOLVED][1.8]LivingSpawnEvent.SpecialSpawn not firing or i am missing something

Featured Replies

Posted

Good morning Forum :)

 

Using the latest (8.0.12.1255 as of writing this) Forge for 1.8 i try to use LivingSpawnEvent.SpecialSpawn and its parent LivingSpawnEvent.

The parent gets called perfectly, but i expected the child to fire first, which it doesn't. In fact it isn't fired at all.

The test setup is that LivingSpawnEvent prevents all mob spawning in an area around spawn, which works for natural spawning.

The problems:

- Eggs spawn mobs, which interestingly is not registered by LivingSpawnEvent or PlayerUseItemEvent.Start.

- Mob spawners spawn their mobs, which should have been caught by LivingSpawnEvent.SpecialSpawn according to the documentation.

 

(shortend) Code example of what i am doing here:

public class onMobSpawn {

@SubscribeEvent(priority=EventPriority.HIGH)
@SideOnly(Side.SERVER)
public void spawnEvent(LivingSpawnEvent event)
{
	Entity mob = event.entity;
	if(mob instanceof EntityAmbientCreature)
	{
		if(mob instanceof EntityBat)
		{
			if(laCheck.noBatsFlag(mob.posX, mob.posY, mob.posZ,helper.getFullWorldName(mob.getEntityWorld())))
			{
				event.isCanceled();
				return;
			}				
		}
	}
	if(mob instanceof EntityMob)
	{
		if(laCheck.monsterFlag(mob.posX, mob.posY, mob.posZ, helper.getFullWorldName(mob.getEntityWorld())))
		{
			event.isCanceled();
			return;
		}
	}		
}
}

public class onMobSpawnSpecial {
@SubscribeEvent(priority=EventPriority.HIGHEST)
@SideOnly(Side.SERVER)
public void spawnEventSpecial(LivingSpawnEvent.SpecialSpawn event)
{
	Entity mob = event.entity;
	Logger log = FMLLog.getLogger();
	log.info("DEBUG: mob.getName() == '" + mob.getName() + "'");	
}	
}

//In my init class
    @EventHandler
    public void init(FMLInitializationEvent event)
    {
        MinecraftForge.EVENT_BUS.register(new onMobSpawn());
        MinecraftForge.EVENT_BUS.register(new onMobSpawnSpecial());
    }

 

So what could be my mistake here. Maybe i am misinterpreting the documentation somewhere and a nudge in the right direction would be helpful.

My Minecraft coding background is hMod/Canary Classic, if that helps. ;)

SELECT signature FROM dumbsignatures WHERE forumtopic LIKE forum;

0 rows returned.

  • Author

Yup, that helped, thanks. :)

 

Anything else that could pose a trap when coming from other Minecraft modding APIs?

SELECT signature FROM dumbsignatures WHERE forumtopic LIKE forum;

0 rows returned.

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.