Jump to content

Any way to detect when a specific entity dies?


Robin Withes

Recommended Posts

Hey everyone,

been trying for a while to look for a solution to this problem:

 

So i am looking for certain mobs to spawn with

entitySpawned(EntityJoinWorldEvent event)

Then when i find the mob i'm looking for i want to do something like this to it:

//Obviously just a dumbed down example
	public void entitySpawned(EntityJoinWorldEvent event) {
		Entity entity = event.getEntity();
		if (true)
		{
			entity.onDead(someFunction()); //Runs when the entity dies.
		}
	}

What would be a ideal solution to this?

Link to comment
Share on other sites

Capabilities. You create one, apply it to the entity when it is spawned, then in the EntityDeathEvent you check to see if that capability is there, and if so, do something.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

7 minutes ago, Draco18s said:

Capabilities. You create one, apply it to the entity when it is spawned, then in the EntityDeathEvent you check to see if that capability is there, and if so, do something.

Is capabilities something originally from Java or from forge, i never heard of it before.

Link to comment
Share on other sites

The Capabilities systems are supplied by Forge. They're an advancement on IEntityExtendedStorage (among other things)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

4 hours ago, Robin Withes said:

Is capabilities something originally from Java or from forge, i never heard of it before.

Capabilities are a concept from Object Oriented Programming (like Objects and Interfaces). They allow for programming in the style “composition over inheritance”. Sorry for the badly worded answer, these articles explain it well.

https://en.m.wikipedia.org/wiki/Composition_over_inheritance

https://en.m.wikipedia.org/wiki/Encapsulation_(computer_programming)

 

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

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.

×
×
  • Create New...

Important Information

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