Jump to content

Recommended Posts

Posted

Is there an existing or accepted way of calling a method on a capability that is attached to armor or items based on update.

For instance, armor has an update method that gets called while the player is wearing it. If I want the update method on my capability called whenever that updated gets called is there an existing or accepted way of doing so or do I need to come up with something?

Current Project: Armerger 

Planned mods: Light Drafter  | Ore Swords

Looking for help getting a mod off the ground? Coding  | Textures

Posted

One way to do it for sure would be to use the PlayerUpdate event, check each wearn armor item if it has ur capability, if it has call the update method.

I dont think you can do this without using events

Posted

Thats what I was think, I was just hoping I was wrong. I am trying to minorly overhaul the damage system.  By adding capabilites to items (tools/weapons/armor) that alter damage done based on Resistances and damage types.

For example leather would help against a cutting edge but would do nothing against a hammer.

This means that essentially any item or armor could have one of these capabilities regardless of the entity that is using/wearing it.

 

Next question:

Since it seems I will likely need to use events for this primarily LivingHurtEvent, when does armor and enchantments get applied to the damage relative to this event?

Current Project: Armerger 

Planned mods: Light Drafter  | Ore Swords

Looking for help getting a mod off the ground? Coding  | Textures

Posted

It gets applied after, which is why I made this method - however, that neat little trick of creating a class in a vanilla package (even though it's still in YOUR mod's folder) doesn't seem to work anymore, see this post.

 

Unless someone knows how to get that to work, your options are either Reflection e.g. to make the method(s) publicly accessible, or to copy/paste those methods (which likely will still require Reflection to make private fields etc. accessible).

 

One thing you may want to think about: if your protection is going to completely nullify the damage received, doing so in LivingHurtEvent still results in the 'hurt' animation / getting knocked back, at least it used to, so you may also want to check in LivingAttackEvent - note that you cannot alter the damage in the attack event, only cancel it or allow it, but it is useful if something gives complete immunity (e.g. evasion).

Posted

What I am planning on doing is have any Resistance capability implement a method for LivingHurtEvent and a method for LivingAttackEvent. In my event handler I will check the Armor slots of the target entity and if any of those have one of the capabilities I will call the respective methods. In the LivingAttackEvent I will check the item/entity that is attacking and if it has on of my damage capabilities and if so I will cancel the event(before checking armor) and re post the event but with the new DamageSource.

Since enchantments/ armor value get applied after this event I might just cancel the livingHurtEvent and apply the damage directly.

Current Project: Armerger 

Planned mods: Light Drafter  | Ore Swords

Looking for help getting a mod off the ground? Coding  | Textures

Posted

Since enchantments/ armor value get applied after this event I might just cancel the livingHurtEvent and apply the damage directly.

I highly advise NOT doing that unless there is absolutely no other way, the reason being that the whole point of the Forge events is mod inter-compatibility, and directly damaging an entity will break that contract and circumvent any number of other mods' damage handlers.

 

Canceling and reposting an event is fine, but usually you can get by with a simple adjustment to the damage amount in the LivingHurtEvent - it is a publicly mutable field of the event class for a reason.

 

Now, if you are talking about the LivingAttackEvent, that'd be the perfect time to cancel and repost with a new DamageSource, e.g. Piercing, Slashing, Bludgeoning, etc. based on the weapon capability / type. At that point, you wouldn't even care about the armor calculations or other resistances as those would be handled in the hurt event.

Posted

I would only include the armor in the livingAttackEvent for the sake of something like evasion or deflection that completely stops damage and doesn't do the damage animation.

 

I suppose I can increase the damage by the amount the armor would block for the case where the armor is ineffective.

Current Project: Armerger 

Planned mods: Light Drafter  | Ore Swords

Looking for help getting a mod off the ground? Coding  | Textures

Posted

To clarify, you don't need to include the armor calculation for things like evasion - that was a bad example, since it is a binary (all or nothing) type of protection.

 

It is useful, however, for things like resistances, e.g. 50% resistance to slashing - well, okay, that takes you to half damage, but now you have to account for the player's armor and potion effects in order to decide if you want to cancel the LivingAttackEvent.

 

You're not changing the damage at this point, nor are you re-posting the event yet again, just deciding if you want to completely negate it to avoid the hurt animation. If there is any damage remaining, you let it all go through to the LivingHurtEvent which then does the same resistance calculations less the armor and potion calculations - those happen during the actual Entity#damageEntity method.

 

Increasing the damage amount during LivingHurtEvent is also fine, e.g. to simulate an armor type that is weak against the damage type, like you mentioned above.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I need to know what mod is doing this crash, i mean the mod xenon is doing the crash but i want to know who mod is incompatible with xenon, but please i need to know a solution if i need to replace xenon, i cant use optifine anymore and all the other mods i tried(sodium, lithium, vulkan, etc) doesn't work, it crash the game.
    • I have been trying to solve a consistent crashing issue on my brother's computer where it will crash during the "Scanning Mod Candidates" phase of the loading process that starts when you click the play button on the Minecraft launcher. The issue seems to stem from a missing library that it mentions in the log file I provide below. I might I'm missing the bigger issue here for a smaller one but hopefully someone can find what I'm missing. Here's all of the stuff that I've been able to figure out so far: 1. It has nothing to do with mods, the crash happened with a real modpack, and even when I made a custom modpack and launched it without putting ANY mods into it (That is where the log file comes from by the way). 2. I have tried to find this class like a file in the Minecraft folders, but I've had no luck finding it (I don't think it works like that, but since I really don't understand how it works, I just figured I'd try). 3. I haven't seen anyone else have this issue before. 4. I know that my modpack (with mods) does work since I've run it on my computer, and it works fantastic. For some reason my brother's computer can't seem to run anything through curseforge. 5. This is for Minecraft version 1.20.1, Minecraft launcher version 3.4.50-2.1.3, forge 47.3.0, and curseforge app version 1.256.0.21056 6. My brother is using a Dell laptop from 6 years ago running Windows 10 (If you think more info on this would help, please ask as I do have it. I'm just choosing not to put it here for now). 7. I have reinstalled the curseforge app and installed Minecraft version 1.20.1. I have not reinstalled Minecraft or forge 47.3.0 but I didn't know if that would help. 8. I had an error code of 1 Please let me know if there is anything else that I am missing that you would like me to add to this post/add in a comment! Lastly, many thanks in advance to whoever can help! ------------- LOG FILE (latest.log) ------------- (from /Users/<NAME OF USER>/cursforge/minecraft/Instances/<THE NAME OF MY EMPTY MODPACK>/logs/latest.log) (This was made after running an empty modpack with same versions for all apps) ("[REDACTED]" is not the actual text from the log, it is me replacing text I figured wouldn't be necessary for fixing and would hurt my privacy) https://pastebin.com/hxXvGGEK ------------- DEBUG.LOG (I realized that I should have put this here first after I had done all of the work on putting latest.log in) -------------------- (again, "[REDACTED]" is not the actual text from the log, it is me replacing text I figured wouldn't be necessary for fixing and would hurt my privacy) https://pastebin.com/Fmh8GHYs
    • Pastebin... https://pastebin.com/Y3iZ85L5   Brand new profile, does not point to a mod as far as I can tell, my fatal message just has something about mixins. Don't know much about reading logs like this, but am genuinely stuck, please help. Java updated, pc restarted.
    • I was playing minecraft, forge 47.3.0 and 1.20.1, but when i tried to play minecraft now only crashes, i need help please. here is the crash report: https://securelogger.net/files/e6640a4f-9ed0-4acc-8d06-2e500c77aaaf.txt
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.