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

updateEntityActionState is final in EntityLiving.  I have a custom AI that completely replaces the base activities in that method that I was using in 1.7.2.

 

Is there a graceful way around this?  So dang annoying Mojang made that final.

Long time Bukkit & Forge Programmer

Happy to try and help

Sorry, my mistake, I though it was a field.

1.7.10 is no longer supported by forge, you are on your own.

  • Author

I've never used reflection to replace a method, just variables.  Got an example you could share?

Long time Bukkit & Forge Programmer

Happy to try and help

As edited, I made mistake.

As to problem - there are no means in java (outside ASM probably) that would allow you to override final method.

 

What you should do:

Stop being an ape :D and start using new stuff - MC changes, Forge changes - you should too (more compatybility and better code).

 

What you can do:

updateEntityActionState() is defined in EntityLivingBase

EntityLiving extends EntityLivingBase.

 

Therefore: you can make your own EntityLivingCustom and override EntityLivingBase's method (which is not final).

Or, you can go with EntityLiving, but override onLivingUpdate() WITHOUT calling super (which is responsible for calling updateEntityActionState()) and copy super's code into your classe's overriding method.

 

Edit - More info:

EntityLivingBase is the first in hiererchy implementing #onLivingUpdate() which is called from its #onUpdate()

Doing what was proposed above WILL be simple and NOT that bad.

1.7.10 is no longer supported by forge, you are on your own.

  • Author

That is what I was planning on doing to fix it, but was checking to see if there was an easier way.

 

What do you mean by "Stop being an ape :D and start using new stuff - MC changes, Forge changes - you should too (more compatybility and better code)"

 

I have no clue what you are talking about.

Long time Bukkit & Forge Programmer

Happy to try and help

I have a custom AI that completely replaces the base activities in that method that I was using in 1.7.2.

 

I was more or less refering to this. Why would you have custom AI at all. ("ape" = old-timer, outdated, you know, stuff like that)

You mentioned 1.7.2 so I assumed that in past it worked, and now after mc/forge updates it doesn't. My logic was and is simple:

If something doesn't work after update - it is outdated. 1st thing I do in this case is look for replacement. Only later I do tricks.

It keeps your code clean and compatibile.

Basically what I mean: do not force implementing new systems if you have vanilla implementations.

1.7.10 is no longer supported by forge, you are on your own.

  • Author

Thanks for sharing.  In this particular case, there is a reason for it and I disagree.

Long time Bukkit & Forge Programmer

Happy to try and help

  • Author

Hmmm, I'll look into that today. 

 

For now I just fixed it, so that I can get the mod running in 1.8.    But, it may be time to take a look and see if there is a more gracefull way to do what I'm doing.

 

Essentially, they are guards that are tied to a block.  They have a modifiable list of safe players and entities to leave alone.  They can also be told to patrol a certain path around their block.  Lastly they have a custom path finding routine that runs outside of the minecraft thread that just notifies back when it is done.  If the enemy is close it runs in less than a tick but if it is 50 or so blocks away it can take 3 ticks.  With a fair number of guards, that led to bad bad things leaving it inside the main thread.  This way they can do some pretty fancy things with no impact.

 

This all worked great in 1.7.2, but had to change a few things for 1.8.  Despite Ernio's unique way of suggesting it, that got me thinking it might be time to look at it again and see if there is a more graceful way to pull it off.  I've overridden and modified so much of the base entitymob code, I'm not sure why i'm using it anymore.

Long time Bukkit & Forge Programmer

Happy to try and help

The graceful way of doing it is to use the AI system for its intended purpose, rather than hard-coding everything in the entity action state / update methods. With the right combination of mutex bits and a lot of patience, you can do some very complex things, especially once you start getting into making custom path navigators and such ;)

  • Author

I did that originally, but got into tick count issues.  I'll give it another whirl.  At the least, I might hide my systems inside the ai calls instead of in the entity.

Long time Bukkit & Forge Programmer

Happy to try and help

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.