Отображение атрибутов на броне

Версия Minecraft
1.16.5
API
Forge
76
3
5
Добавил атрибуты к броне, но при наведении на один из его комплекта выводит все атрибуты.
Java:
@Override
    public Multimap<Attribute, AttributeModifier> getAttributeModifiers(EquipmentSlotType slot, ItemStack stack) {
        Multimap<Attribute, AttributeModifier> map = HashMultimap.create();
        switch (slot) {
            case HEAD:
                map.put(Attributes.MAX_HEALTH,
                        new AttributeModifier(new UUID(171328 ,slot.getIndex()), "Armor modifier" + slot, 5,
                                AttributeModifier.Operation.fromValue(0)));
            case CHEST:
                map.put(Attributes.MAX_HEALTH,
                        new AttributeModifier(new UUID(171328 ,slot.getIndex()), "Armor modifier" + slot, 4,
                                AttributeModifier.Operation.fromValue(0)));
            case LEGS:
                map.put(Attributes.MAX_HEALTH,
                        new AttributeModifier(new UUID(171328 ,slot.getIndex()), "Armor modifier" + slot, 3,
                                AttributeModifier.Operation.fromValue(0)));
            case FEET:
                map.put(Attributes.MAX_HEALTH,
                        new AttributeModifier(new UUID(171328 ,slot.getIndex()), "Armor modifier" + slot, 2,
                                AttributeModifier.Operation.fromValue(0)));
        }
        return map;
    }
 

Вложения

  • Screenshot_1.png
    Screenshot_1.png
    40.7 KB · Просмотры: 15
А что этот код должен делать?
Он показывает все доп атрибуты всех вещей при наведении на одну.
На скрине ботинки, но на них же отображены и другие доп атрибуты частей брони.
Мне нужно, что бы при наведении на ботинки показывало только доп атрибуты ботинок и т.д.
 
Мне нужно, что бы при наведении на ботинки показывало только доп атрибуты ботинок и т.д.
Тогда надо перехватывать момент, когда эти атрибуты попадают в tooltip.
Метод getTooltipLines. Здесь надо поставить миксин, чтобы перехватить и изменить multimap.
Java:
...
if (shouldShowInTooltip(j, ItemStack.TooltipPart.MODIFIERS)) {
    for(EquipmentSlot equipmentslot : EquipmentSlot.values()) {
        Multimap<Attribute, AttributeModifier> multimap = this.getAttributeModifiers(equipmentslot);
        if (!multimap.isEmpty()) {
            ...
Только надо ещё узнать в каком слоте находится предмет.
 
Последнее редактирование:
Назад
Сверху