Jump to content

[1.10.2] Getting the main entity from a entity part


Silly511

Recommended Posts

I have a item that does something when you left-click a entity with it. However when you left click the ender dragon the method returns a instance of EntityDragonPart instead of EntityEnderDragon. I know I can get the dragon entity from the

entityDragonObj

field in EntityDragonPart, but how can I get the main entity from any multipart entities, including modded ones?

Link to comment
Share on other sites

I have a item that does something when you left-click a entity with it. However when you left click the ender dragon the method returns a instance of EntityDragonPart instead of EntityEnderDragon. I know I can get the dragon entity from the

entityDragonObj

field in EntityDragonPart, but how can I get the main entity from any multipart entities, including modded ones?

What are you trying to do?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

I'm making a sword that cuts though any protections, including the attack event being canceled. To do this I'm directly modifying the entity's health using setHealth, which is why I can't use attackEntityFrom.

Attack with void DamageSource ie

Entity#attackEntityFrom(DamageSource.outOfWorld, amount);

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

That would work for most things, but the death message would be "ENTITY fell out of the world". I want to attack with a custom damage source. I can make my custom damage source ignore creative which would work for most things but it still won't work work if the death event is canceled. I'm pretty sure the only way to do this is directly modifying the entity's health.

Edited by Silly511
Link to comment
Share on other sites

So make a custom damage source.

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

Directly modifying the entity's health won't affect the Death Event: the entity will still die, fire the event, which could still cause the entity to heal (canceling the event is not sufficient).

 

If you want to prevent people from dickering with events, then subscribe to the event and dicker with it yourself, setting your priority to lowest.

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

I'm already doing that. My death code works fine, I just need to get the main mob from a multipart mob part. Looking into the code some more I think I need to submit a pull request for an IMultipartEntityPart interface which multipart mob parts could implement and have a getMainEntity method.

Link to comment
Share on other sites

I'm already doing that. My death code works fine, I just need to get the main mob from a multipart mob part. Looking into the code some more I think I need to submit a pull request for an IMultipartEntityPart interface which multipart mob parts could implement and have a getMainEntity method.

You are probably better off doing that, but I believe my method of doing this would work. IE Create custom damage source deal 0.04 (somewhere around this), then subscribe to the living attack event (can't remember name off of the top of my head) and deal the appropriate amount of damage. Bypassing the whole need for a PR though would be nice for other features.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

I think what you want already exists in the entityDragonPart class

 

I know I can get the dragon entity from the
entityDragonObj

field in EntityDragonPart, but how can I get the main entity from any multipart entities, including modded ones?

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

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.