From 6b50b6cb3b8de4ee63df1277c220b67f4cd0184d Mon Sep 17 00:00:00 2001 From: radimous Date: Wed, 22 Jan 2025 07:10:23 +0100 Subject: [PATCH] unique support 90% done --- .../com/radimous/vhatcaniroll/Config.java | 16 +- .../vhatcaniroll/logic/Modifiers.java | 252 +++++++++++++----- ...ilityFloatValueAttributeReaderInvoker.java | 12 + .../ui/UniqueGearListContainer.java | 151 +++++------ .../assets/vhatcaniroll/lang/en_us.json | 3 +- src/main/resources/vhatcaniroll.mixins.json | 7 +- 6 files changed, 277 insertions(+), 164 deletions(-) create mode 100644 src/main/java/com/radimous/vhatcaniroll/mixin/AbilityFloatValueAttributeReaderInvoker.java diff --git a/src/main/java/com/radimous/vhatcaniroll/Config.java b/src/main/java/com/radimous/vhatcaniroll/Config.java index 47e7a34..5df0886 100644 --- a/src/main/java/com/radimous/vhatcaniroll/Config.java +++ b/src/main/java/com/radimous/vhatcaniroll/Config.java @@ -11,11 +11,12 @@ public class Config { public static final ForgeConfigSpec.IntValue BUTTON_X; public static final ForgeConfigSpec.IntValue BUTTON_Y; public static final ForgeConfigSpec.IntValue MAX_LEVEL_OVERRIDE; - public static final ForgeConfigSpec.BooleanValue SHOW_ABILITY_ENHANCEMENTS; + public static final ForgeConfigSpec.BooleanValue SHOW_ABILITY_ENHANCEMENTS; public static final ForgeConfigSpec.BooleanValue SHOW_WEIGHT; public static final ForgeConfigSpec.BooleanValue SHOW_CHANCE; public static final ForgeConfigSpec.BooleanValue QOL_HUNTERS_CONFLICT_RESOLUTION; public static final ForgeConfigSpec.BooleanValue SHOW_UNOBTAINABLE_CRAFTED; + public static final ForgeConfigSpec.BooleanValue DEBUG_UNIQUE_GEAR; // string instead of enum, because forge would remove enum values that are not present in the enum // (this could cause problems if mods are extending the enum - like wold's) public static final ForgeConfigSpec.ConfigValue> AFFIX_TAG_GROUP_CHANCE_BLACKLIST; @@ -41,11 +42,16 @@ public class Config { QOL_HUNTERS_CONFLICT_RESOLUTION = builder .comment("QOL Hunters conflict resolution (shouldn't be disabled unless it causes issues)") .define("QOLHuntersConflictResolution", true); - builder.pop(); - + AFFIX_TAG_GROUP_CHANCE_BLACKLIST = builder + .comment("vhcir won't show chance/weight for affixes in these groups") + .define("affixTagGroupBlacklist", List.of(VaultGearTierConfig.ModifierAffixTagGroup.CRAFTED_PREFIX.name(), VaultGearTierConfig.ModifierAffixTagGroup.CRAFTED_SUFFIX.name())); MAX_LEVEL_OVERRIDE = builder .comment("override max level") .defineInRange("maxLevelOverride", -1, -1, Integer.MAX_VALUE); + DEBUG_UNIQUE_GEAR = builder + .comment("debug unique gear") + .define("debugUniqueGear", false); + builder.pop(); SHOW_ABILITY_ENHANCEMENTS = builder .comment("show ability enhancements") @@ -59,10 +65,6 @@ public class Config { .comment("show chance") .define("showChance", true); - AFFIX_TAG_GROUP_CHANCE_BLACKLIST = builder - .comment("vhcir won't show chance/weight for affixes in these groups") - .define("affixTagGroupBlacklist", List.of(VaultGearTierConfig.ModifierAffixTagGroup.CRAFTED_PREFIX.name(), VaultGearTierConfig.ModifierAffixTagGroup.CRAFTED_SUFFIX.name())); - SHOW_UNOBTAINABLE_CRAFTED = builder .comment("show unobtainable crafted modifiers (above current lvl)") .define("showUnobtainableCrafted", false); diff --git a/src/main/java/com/radimous/vhatcaniroll/logic/Modifiers.java b/src/main/java/com/radimous/vhatcaniroll/logic/Modifiers.java index d4fe02e..547a638 100644 --- a/src/main/java/com/radimous/vhatcaniroll/logic/Modifiers.java +++ b/src/main/java/com/radimous/vhatcaniroll/logic/Modifiers.java @@ -1,15 +1,27 @@ package com.radimous.vhatcaniroll.logic; import com.radimous.vhatcaniroll.Config; +import com.radimous.vhatcaniroll.mixin.AbilityFloatValueAttributeReaderInvoker; import com.radimous.vhatcaniroll.mixin.EffectConfigAccessor; import com.radimous.vhatcaniroll.mixin.VaultGearTierConfigAccessor; +import iskallia.vault.config.UniqueGearConfig; import iskallia.vault.config.gear.VaultGearTierConfig; import iskallia.vault.gear.attribute.VaultGearAttribute; import iskallia.vault.gear.attribute.VaultGearAttributeRegistry; +import iskallia.vault.gear.attribute.VaultGearModifier; +import iskallia.vault.gear.attribute.ability.AbilityAreaOfEffectPercentAttribute; import iskallia.vault.gear.attribute.ability.AbilityLevelAttribute; +import iskallia.vault.gear.attribute.ability.special.EntropyPoisonModification; +import iskallia.vault.gear.attribute.ability.special.FrostNovaVulnerabilityModification; +import iskallia.vault.gear.attribute.ability.special.base.SpecialAbilityConfig; +import iskallia.vault.gear.attribute.ability.special.base.SpecialAbilityGearAttribute; +import iskallia.vault.gear.attribute.ability.special.base.SpecialAbilityModification; +import iskallia.vault.gear.attribute.ability.special.base.template.config.IntRangeConfig; +import iskallia.vault.gear.attribute.ability.special.base.template.value.IntValue; import iskallia.vault.gear.attribute.config.BooleanFlagGenerator; import iskallia.vault.gear.attribute.config.ConfigurableAttributeGenerator; import iskallia.vault.gear.attribute.custom.effect.EffectGearAttribute; +import iskallia.vault.gear.reader.VaultGearModifierReader; import iskallia.vault.init.ModConfigs; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; @@ -20,6 +32,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraftforge.fml.LogicalSide; import org.jetbrains.annotations.NotNull; +import java.text.DecimalFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -40,19 +53,29 @@ public class Modifiers { public static List getModifierList(int lvl, VaultGearTierConfig cfg, ModifierCategory modifierCategory) { Map modifierGroup = ((VaultGearTierConfigAccessor) cfg).getModifierGroup(); - + ArrayList modList = new ArrayList<>(); for (VaultGearTierConfig.ModifierAffixTagGroup affixTagGroup : modifierGroup.keySet()) { - modList.addAll(getAffixGroupComponents(lvl, affixTagGroup, modifierGroup, modifierCategory)); + modList.addAll(getAffixGroupComponents(lvl, affixTagGroup, modifierGroup.get(affixTagGroup), modifierCategory)); } return modList; } - private static List getAffixGroupComponents(int lvl, VaultGearTierConfig.ModifierAffixTagGroup affixTagGroup, - Map modifierGroup, - ModifierCategory modifierCategory) { + public static List getUniqueModifierList(int lvl, ModifierCategory modifierCategory, Map> modifierIdentifiers) { + ArrayList modList = new ArrayList<>(); + + for (Map.Entry> modifierIdentifier : modifierIdentifiers.entrySet()) { + modList.addAll(getUniqueAffixComponents(lvl, modifierIdentifier, modifierCategory)); + } + + return modList; + } + + public static List getAffixGroupComponents(int lvl, VaultGearTierConfig.ModifierAffixTagGroup affixTagGroup, + VaultGearTierConfig.AttributeGroup modifierGroups, + ModifierCategory modifierCategory) { ArrayList componentList = new ArrayList<>(); if (!Config.SHOW_ABILITY_ENHANCEMENTS.get() && affixTagGroup.equals(VaultGearTierConfig.ModifierAffixTagGroup.ABILITY_ENHANCEMENT)) { @@ -60,14 +83,14 @@ public class Modifiers { } - Map groupCounts = countGroups(lvl, affixTagGroup, modifierGroup, modifierCategory); + Map groupCounts = countGroups(lvl, modifierGroups, modifierCategory); AtomicBoolean noWeightAttr = new AtomicBoolean(false); - int totalWeight = modifierGroup.get(affixTagGroup).stream() + int totalWeight = modifierGroups.stream() .mapToInt(modTierGroup -> getModifierTiers(lvl, modTierGroup, modifierCategory).stream().mapToInt( tier -> { if ((affixTagGroup == VaultGearTierConfig.ModifierAffixTagGroup.IMPLICIT - || affixTagGroup == VaultGearTierConfig.ModifierAffixTagGroup.BASE_ATTRIBUTES) && groupCounts.get(modTierGroup.getModifierGroup()) == 1) { + || affixTagGroup == VaultGearTierConfig.ModifierAffixTagGroup.BASE_ATTRIBUTES) && groupCounts.get(modTierGroup.getModifierGroup()) == 1) { noWeightAttr.set(true); return 0; } @@ -88,10 +111,8 @@ public class Modifiers { componentList.add(new TextComponent("Total Weight: " + totalWeight).withStyle(ChatFormatting.BOLD)); } - - Map> groupedModifiers = new HashMap<>(); - for (VaultGearTierConfig.ModifierTierGroup modifierTierGroup : modifierGroup.get(affixTagGroup)) { + for (VaultGearTierConfig.ModifierTierGroup modifierTierGroup :modifierGroups) { ArrayList> mTierList; mTierList = getModifierTiers(lvl, modifierTierGroup, modifierCategory); @@ -99,11 +120,10 @@ public class Modifiers { continue; } String modGr = modifierTierGroup.getModifierGroup(); - - + + MutableComponent modComp = getModifierComponent(VaultGearAttributeRegistry.getAttribute(modifierTierGroup.getAttribute()),mTierList); -// //if (implicit||base) && groupCounts == 0 if (!( (affixTagGroup == VaultGearTierConfig.ModifierAffixTagGroup.BASE_ATTRIBUTES || affixTagGroup == VaultGearTierConfig.ModifierAffixTagGroup.IMPLICIT @@ -114,7 +134,7 @@ public class Modifiers { modComp.append(new TextComponent(" w"+weight).withStyle(ChatFormatting.GRAY)); } - if (Config.SHOW_CHANCE.get() && shouldShowWeight(modifierCategory, affixTagGroup)) { + if (Config.SHOW_CHANCE.get() && shouldShowWeight(modifierCategory, affixTagGroup) && totalWeight > 0) { modComp.append(new TextComponent(String.format(" %.2f%%", ((double) weight * 100 / totalWeight))).withStyle(ChatFormatting.GRAY)); } } @@ -136,22 +156,55 @@ public class Modifiers { boolean useNums = groupedModifiers.size() > COLORS.length; int i = 0; for (var modGr: groupedModifiers.values()) { - for (var mod: modGr) { - MutableComponent full = new TextComponent(useNums ? i + " " : "► ").withStyle(COLORS[i % COLORS.length]); - full.append(mod); - componentList.add(full); - } - i++; + for (var mod: modGr) { + MutableComponent full = new TextComponent(useNums ? i + " " : "► ").withStyle(COLORS[i % COLORS.length]); + full.append(mod); + componentList.add(full); + } + i++; } componentList.add(TextComponent.EMPTY); return componentList; } - private static Map countGroups(int lvl, VaultGearTierConfig.ModifierAffixTagGroup affixTagGroup, - Map modifierGroup, - ModifierCategory modifierCategory) { + /** + * Same as getAffixGroupComponents, but for unique gear without chances and groups + */ + public static List getUniqueAffixComponents(int lvl,Map.Entry> modifierIdentifier, ModifierCategory modifierCategory) { + + ArrayList componentList = new ArrayList<>(); + if (modifierIdentifier.getValue().isEmpty()) { + return componentList; // no affix for this type + } + UniqueGearConfig.AffixTargetType affixTagGroup = modifierIdentifier.getKey(); + componentList.add(new TextComponent(affixTagGroup.toString().replace("_", " ")).withStyle(ChatFormatting.BOLD)); + for (ResourceLocation modifier : modifierIdentifier.getValue()) { + VaultGearTierConfig.ModifierTierGroup modifierTierGroup = ModConfigs.VAULT_GEAR_CONFIG.get(VaultGearTierConfig.UNIQUE_ITEM).getTierGroup(modifier); + if (modifierTierGroup == null) { + continue; + } + ArrayList> mTierList; + mTierList = getModifierTiers(lvl, modifierTierGroup, modifierCategory); + if (mTierList.isEmpty()) { + continue; + } + MutableComponent modComp = getModifierComponent(VaultGearAttributeRegistry.getAttribute(modifierTierGroup.getAttribute()),mTierList); + MutableComponent full = new TextComponent(" "); + full.append(modComp); + componentList.add(full); + } + + if (componentList.size() == 1) { // only header + return new ArrayList<>(); // no affixes for this type (all tiers are unobtainable) + } + + componentList.add(TextComponent.EMPTY); + return componentList; + } + + private static Map countGroups(int lvl, VaultGearTierConfig.AttributeGroup modifierTierGroups, ModifierCategory modifierCategory) { Map groupCounts = new HashMap<>(); - for (VaultGearTierConfig.ModifierTierGroup modifierTierGroup : modifierGroup.get(affixTagGroup)) { + for (VaultGearTierConfig.ModifierTierGroup modifierTierGroup : modifierTierGroups) { ArrayList> mTierList; mTierList = getModifierTiers(lvl, modifierTierGroup, modifierCategory); if (mTierList.isEmpty()) { @@ -163,8 +216,7 @@ public class Modifiers { return groupCounts; } - public static ArrayList> getModifierTiers(int lvl, - VaultGearTierConfig.ModifierTierGroup modifierTierGroup, ModifierCategory modifierCategory) { + public static ArrayList> getModifierTiers(int lvl, VaultGearTierConfig.ModifierTierGroup modifierTierGroup, ModifierCategory modifierCategory) { if (modifierCategory == ModifierCategory.NORMAL) { return getNormalModifierTiers(lvl, modifierTierGroup); @@ -223,7 +275,11 @@ public class Modifiers { String atrName = atrRegName.toString(); var minConfigDisplay = atrGenerator.getConfigDisplay(atr.getReader(), minConfig); - + + if (minConfig instanceof SpecialAbilityGearAttribute.SpecialAbilityTierConfig minConfigSpecial) { + return getSpecialAbilityAttributeComponent(modifierTiers, minConfigSpecial); + } + MutableComponent res = null; if (modifierTiers.size() > 1) { res = rangeComponent(atrName, atr, atrGenerator, minConfig, maxConfig); @@ -240,11 +296,43 @@ public class Modifiers { if (minConfig instanceof EffectGearAttribute.Config ) { return minConfigDisplay; } + + if (minConfig instanceof AbilityAreaOfEffectPercentAttribute.Config minConfigA) { + return getAbilityAoePercentageComponent(atr, minConfigA, minConfigA); + } return res; } return new TextComponent("ERR - NULL DISPLAY " + atrName); } + @SuppressWarnings("unchecked") // this thing is insane + private static @NotNull MutableComponent getSpecialAbilityAttributeComponent( + ArrayList> modifierTiers, + SpecialAbilityGearAttribute.SpecialAbilityTierConfig minConfigSpecial) { + var modification = minConfigSpecial.getModification(); + if (modification instanceof FrostNovaVulnerabilityModification frostNovaVulnerabilityModification) { + var minToMaxComponent = new TextComponent(""); + return (new TextComponent("Frost Nova also applies Level ").append(minToMaxComponent) + .append(" Vulnerability")); + } + if (modification instanceof EntropyPoisonModification entropyPoisonModification) { + var tiers = (List, IntRangeConfig, IntValue>>) modifierTiers.stream().map(x -> x.getModifierConfiguration()).toList(); + var minValue = entropyPoisonModification.getMinimumValue(tiers); + var minValueDisplay = new TextComponent(minValue.map(x -> String.valueOf(x.getValue().getValue())).orElse("NULL")); + var maxValue = entropyPoisonModification.getMaximumValue(tiers); + var maxValueDisplay = new TextComponent(maxValue.map(x -> String.valueOf(x.getValue().getValue())).orElse("NULL")); + MutableComponent cmp = new TextComponent("Entropic Bind also applies Poison "); + var range = new TextComponent(minValueDisplay.getString() + "-" + maxValueDisplay.getString()); + cmp.append(range); + return cmp; + } + var abilityKey = minConfigSpecial.getAbilityKey(); + return ModConfigs.ABILITIES.getAbilityById(abilityKey).filter(skill -> skill.getName() != null).map(skill -> { + String name = skill.getName(); + return new TextComponent("Special " + name + " modification"); + }).orElseGet(() -> (TextComponent) new TextComponent(abilityKey).withStyle(Style.EMPTY.withColor(14076214))); + } + /** * This method handles combining multiple configs into a single component * VH doesn't have method for this, so we need to do it manually @@ -252,43 +340,83 @@ public class Modifiers { * and combining it with normal display for single component (that has name and color) */ private static MutableComponent rangeComponent(String atrName, VaultGearAttribute atr, - ConfigurableAttributeGenerator atrGenerator, C minConfig, C maxConfig) { - MutableComponent res = atrGenerator.getConfigRangeDisplay(atr.getReader(), minConfig, maxConfig); - var minConfigDisplay = atrGenerator.getConfigDisplay(atr.getReader(), minConfig); - var maxConfigDisplay = atrGenerator.getConfigDisplay(atr.getReader(), maxConfig); + ConfigurableAttributeGenerator atrGenerator, C minConfig, C maxConfig) { + MutableComponent res = atrGenerator.getConfigRangeDisplay(atr.getReader(), minConfig, maxConfig); + var minConfigDisplay = atrGenerator.getConfigDisplay(atr.getReader(), minConfig); + var maxConfigDisplay = atrGenerator.getConfigDisplay(atr.getReader(), maxConfig); - if (res != null && minConfig instanceof AbilityLevelAttribute.Config minConfigAbility) { - return abilityLvlComponent(res, atr, minConfigAbility); - } - - if ((atrName.equals("the_vault:effect_avoidance") || atrName.equals("the_vault:effect_list_avoidance")) && minConfigDisplay != null) { - // res -> "30% - 50%" - // single -> "30% Poison Avoidance" - // minRange -> "30%" - var single = minConfigDisplay.withStyle(atr.getReader().getColoredTextStyle()); - var minRange = atrGenerator.getConfigRangeDisplay(atr.getReader(), minConfig, minConfig); - if (minRange != null && res != null) { - res.append(single.getString().replace(minRange.getString(), "")); - // res -> "30% - 50% Poison Avoidance" - } - } - if (minConfigDisplay != null && maxConfigDisplay != null && (atrName.equals("the_vault:effect_cloud") || atrName.equals("the_vault:effect_cloud_when_hit"))) { - return getCloudRangeComponent(minConfigDisplay, maxConfigDisplay, atr); - } + if (res != null && minConfig instanceof AbilityLevelAttribute.Config minConfigAbility) { + return abilityLvlComponent(res, atr, minConfigAbility); + } - if (minConfig instanceof EffectGearAttribute.Config minEffectConfig - && maxConfig instanceof EffectGearAttribute.Config - && maxConfigDisplay != null) { - var effectStr = ((EffectConfigAccessor)minEffectConfig).getAmplifier() + "-" + - maxConfigDisplay.getString(); - return new TextComponent(effectStr).withStyle(atr.getReader().getColoredTextStyle()); + if ((atrName.equals("the_vault:effect_avoidance") || atrName.equals("the_vault:effect_list_avoidance")) && minConfigDisplay != null) { + // res -> "30% - 50%" + // single -> "30% Poison Avoidance" + // minRange -> "30%" + var single = minConfigDisplay.withStyle(atr.getReader().getColoredTextStyle()); + var minRange = atrGenerator.getConfigRangeDisplay(atr.getReader(), minConfig, minConfig); + if (minRange != null && res != null) { + res.append(single.getString().replace(minRange.getString(), "")); + // res -> "30% - 50% Poison Avoidance" + } + } + if (minConfigDisplay != null && maxConfigDisplay != null && (atrName.equals("the_vault:effect_cloud") || atrName.equals("the_vault:effect_cloud_when_hit"))) { + return getCloudRangeComponent(minConfigDisplay, maxConfigDisplay, atr); + } - } - if (res != null) { - return atr.getReader().formatConfigDisplay(LogicalSide.CLIENT, res); - } - return res; + if ((minConfig instanceof AbilityAreaOfEffectPercentAttribute.Config minConfigA) && (maxConfig instanceof AbilityAreaOfEffectPercentAttribute.Config maxConfigA)) { + return getAbilityAoePercentageComponent(atr, minConfigA, maxConfigA); + } + + if (minConfig instanceof EffectGearAttribute.Config minEffectConfig + && maxConfig instanceof EffectGearAttribute.Config + && maxConfigDisplay != null) { + var effectStr = ((EffectConfigAccessor)minEffectConfig).getAmplifier() + "-" + + maxConfigDisplay.getString(); + return new TextComponent(effectStr).withStyle(atr.getReader().getColoredTextStyle()); + } + + if (atrName.equals("the_vault:effect_cloud")){ + return new TextComponent("Special ability modification"); + } + + if (res != null) { + return atr.getReader().formatConfigDisplay(LogicalSide.CLIENT, res); + } + return res; + } + + private static @NotNull MutableComponent getAbilityAoePercentageComponent(VaultGearAttribute atr, + AbilityAreaOfEffectPercentAttribute.Config minConfigA, + AbilityAreaOfEffectPercentAttribute.Config maxConfigA) { + float min = minConfigA.getMin(); + float max = maxConfigA.generateMaximumValue(); + + VaultGearModifierReader reader = atr.getReader(); + MutableComponent minValueDisplay = new TextComponent(new DecimalFormat("0.#").format(Math.abs(min * 100.0F)) + "%"); + MutableComponent maxValueDisplay = new TextComponent(new DecimalFormat("0.#").format(Math.abs(max * 100.0F)) + "%"); + boolean positive = min > 0; + MutableComponent areaCmp = new TextComponent("Area Of Effect").withStyle(Style.EMPTY.withColor(ModConfigs.COLORS.getColor("areaOfEffect"))); + String cdInfo; + if (positive) { + cdInfo = " more "; + } else { + cdInfo = " less "; + } + + return new TextComponent("") + .append(VaultGearModifier.AffixType.IMPLICIT.getAffixPrefixComponent(true) + .withStyle(Style.EMPTY.withColor(6082075))) + .append(minValueDisplay.withStyle(Style.EMPTY.withColor(6082075))) + .append(new TextComponent("-").withStyle(Style.EMPTY.withColor(6082075))) + .append(maxValueDisplay.withStyle(Style.EMPTY.withColor(6082075))) + .append(cdInfo) + .append(areaCmp) + .append(" of ") + .append( + ((AbilityFloatValueAttributeReaderInvoker) reader).invokeFormatAbilityName(minConfigA.getAbilityKey())) + .setStyle(reader.getColoredTextStyle()); } private static MutableComponent getCloudRangeComponent(MutableComponent minConfigDisplay, MutableComponent maxConfigDisplay, VaultGearAttribute atr) { @@ -356,7 +484,7 @@ public class Modifiers { abComp.append(new TextComponent(abName).withStyle(Style.EMPTY.withColor(14076214))); return abComp; } - + private static int modTierListWeight(List> val) { if (val == null || val.isEmpty()) { return 0; diff --git a/src/main/java/com/radimous/vhatcaniroll/mixin/AbilityFloatValueAttributeReaderInvoker.java b/src/main/java/com/radimous/vhatcaniroll/mixin/AbilityFloatValueAttributeReaderInvoker.java new file mode 100644 index 0000000..8aa5806 --- /dev/null +++ b/src/main/java/com/radimous/vhatcaniroll/mixin/AbilityFloatValueAttributeReaderInvoker.java @@ -0,0 +1,12 @@ +package com.radimous.vhatcaniroll.mixin; + +import iskallia.vault.gear.attribute.ability.AbilityFloatValueAttribute; +import net.minecraft.network.chat.MutableComponent; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(AbilityFloatValueAttribute.Reader.class) +public interface AbilityFloatValueAttributeReaderInvoker { + @Invoker + MutableComponent invokeFormatAbilityName(String abilityKey); +} diff --git a/src/main/java/com/radimous/vhatcaniroll/ui/UniqueGearListContainer.java b/src/main/java/com/radimous/vhatcaniroll/ui/UniqueGearListContainer.java index dd1d9ac..a096f4e 100644 --- a/src/main/java/com/radimous/vhatcaniroll/ui/UniqueGearListContainer.java +++ b/src/main/java/com/radimous/vhatcaniroll/ui/UniqueGearListContainer.java @@ -1,11 +1,14 @@ package com.radimous.vhatcaniroll.ui; +import com.radimous.vhatcaniroll.Config; import com.radimous.vhatcaniroll.logic.ModifierCategory; import com.radimous.vhatcaniroll.logic.Modifiers; import com.radimous.vhatcaniroll.mixin.UniqueGearConfigAccessor; import com.radimous.vhatcaniroll.mixin.VaultGearTierConfigAccessor; import iskallia.vault.client.gui.framework.ScreenTextures; +import iskallia.vault.client.gui.framework.element.FakeItemSlotElement; import iskallia.vault.client.gui.framework.element.LabelElement; +import iskallia.vault.client.gui.framework.element.NineSliceElement; import iskallia.vault.client.gui.framework.element.VerticalScrollClipContainer; import iskallia.vault.client.gui.framework.spatial.Padding; import iskallia.vault.client.gui.framework.spatial.Spatials; @@ -13,33 +16,24 @@ import iskallia.vault.client.gui.framework.spatial.spi.ISpatial; import iskallia.vault.client.gui.framework.text.LabelTextStyle; import iskallia.vault.config.UniqueGearConfig; import iskallia.vault.config.gear.VaultGearTierConfig; -import iskallia.vault.gear.attribute.VaultGearAttributeRegistry; +import iskallia.vault.gear.VaultGearState; +import iskallia.vault.gear.data.VaultGearData; import iskallia.vault.init.ModConfigs; +import iskallia.vault.init.ModGearAttributes; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.TextComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; -import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.Optional; public class UniqueGearListContainer extends VerticalScrollClipContainer implements InnerGearScreen { public UniqueGearListContainer(ISpatial spatial, int lvl, ModifierCategory modifierCategory, ItemStack gearPiece) { super(spatial, Padding.ZERO, ScreenTextures.INSET_BLACK_BACKGROUND); int labelX = 9; - int labelY = 20; - - - // Label for the item name and level (GOLD if legendary, AQUA if greater, WHITE if common) - LabelElement itemName = new LabelElement<>( - Spatials.positionXY(labelX, 5).width(this.innerWidth() - labelX).height(15), new TextComponent( - gearPiece.getItem().toString().toUpperCase() + " - LVL " + lvl) - .withStyle(ChatFormatting.UNDERLINE).withStyle(modifierCategory.getStyle()), LabelTextStyle.defaultStyle() - ); - this.addElement(itemName); + int labelY = 9; Map uniqueRegistry = ((UniqueGearConfigAccessor) ModConfigs.UNIQUE_GEAR).getRegistry(); var regName = gearPiece.getItem().getRegistryName(); @@ -51,103 +45,78 @@ public class UniqueGearListContainer extends VerticalScrollClipContainer entry.getValue().getModel() != null && entry.getValue().getModel().toString().contains(regPath)).toList(); List> badEntries = uniqueRegistry.entrySet().stream().filter(entry -> entry.getValue().getModel() == null || !entry.getValue().getModel().toString().contains(regPath)).toList(); + var uniqueConfig1 = (VaultGearTierConfigAccessor) ModConfigs.VAULT_GEAR_CONFIG.get(VaultGearTierConfig.UNIQUE_ITEM); if (uniqueConfig1 == null) { return; } for (var entry : goodEntries) { var value = entry.getValue(); - ResourceLocation id = value.getId() == null ? new ResourceLocation("minecraft", "missing") : value.getId(); - String name = value.getName() == null ? "missing" : value.getName(); - ResourceLocation model = value.getModel() == null ? new ResourceLocation("minecraft", "missing") : value.getModel(); + String name = value.getName(); + if (name == null) { + continue; + } + ResourceLocation model = value.getModel(); + if (model == null) { + continue; + } - List modifierTags = value.getModifierTags() == null ? List.of("missing") : value.getModifierTags(); - Map> modifierIdentifiers = value.getModifierIdentifiers() == null ? Map.of(UniqueGearConfig.AffixTargetType.PREFIX, List.of(new ResourceLocation("minecraft", "missing"))) : value.getModifierIdentifiers(); + Map> modifierIdentifiers = value.getModifierIdentifiers(); + if (modifierIdentifiers == null) { + continue; + } + int iconHeight = labelY; - LabelElement idLabel = new LabelElement<>( - Spatials.positionXY(labelX, labelY).width(this.innerWidth() - labelX).height(15), - new TextComponent( - "ID: " + id.toString()), LabelTextStyle.defaultStyle() - ); - this.addElement(idLabel); - labelY += 10; + labelY += 5; LabelElement nameLabel = new LabelElement<>( - Spatials.positionXY(labelX, labelY).width(this.innerWidth() - labelX).height(15), - new TextComponent( - "Name: " + name), LabelTextStyle.defaultStyle() + Spatials.positionXY(labelX + 20, labelY).width(this.innerWidth() - labelX).height(15), + new TextComponent(name), LabelTextStyle.defaultStyle() ); this.addElement(nameLabel); + labelY += 20; + + ItemStack displayStack = new ItemStack(gearPiece.getItem()); + VaultGearData gearData = VaultGearData.read(displayStack); + gearData.setState(VaultGearState.IDENTIFIED); + gearData.createOrReplaceAttributeValue(ModGearAttributes.GEAR_MODEL, model); + gearData.write(displayStack); + this.addElement(new FakeItemSlotElement<>(Spatials.positionXY(labelX - 4, iconHeight).width(16).height(16), () -> displayStack, () -> false, ScreenTextures.EMPTY, ScreenTextures.EMPTY)); + + + var mlist = Modifiers.getUniqueModifierList(lvl, modifierCategory, modifierIdentifiers); + for (var mc : mlist) { + LabelElement mcl = new LabelElement<>( + Spatials.positionXY(labelX, labelY).width(this.innerWidth() - labelX).height(15), + mc, LabelTextStyle.defaultStyle()); + this.addElement(mcl); + labelY += 10; + } + this.addElement(new NineSliceElement<>( + Spatials.positionXY(0, labelY).width(this.innerWidth()).height(3), + ScreenTextures.BUTTON_EMPTY)); labelY += 10; - LabelElement modelLabel = new LabelElement<>( + } + if (Config.DEBUG_UNIQUE_GEAR.get()) { + this.addElement(new LabelElement<>( Spatials.positionXY(labelX, labelY).width(this.innerWidth() - labelX).height(15), - new TextComponent( - "Model: " + model.toString()), LabelTextStyle.defaultStyle() - ); - this.addElement(modelLabel); + new TextComponent("[DEBUG] BAD ENTRIES:").withStyle(ChatFormatting.RED), LabelTextStyle.defaultStyle())); labelY += 10; - LabelElement modifierTagsLabel = new LabelElement<>( - Spatials.positionXY(labelX, labelY).width(this.innerWidth() - labelX).height(15), - new TextComponent( - "Modifier Tags: " + modifierTags.toString()), LabelTextStyle.defaultStyle() - ); - this.addElement(modifierTagsLabel); - labelY += 10; - for (Map.Entry> modifierIdentifier : modifierIdentifiers.entrySet()) { - if (modifierIdentifier.getValue().isEmpty()) { + for (var entry : badEntries) { + this.addElement(new LabelElement<>( + Spatials.positionXY(labelX, labelY).width(this.innerWidth() - labelX).height(15), + new TextComponent("ID: " + entry.getKey().toString()).withStyle(ChatFormatting.RED), + LabelTextStyle.defaultStyle())); + labelY += 10; + var vv = entry.getValue(); + if (vv == null) { continue; } this.addElement(new LabelElement<>( Spatials.positionXY(labelX, labelY).width(this.innerWidth() - labelX).height(15), - new TextComponent(modifierIdentifier.getKey().toString()), LabelTextStyle.defaultStyle())); - labelY += 10; - for (ResourceLocation modifier : modifierIdentifier.getValue()) { - Map ff = uniqueConfig1.getModifierGroup(); - List kk = new ArrayList<>(); - for (Map.Entry f : ff.entrySet()) { - kk.add(f.getValue()); - } - var someModTierGroup = kk.get(0).get(0); - var mTierList = Modifiers.getModifierTiers(lvl,someModTierGroup , modifierCategory); - var mc = Modifiers.getModifierComponent(VaultGearAttributeRegistry.getAttribute(modifier),mTierList); - - //TODO: figure this out -// LabelElement mcl = new LabelElement<>( -// Spatials.positionXY(labelX, labelY).width(this.innerWidth() - labelX).height(15), -// mc, LabelTextStyle.defaultStyle()); -// this.addElement(mcl); - labelY += 10; - LabelElement modifierIdentifierLabel = new LabelElement<>( - Spatials.positionXY(labelX, labelY).width(this.innerWidth() - labelX).height(15), - new TextComponent(" " + modifier.toString()), LabelTextStyle.defaultStyle()); - this.addElement(modifierIdentifierLabel); - labelY += 10; - } - labelY += 10; + new TextComponent("Model: " + vv.getModel()).withStyle(ChatFormatting.RED), + LabelTextStyle.defaultStyle())); + labelY += 16; } - labelY += 10; - - this.addElement(new LabelElement<>( - Spatials.positionXY(labelX, labelY).width(this.innerWidth() - labelX).height(15), - new TextComponent("----------------------------------------"), LabelTextStyle.defaultStyle())); - labelY += 10; - } - this.addElement(new LabelElement<>( - Spatials.positionXY(labelX, labelY).width(this.innerWidth() - labelX).height(15), - new TextComponent("BAD ENTRIES:").withStyle(ChatFormatting.RED), LabelTextStyle.defaultStyle())); - labelY += 10; - for (var entry : badEntries) { - this.addElement(new LabelElement<>( - Spatials.positionXY(labelX, labelY).width(this.innerWidth() - labelX).height(15), - new TextComponent("ID: " + entry.getKey().toString()).withStyle(ChatFormatting.RED), LabelTextStyle.defaultStyle())); - labelY += 10; - var vv = entry.getValue(); - if (vv == null) { - continue; - } - this.addElement(new LabelElement<>( - Spatials.positionXY(labelX, labelY).width(this.innerWidth() - labelX).height(15), - new TextComponent("Model: " + vv.getModel()).withStyle(ChatFormatting.RED), LabelTextStyle.defaultStyle())); - labelY += 16; } } diff --git a/src/main/resources/assets/vhatcaniroll/lang/en_us.json b/src/main/resources/assets/vhatcaniroll/lang/en_us.json index c243b93..7c4f3e5 100644 --- a/src/main/resources/assets/vhatcaniroll/lang/en_us.json +++ b/src/main/resources/assets/vhatcaniroll/lang/en_us.json @@ -1,7 +1,8 @@ { "vhatcaniroll.screen.title.random": "Random Modifiers", "vhatcaniroll.screen.title.crafted": "Crafted Modifiers", - "vhatcaniroll.screen.title.transmogs": "Transmogs", + "vhatcaniroll.screen.title.unique": "Unique Gear", + "vhatcaniroll.screen.title.transmogs": "Transmogs", "vhatcaniroll.openmodscreen": "Open VHat can I roll? screen", "key.categories.vhatcaniroll": "VHat can I roll?" } diff --git a/src/main/resources/vhatcaniroll.mixins.json b/src/main/resources/vhatcaniroll.mixins.json index 8716526..ac758bc 100644 --- a/src/main/resources/vhatcaniroll.mixins.json +++ b/src/main/resources/vhatcaniroll.mixins.json @@ -7,10 +7,11 @@ "mixins": [ ], "client": [ - "StatisticsElementContainerScreenMixin", - "VaultGearTierConfigAccessor", "EffectConfigAccessor", - "UniqueGearConfigAccessor" + "StatisticsElementContainerScreenMixin", + "UniqueGearConfigAccessor", + "VaultGearTierConfigAccessor", + "AbilityFloatValueAttributeReaderInvoker" ], "injectors": { "defaultRequire": 1