Jump to content

Adding hit points to an entity


Asweez

Recommended Posts

First, sorry for the barrage of questions, but I'm trying to learn as much as I can about this stuff to become a better modder.

 

I have a vehicle that is just an entity. I want it to to have hit points that will go down when things do damage and eventually destroy that vehicle. How do I add this?

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Link to comment
Share on other sites

Extend EntityLivingBase instead, or simply add your own hit points field and manage it yourself when the entity is struck.

 

The first is easier, but has the downside of your vehicle then acting like an actual living being when it shouldn't. The second is more work, and will require that you spend some time thinking about your design and being comfortable with Java.

Link to comment
Share on other sites

Extend EntityLivingBase instead, or simply add your own hit points field and manage it yourself when the entity is struck.

 

The first is easier, but has the downside of your vehicle then acting like an actual living being when it shouldn't. The second is more work, and will require that you spend some time thinking about your design and being comfortable with Java.

You can actually override onUpdate and onLivingUpdate, and that will stop it from acting like a living entity.

Link to comment
Share on other sites

Extend EntityLivingBase instead, or simply add your own hit points field and manage it yourself when the entity is struck.

 

The first is easier, but has the downside of your vehicle then acting like an actual living being when it shouldn't. The second is more work, and will require that you spend some time thinking about your design and being comfortable with Java.

You can actually override onUpdate and onLivingUpdate, and that will stop it from acting like a living entity.

Not entirely, as there are plenty of places that check 'if (entity instanceof EntityLivingBase)' before operating some logic which may not really apply to the vehicle; not to mention that overriding those two methods is generally pretty messy.

 

Still, that is a possibility. I would only use it as a last resort, though.

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.