Yarn: InfoEnchantment -> ?

Created on 13 Jan 2020  ·  15Comments  ·  Source: FabricMC/yarn

InfoEnchantment is not an enchantment called "Info", but a data object that stores an enchantment together with its level.

Suggested names:

  • EnchantmentState

    • > It's not a state either. A state sounds like a Map that is bound to an item stack to me.

      - @liach

  • EnchantmentEntry

    • A bit vague IMO, and doesn't really describe what it does.

  • EnchantmentInfo

    • To me, that sounds like a class that stores the description ("info") of an enchantment.

discussion refactor

Most helpful comment

What about renaming Enchantment to EnchantmentType and this one to Enchantment?

EnchantmentType still fits the other, and so does Enchantment for this class, since you could say that the entire thing (type + level) is an enchantment, like "Sharpness II" for example.

All 15 comments

EnchantmentInfo is probably the one that fits best out of those three. It's not perfect, but you could extrapolate the info as being the pairing of an "enchantment type" (Enchantment) with "enchantment level" (numeric).

What is it being used for, though?

It is used mostly in EnchantmentHelper to represent an enchantment that is going to be applied to an item.

So it's an application of an enchantment? Enchantment application? EnchantOptions or EnchantAttributes?

EnchantmentLevelPair?

What about EnchantmentInstance? A bit like StatusEffectInstance

not really an instance, and this class is actually very rarely used, more like a Map.Entry<Enchantment, Integer>

EnchantmentValue?

I am not following the first half of liach's logic, he doesn't really back up his "not really an instance" claim.

What I really have against EnchantmentInstance is that it's not very descriptive, sort of like StatusEffectInstance isn't very descriptive either, and neither is ItemInstance, which seems to be Mojang's name for ItemStack according to strings in the datafixers. The difference between the three is that for status effects, there doesn't really exist a better name, and it's hard to encompass its many fields into one name. ItemStack is a good alternative to ItemInstance as it's a well-established name that the wiki also uses, and makes logical sense.

I still think that EnchantmentLevelPair is the best name, as it contains only two fields, enchantment and level. And its usage also screams that it's basically a Pair<Enchantment, Integer>, that's used as a utility class inside EnchantmentHelper and iirc nowhere else.

ItemInstance, which seems to be Mojang's name for ItemStack according to strings in the datafixers.

The vanilla DFU type references use item_stack.

The vanilla DFU type references use item_stack.

Maybe a fix refers to that name somewhere?

EnchantmentStack

:tiny_potato:

Also why didn't we go with EnchantmentInfo before?

Do we have a EnchantmentLevel class? What about EnchantmentLevels (for more than once)?

The purpose of this class is to store an enchantment and level pair, so I suggest LevelledEnchantment or EnchantmentLevelPair.

EnchantmentStack doesn't work. You can only have a stack of concrete objects.

What about renaming Enchantment to EnchantmentType and this one to Enchantment?

EnchantmentType still fits the other, and so does Enchantment for this class, since you could say that the entire thing (type + level) is an enchantment, like "Sharpness II" for example.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Prospector picture Prospector  ·  15Comments

Runemoro picture Runemoro  ·  23Comments

Runemoro picture Runemoro  ·  10Comments

Runemoro picture Runemoro  ·  10Comments

jamierocks picture jamierocks  ·  13Comments