Giselbaer's Durability Viewer

Giselbaer's Durability Viewer

3M Downloads

Enhancement: add support for Colytra

MeeniMc opened this issue ยท 6 comments

commented

Mod Colytra (https://www.curseforge.com/minecraft/mc-mods/colytra-fabric) makes a single item of a chest armor and an elytra.
The durabilty of both items remains tracked independently (i.e., the chest item has two durabilities, one for taking hits from mobs, one for using the elytra flying around).

Currently DurabilityViewer being unaware of this special behavior, it shows the durability of the chest armor, but the durability of the elytra is not visible.

I looked at the code, the 'elytra' appears to be stored as an NBT in the chestplate item.

commented

It works!

It's ready to go as-is, but two nitpicking, if you have more time.

The enchant glint is missing from the 'elytra' display if the 'colytra' is enchanted. See on the bottom left of the action bar, missing the violet lines.
2020-11-01_15 00 16

In the 'snap to corner' view, the elytra presents itself 'under' the chestplace. It would look better if it would present itself 'on the side', like in the 'action bar' view. That would obviously shift the arrows and weapons 1 slot down.

2020-11-01_15 03 27

commented

I found another edge use case. If you disable the Colytra addon without first separating the items, Durability Viewer will still display the 'colytra', although it is not usable. But honestly this is a broken use case.

commented

Here's a version that should work with colytra, please check and give me feedback. (the jar is in the zip file; you need to unzip that, because GH doesn't allow jar files in messages directly).

durabilityviewer_beta_colytra.zip

commented

Enchant glints

I pulled out the NBT for you in both NORMAL and UNISON modes:

2020-11-02_13 28 36

For knowing if the elytra-part itself has enchants, they are listed in the NBT 'colytraElytraUpgrade, alongside the durability.

colytra modes (UNISON mode)

There is no difference to speak-of between the NORMAL (separate durability) and UNISON (merged durability with the chestplate) modes from the NBT perspective. The produced Colytra tag contains all the same information.

In UNISON mode, the durability is taken from the main chestplate, so the durability of the colytra tag itself is irrelevant (and this mod should not display it). A simple enough approach is to show the colytra durability only if Damage > 0.

This has an edge case if a user merges merges an already damaged elytra to form a UNISON colytra. This case cannot be distinguished easily from NORMAL mode, since the NBT will have Damage > 0. "Just don't do that" is maybe enough of an answer for this case. If one merges a repaired elytra, all would work as intended.

commented

Yes, disabling the addon is a broken use case. The NBT data is still there after all. And I don't want to check for the addon in any other way than checking for the NBT, because that opens a whole other can of worms, like class loading order, what if the owner of colytra changes the class layout, and all this kind of stuff.

Putting the elytra next to the chestpiece isn't as easy as it sounds either. because the chestpiece doesn't have a fixed place; if you have no helmet, the chestpiece goes up one row. In that case, the elytra would need to be above the chest icon (which itself can be turned off and on in options), so, just too many dependencies here.

To render the elytra, I'm creating an internal itemstack that has just a plain elytra. I could think about copying the enchantments from the chest to that stack. But what happens/should happen if the chest has just protection/thorns, no unbreaking/mending? What happens to the enchantments anyway if you combine enchanted elytra and enchanted chestplate, and how do the various modes of the colytra mod affect that?

commented

Colytra author has fixed the 'edge case'. When in UNISON mode, the colytra damage is now reset to 0.