First Aid

First Aid

15M Downloads

Incompatibility with Spice of Life: Carrot Edition

juliand665 opened this issue ยท 7 comments

commented

Hi! I'm the maintainer of Spice of Life: Carrot Edition and it has been brought to my attention repeatedly that our mods are not compatible with each other. I was hoping this issue could serve as a central place to discuss this, rather than the other issues currently in your tracker concerning this: #72, #76, #111.

I'd really appreciate it if you could look at how we handle this and think if you can come up with how it conflicts with your mod, since our interaction with player health is pretty limited in scope while it is a much larger (and assumedly more complex) part of your mod. The relevant part is really just this file, most notably the part where we change the max health attribute modifier and force an update to the player's health. I have a theory the latter part is what's breaking; it's a workaround for Minecraft refusing to update the displayed (max) health in some circumstances.

commented

Ok funnily enough, Spice of Life Potato edition WORKS with first aid.
When I achieved the 3.0 Threshold to gain a heart, it didn't take away ANY health, and added the heart I gained to the first aid's health system correctly. This is really odd, because when Spice of Life Carrot Edition does this, it completely sets first aid's health system to 0 until you respawn.

commented
commented

Huh, interesting! Well, if my hunch is correct and it's the workaround's fault, it might just be that potato edition does not have this workaround lol.

commented

Yeah whenever I ate something (any food) I'd get all my health taken away and basically be at one hp

commented

Hi @juliand665,

So I finally had time to look at this, and yeah, that setHealth(1) is where everything goes wrong. Because in firstaid, you can already die when your health is >0, so firstaid intercepts the call to setHealth(1) and notices a difference of 19 health to the original player health (if the player is fully healed). Because there was no DamageEvent of something like that, FirstAid assumes that the player has taken damage from a mod that does this by using the setHealth method. So it tries to distribute these 19 damage, and notices that the player will be dead with that. That's where the issue comes from.

If I read your code correctly, this should just increase/decrease the max health, and the setHealth is to trigger a change so vanilla notices. If you need that change to take affect immideatly, the FirstAid API has a method to do this (runScaleLogic on the AbstractPlayerDamageModel, which you can get from the capabitlity). However, if you don't need the change to apply this tick and next tick is fine as well, you can just skip the set health part when first aid is loaded! First Aid checks every tick if player.getMaxHealth() is still the same as the old value. So it should see the change and scale accordingly.

If you have have any more question, feel free to ask here or poke me on discord (ichttt#2790).

commented

I opened a PR that should hopefully fix the issue: Cazsius/Spice-of-Life-Carrot-Edition#105

commented

The latest first aid version is now compatible with the latest Spice of Life version