Jump to content

Recommended Posts

Posted

Say I want to add elytra that behave motion-wise in a similar fashion of vanilla's but with some tweaks, say, custom colour or whatever.

Every tick almost at the end of EntityLivingBase#onLivingUpdate, EntityLivingBase#updateElytra gets called, which checks for the one and only vanilla elytra by reference comparison, and if (not) present in the chest armour slot, is sets the 7-flag (elytra-flight) to true (false).

The method updateElytra() gets called immediately before EntityLivingBase#moveEntityWithHeading, which calculates the motion of elytra flight, but only if flag-7 is true (through EntityLivingBase#isElytraFlying), so there is no point of entry to set the flag manually (in an armorTick or whatever).

One could replace the player entity with a subclass that overrides EntityLivingBase#isElytraFlying, but that seems awkward to do.

Coremodding can always be used, but never should.

The last idea I have is just bailing on the vanilla code, and applying motion calculated by an equivalent (heh, copy&paste) algorithm directly from the custom item. This doesn't seem update-proof however, what if Mojang changes the algorithm? (Probs not an issue, but still)

 

Lastly, if I decide to go with the third option, which seems the most sensible, what if the custom elytra are meant to be won in, say, the leggings slot, and the player simultaneously equips regular elytra?

 

Any other ideas or arguments pro/contra my ideas are greatly appreciated.

Posted
8 minutes ago, HashtagShell said:

The last idea I have is just bailing on the vanilla code, and applying motion calculated by an equivalent (heh, copy&paste) algorithm directly from the custom item. This doesn't seem update-proof however, what if Mojang changes the algorithm? (Probs not an issue, but still)

This until Forge patches it.

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.

Posted

The reference comparison is also made in NetHandlerPlayServer#processEntityAction for players.

 

Another issue with that idea is that motion isn't everything, there are the client-side controller checks to start flying, the player renderer, the elytra model... all these things check EntityLivingBase#isElytraFlying.

It just doesn't really seem feasible.

Posted

Make a Forge pull request changing the == to an instanceof check.

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.

Posted

Mind, when it goes under review, Lex or someone else might have some comment on how to improve it, or something. Or why it won't work, or....

Be prepared for that.

And check to see if there's already a PR open for it.

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.

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.