Jump to content

[1.12.1] Potion Effects on items


Erfurt

Recommended Posts

Hey guys,

 

So I'm working on some Baubles rings and other stuff, that adds potion/beacon effects to the wearer. And my first testing was fine, no problems. But when I tried to use health boost, I noticed some 'weird' behavior, there was no regeneration on the extra hearts. I do understand why this is, and it's because I reapply the effect on every worn tick (I don't know any other way to do that). I can't see any easy fix to this, other than giving the wearer a short burst of regeneration or instant health, but that would mess up if the player is in combat, or is low on hunger. That would not be a good solution, in my mind. So that made me wonder if there is another way to add effects to players, and if I would be able to base the effects on what items that player is wearing? I would assume that I could use nbttags to do that, although I have not worked with that before, so I'm not sure how it works.

 

Because I'm trying to find another way to do the effects, I don't have much code to show, but this is more of a question about what I'm able to do, and not as much a question of what is wrong with my code. I think that it's ok.

 

I should also mention that at the moment I'm just doing some testing of the effects and what I'm able to do with them. But at some point I will be converting from having all the effects static on the items, to have some of the effects come from enchantments instead. And at this point I have no clue where to begin on the enchantments, however that's not what this is about (but if you guys know a good guide or place to learn this, that would be very much appreciated).

 

So to recap, I need to find a way to add potion/beacon effects to the wearer of an item, with a specific effect and/or enchantment.

If some of you can guide me towards a tutorial or some other guides on this, especial the health boost thing, as that was one of the main things I wanted to add with my mod. I would be very happy. Or just shoot me down if I'm being stupid :P

Link to comment
Share on other sites

Regeneration specifically requires certain "time remaining" ticks to be hit in order to produce any healing factor. Reapplying the potion every tick is the wrong way to do this. Instead, apply the potion effect for a 1 second duration, then check to see if the player has the potion effect, if they do not, reapply 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.

Link to comment
Share on other sites

9 hours ago, Draco18s said:

Regeneration specifically requires certain "time remaining" ticks to be hit in order to produce any healing factor. Reapplying the potion every tick is the wrong way to do this. Instead, apply the potion effect for a 1 second duration, then check to see if the player has the potion effect, if they do not, reapply it.

This isn't really an option, because every time Health Boost gets reapplied, it starts with empty hearts. And as I mentioned I don't really want to have any healing factors, other than when it gets applied the first time, as it can otherwise mess up if the player is in combat or something like that. But maybe there's a way to alternate the max health of the player by other means? I have the means to apply stuff when the player equip the item, and remove stuff when the player unequip the item. So it's just a matter of finding the other way, as I have little to no clue :)

 

But thanks for your input, might be useful for other effects

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.