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

Hey,

 

I was wondering if there's any way to make any entity spawn holding/wearing an item from my mod.

 

any help appreciated.

 

Thanks

Edited by Differentiation

If you subscribe to EntityJoinWorldEvent, then you should be able to access the entity through the event and change it however you want to.

Fancy 3D Graphing Calculator mod, with many different coordinate systems.

Lightweight 3D/2D position/vector transformations library, also with support for different coordinate systems.

  • Author
6 hours ago, SerpentDagger said:

If you subscribe to EntityJoinWorldEvent, then you should be able to access the entity through the event and change it however you want to.

I tried to do this with LivingSpawnEvent and having zombies spawn with a certain item only 1/10000 chance but it's still very frequent...

  • Author
1 hour ago, diesieben07 said:

Show your code.

	@SubscribeEvent
    public static void onLivingSpawn(LivingSpawnEvent event) 
	{
		EntityLivingBase entityliving = event.getEntityLiving();
		Random rand = entityliving.world.rand;
		EnumDifficulty difficulty = entityliving.world.getDifficulty();
		
		if (entityliving instanceof EntityZombie)
		{
			int i = rand.nextInt(difficulty == difficulty.EASY ? 20000 : difficulty == difficulty.NORMAL ? 15000 : 10000);
			int j = rand.nextInt(difficulty == difficulty.EASY ? 20000 : difficulty == difficulty.NORMAL ? 15000 : 10000);
			
			if (i < 1 && entityliving.getHeldItemMainhand().isEmpty())
			{
				entityliving.setHeldItem(EnumHand.MAIN_HAND, new ItemStack(DinocraftItems.LEAFERANG));
			}
        }
	}

For some reason I see a zombie spawning with this item once in 3-ish nights. What is the chance that they spawn with Iron or Diamond swords and stuff?

  • Author
5 hours ago, diesieben07 said:

LivingSpawnEvent is a parent event for several sub-events. Subscribing to just LivingSpawnEvent subscribes you to all sub-events, which is not meaningful in any way.

So... EntityJoinWorldEvent is the better way out?

  • Author
12 minutes ago, diesieben07 said:

No. EntityJoinWorldEvent fires every time an entity enters a world. Regardless of if it's a newly spawned one or one that's loaded from disk.

You probably want LivingSpawnEvent.SpecialSpawn, which is used to initialize newly spawned entities.

Thanks

 

Also, do you happen to know in what class MC spawns mobs with armor and what are the chances?

Edited by Differentiation

5 hours ago, Differentiation said:

Thanks

 

Also, do you happen to know in what class MC spawns mobs with armor and what are the chances?

Do you mean about line1000 - 1200 in EntityLiving?

Edited by poopoodice

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.