Minecraftforge: Revisit PR to allow changing enchantment glint colors

Created on 28 Jan 2018  路  6Comments  路  Source: MinecraftForge/MinecraftForge

There have been previous attempted PRs such as #4105. And the question comes up fairly regularly as it has some interest to modders.

As far as I can tell, the mods that do this use ASM. For example this mod does it: https://github.com/BoxOfFlex/CynTweaks/blob/master/src/main/java/cynfoxwell/cyntweaks/glint/RenderEffectVisitor.java

It also seems that you can do some tweaking by colorizing the glint.PNG file. It is currently in grayscale but gets blended with the default purple (which for example in LayerArmorBase.renderEnchantedGlint() sets color to GlStateManager.color(0.38F, 0.19F, 0.608F, 1.0F) which seems to be color 0x61319B).

Since it is blended, it is possible to tweak the color but not full control. Plus this change is set as a resource pack asset, not in code so doesn't lend itself to algorithmic changes. Also it would affect ALL glint, where a modder would really like ability to have different or changing glints.

Assuming the above is true (would love to hear if it is easier), the previous attempted PRs #4105 was perhaps overly complicated. It tried to instill the idea of multiple mods all overlaying each other. Ultimately that PR was closed as "stale".

I think the issue is still relevant though. I also think it may not be that hard to make a hook that is useful enough.

One easy hook of course is to simply allow overriding the color directly. This could even be really "dumb" where it didn't even give much context, just asked Forge for the enchantment color.

A more sophisticated hook would pass some information like the ItemStack so that the returned color value could be modified (such as by enchantment type, or other NBT info).

An even more powerful hook might be simply to provide an AddRenderLayerEvent event which would allow substitution of custom layer at the time an renderer is being constructed/initialized.

Anyway, just wanted to make sure this issue stays open and maybe get the creative juices flowing for anyone who might tackle it. I might get around to it myself, but am concentrating on some fluid stuff at the moment.

Stale

Most helpful comment

Hey leave this issue alone stale...
Glint colors are nice things

All 6 comments

@jabelar I'm willing to go back to working on this if the interest is there still. I still have the code stashed away on my PC and can update it pretty easily. The fluid system is definitely a more functionally important bit to get tackled

The original PR #2458 I made, yonks back, used an event for the effect pass handling and was shot down, which is fair enough since rendering is a bad spot for the event system as far as efficiency is concerned.

I then had a basic each handler has an item sort of deal going on. seemed to work till I toyed with the idea of writing a mod that'd add per enchantment effects for vanilla and such. Sort of like what WoW and Morrowind do. And that's where the original system hit the wall, since there wasn't a way to replace existing handlers, and for the mod added ones to coexist. Hence a wrapper system.

The wrapper was to avoid having unnecessary single value lists and for() calls for items that only use the vanilla handler, so using a wrapper system the majority of items just have a reference to a single handler. Maps were out of the question; IItemColor is referenced from a Map, and a single render call will run the map lookup per tinted quad, which can be hundreds of time per render call. Not a very performance friendly approach, at least as far as my understanding of OOP is concerned. I've often toyed with the idea of just rewriting that whole rendering pipeline to at least cache the IItemColor till the item is rendered.

I wasn't really clear on whether #4105 was too big in the sense of lines added, or just general complexity. So I let it go stale in favor of sacrificing readability to compress the source.

I think modders would like to have this control.

Regarding the complexity level, I'm kinda in favor of just keeping it simple. Like just intercepting the color value before it is used and giving opportunity to change it as an event. Imagine event is called when the glint color is needed, with the itemstack and existing glint color passed in. Then event handler could do things like always replace it with a color (allows things like rainbow effect), or could do per-enchantment color effects.

Anyway, I think it is still interesting.

This issue has been automatically marked as stale because it has not had activity in a long time. If this issue is still relevant and should remain open, please reply with a short explanation (e.g. "I have checked the code and this issue is still relevant because ___." or "Here's a screenshot of this issue on the latest version"). Thank you for your contributions!

Hey leave this issue alone stale...
Glint colors are nice things

This issue has been automatically marked as stale because it has not had activity in a long time. If this issue is still relevant and should remain open, please reply with a short explanation (e.g. "I have checked the code and this issue is still relevant because ___." or "Here's a screenshot of this issue on the latest version"). Thank you for your contributions!

This issue has been automatically closed because it has not had activity in a long time. Please feel free to reopen it or create a new issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

blay09 picture blay09  路  3Comments

ghost picture ghost  路  3Comments

DaedalusGame picture DaedalusGame  路  3Comments

darthvader45 picture darthvader45  路  3Comments

NovaViper picture NovaViper  路  3Comments