#Tooltip shows weirdly when setting attribute modifiers in MC 1.20.6

4 messages · Page 1 of 1 (latest)

mint locust
#

Is there a common reason why the values would show up like this and not how they normally do?

The source code of the method responsible for setting the attribute modifiers:
https://pastebin.com/ga5tP15A

(My Java and MC components knowledge is surface level but I do know how to program)

bleak acorn
#

Yes it is. It from mojang hardcode in tooltip can look into itemstack.class

mint locust
bleak acorn
#
private void appendAttributeModifierTooltip(Consumer<Text> textConsumer, @Nullable PlayerEntity player, RegistryEntry<EntityAttribute> attribute, EntityAttributeModifier modifier) {
        if (bl) {
            textConsumer.accept((Text)ScreenTexts.space().append((Text)Text.translatable((String)("attribute.modifier.equals." + modifier.operation().getId()), (Object[])new Object[]{AttributeModifiersComponent.DECIMAL_FORMAT.format(e), Text.translatable((String)((EntityAttribute)attribute.value()).getTranslationKey())})).formatted(Formatting.DARK_GREEN));
        } else if (d > 0.0) {
            textConsumer.accept((Text)Text.translatable((String)("attribute.modifier.plus." + modifier.operation().getId()), (Object[])new Object[]{AttributeModifiersComponent.DECIMAL_FORMAT.format(e), Text.translatable((String)((EntityAttribute)attribute.value()).getTranslationKey())}).formatted(((EntityAttribute)attribute.value()).getFormatting(true)));
        } else if (d < 0.0) {
            textConsumer.accept((Text)Text.translatable((String)("attribute.modifier.take." + modifier.operation().getId()), (Object[])new Object[]{AttributeModifiersComponent.DECIMAL_FORMAT.format(-e), Text.translatable((String)((EntityAttribute)attribute.value()).getTranslationKey())}).formatted(((EntityAttribute)attribute.value()).getFormatting(false)));
        }
    }