Jump to content

[SOLVED] [1.12.2] Making entities spawn with mod items?


Differentiation

Recommended Posts

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...

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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