Colorful Hearts

Colorful Hearts

12M Downloads

Eidolon:Repraised Compat (Dev to Dev)

Alexthw46 opened this issue ยท 2 comments

commented

It's a clone of #23 in a way, but that one talks only about chilled hearts (and it seems fixed?) but ethereal hearts don't seem to draw at all with this mod.

Is there a way we can co-op to make both hearts more compatible? It's mostly legacy code from the former author with little patches to make it work with current overlays, so you'd be the expert on the topic.
Not sure on how much it's only on your end and how much i can help, but if i can avoid forcing all health stack mod to need explicit compat, as you had to, it would be nice

commented

Unfortunately there is no real solution to adding support for all health stacking mods since it is basically required to override vanilla heart renderer with your own. This means that any mod that tries to follow vanilla's heart rendering convention with separate rows will not work as expected or their renderer will not run at all like is the case with Eidolon and there is no real way to detect if a mod has done this without checking if the mod is present.

The reason why Eidolon hearts do not render at all is that the Pre render event in forge is cancelled, which in turn also makes the Post event not run and any heart overlays that are registered using RegisterGuiOverlaysEvent not run. It is possible for a health stacking mod to run these events by itself, but that is just going to have a ton of these overlays render in multiple rows when health or absorption overflows since they assume that hearts are rendered in multiple rows. Sorry, this is completely wrong. the overlays do render but since they behave according to vanilla's heart rendering, it renders overlays over non-existing hearts since they are all in the same row instead of spreading out over multiple rows. This is why I cancel those overlays

private void cancelOverlay(RenderGuiOverlayEvent.Pre event) {
if (event.getOverlay().id().equals(EIDOLON_HEARTS)) {
event.setCanceled(true);

I have added an API for any kind of "effect-like" heart types where a mod just provides their own "alternating" HeartDrawing instances for health and/or absorption to OverlayHeart and everything else is handled internally by rendering those hearts on top of colored hearts. This is what I have done for the chilled effect from Eidolon as you can see here

event.registerOverlayHeart(OverlayHeart.build(chilledId, player -> player.hasEffect(effectHolder.get()))
.addHealth(drawing)
.transparent().finish());

After rechecking how ethereal hearts are rendered I just realized it is actually pretty simple and can be added by subscribing to the post render event provided by Colorful Hearts.

public static class Post extends ForgeHeartRenderEvent<HeartRenderEvent.Post> {

Ethereal hearts seem to render after health and absorption hearts, so just assuming that the highest amount of rows is 2 (with health and absorption both having 10 or more hearts), it should be pretty easy to handle it. I initially assumed that you rendered ethereal hearts between health and absorption which would make this more complicated as I would need to add a way to move absorption hearts, but since they are just a thing that renders above it is pretty straightforward. I'll look into adding a compat on my side since I already added it for chilled hearts and it kind of is my fault since these kinds of mods break custom overlays. Recently I've been trying to make the mod compatible with custom overlays from other mods as much as possible since most of these types of mods do not bother adding support giving most users a bad experience.

commented

Adding support was actually pretty simple as you can see here 485fcf5. I just do the same thing as you do in Eidolon but with it considering that there's only max 20 hearts for absorption and health.

If you want to, I could remove the compat and let you handle it on your own side since the overlay does run if I do not cancel it. You would just have to check if any heart stacking mod like Colorful Hearts is installed using something like ModList.get().isLoaded(modid) and modify the few values to consider that health and absorption together go only to max 20 hearts.

But as you can probably see in my implementation of ethereal hearts, I did not put in the vanilla offset that decreases vertical spacing between heart rows when there's many so that it saves on vertical space. Since Eidolon only has up to 20 hearts afaik (10 from helmet & leggings and another 10 from chestplate) I saw no need for this since there's only a maximum of 4 rows of hearts with health and absorption.