trying to add uniques

This commit is contained in:
radimous 2025-01-19 15:21:51 +01:00
parent 189a44e3c8
commit de646fd885
7 changed files with 222 additions and 13 deletions

View file

@ -163,7 +163,7 @@ public class Modifiers {
return groupCounts;
}
private static ArrayList<VaultGearTierConfig.ModifierTier<?>> getModifierTiers(int lvl,
public static ArrayList<VaultGearTierConfig.ModifierTier<?>> getModifierTiers(int lvl,
VaultGearTierConfig.ModifierTierGroup modifierTierGroup, ModifierCategory modifierCategory) {
if (modifierCategory == ModifierCategory.NORMAL) {
@ -200,7 +200,7 @@ public class Modifiers {
}
@SuppressWarnings("unchecked") // I don't think proper generics are possible, VaultGearTierConfig#getModifiersForLevel returns List<ModifierTier<?>>
private static <T, C> MutableComponent getModifierComponent(VaultGearAttribute<T> atr,
public static <T, C> MutableComponent getModifierComponent(VaultGearAttribute<T> atr,
ArrayList<VaultGearTierConfig.ModifierTier<?>> modifierTiers) {
if (modifierTiers.isEmpty()) {
return new TextComponent("ERR - EMPTY MODIFIER TIERS");

View file

@ -0,0 +1,18 @@
package com.radimous.vhatcaniroll.mixin;
import iskallia.vault.config.UniqueGearConfig;
import iskallia.vault.core.util.WeightedList;
import net.minecraft.resources.ResourceLocation;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.Map;
@Mixin(value = UniqueGearConfig.class, remap = false)
public interface UniqueGearConfigAccessor {
@Accessor
Map<ResourceLocation, UniqueGearConfig.Entry> getRegistry();
@Accessor
Map<ResourceLocation, WeightedList<ResourceLocation>> getPools();
}

View file

@ -47,7 +47,7 @@ public class GearModifierScreen extends AbstractElementScreen {
private LabelElement<?> modifierCategoryLabel;
private NineSliceButtonElement<?> modifierCategoryButton;
private HelpContainer helpContainer;
private LabelElement<?> windowName;
private LabelElement<?> windowNameLabel;
private int currIndex = 0;
private final List<TabElement<?>> tabs = new ArrayList<>();
@ -71,7 +71,7 @@ public class GearModifierScreen extends AbstractElementScreen {
new TranslatableComponent("vhatcaniroll.screen.title.random").withStyle(ChatFormatting.BLACK),
LabelTextStyle.defaultStyle()
).layout(this.translateWorldSpatial());
this.windowName = windowName;
this.windowNameLabel = windowName;
this.addElement(background);
this.addElement(windowName);
@ -97,6 +97,7 @@ public class GearModifierScreen extends AbstractElementScreen {
createModifierButton();
createTransmogButton();
createCraftedModsButton();
createUniqueGearButton();
}
// helper methods
@ -136,7 +137,7 @@ public class GearModifierScreen extends AbstractElementScreen {
this.modifierCategoryButton.setDisabled(true);
this.modifierCategoryButton.setVisible(false);
this.modifierCategoryLabel.setVisible(false);
this.windowName.set(new TranslatableComponent("vhatcaniroll.screen.title.transmogs").withStyle(ChatFormatting.BLACK));
this.windowNameLabel.set(new TranslatableComponent("vhatcaniroll.screen.title.transmogs").withStyle(ChatFormatting.BLACK));
this.addElement(this.innerScreen);
ScreenLayout.requestLayout();
}
@ -148,7 +149,7 @@ public class GearModifierScreen extends AbstractElementScreen {
this.modifierCategoryButton.setDisabled(false);
this.modifierCategoryButton.setVisible(true);
this.modifierCategoryLabel.setVisible(true);
this.windowName.set(new TranslatableComponent("vhatcaniroll.screen.title.random").withStyle(ChatFormatting.BLACK));
this.windowNameLabel.set(new TranslatableComponent("vhatcaniroll.screen.title.random").withStyle(ChatFormatting.BLACK));
this.addElement(this.innerScreen);
ScreenLayout.requestLayout();
}
@ -162,7 +163,21 @@ public class GearModifierScreen extends AbstractElementScreen {
this.modifierCategoryButton.setDisabled(true);
this.modifierCategoryButton.setVisible(false);
this.modifierCategoryLabel.setVisible(false);
this.windowName.set(new TranslatableComponent("vhatcaniroll.screen.title.crafted").withStyle(ChatFormatting.BLACK));
this.windowNameLabel.set(new TranslatableComponent("vhatcaniroll.screen.title.crafted").withStyle(ChatFormatting.BLACK));
this.addElement(this.innerScreen);
ScreenLayout.requestLayout();
}
private void switchToUnique(){
this.removeElement(this.innerScreen);
this.modifierCategory = ModifierCategory.NORMAL;
updateModifierCategoryButtonLabel();
ISpatial modListSpatial = Spatials.positionXY(7, 50).size(this.getGuiSpatial().width() - 14, this.getGuiSpatial().height() - 57);
this.innerScreen = new UniqueGearListContainer(modListSpatial, lvlInput.getValue(), modifierCategory, getCurrGear()).layout(this.translateWorldSpatial());
this.modifierCategoryButton.setDisabled(true);
this.modifierCategoryButton.setVisible(false);
this.modifierCategoryLabel.setVisible(false);
this.windowNameLabel.set(new TranslatableComponent("vhatcaniroll.screen.title.unique").withStyle(ChatFormatting.BLACK));
this.addElement(this.innerScreen);
ScreenLayout.requestLayout();
}
@ -378,6 +393,17 @@ public class GearModifierScreen extends AbstractElementScreen {
);
}
private void createUniqueGearButton() {
this.addElement(new ButtonElement<>(Spatials.positionXY(-3, 3), ScreenTextures.BUTTON_QUEST_TEXTURES, () -> {
if (!(this.innerScreen instanceof UniqueGearListContainer))
switchToUnique();
})).layout((screen, gui, parent, world) -> {
world.width(21).height(21).translateX(gui.left() - 36).translateY(this.getGuiSpatial().bottom() - 96);
}).tooltip(
Tooltips.single(TooltipDirection.LEFT, () -> new TextComponent("Unique Modifiers"))
);
}
@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
// left/right to increase/decrease lvl

View file

@ -23,9 +23,7 @@ public class ModifierListContainer extends VerticalScrollClipContainer<ModifierL
super(spatial, Padding.ZERO, ScreenTextures.INSET_BLACK_BACKGROUND);
int labelX = 9;
int labelY = 20;
Optional<VaultGearTierConfig> optCfg = VaultGearTierConfig.getConfig(gearPiece);
// 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(
@ -34,7 +32,7 @@ public class ModifierListContainer extends VerticalScrollClipContainer<ModifierL
);
this.addElement(itemName);
Optional<VaultGearTierConfig> optCfg = VaultGearTierConfig.getConfig(gearPiece);
if (optCfg.isPresent()) {
VaultGearTierConfig cfg = optCfg.get();
for (var modifier : Modifiers.getModifierList(lvl, cfg, modifierCategory)) {

View file

@ -42,7 +42,7 @@ public class TransmogListContainer extends VerticalScrollClipContainer<TransmogL
}
var discoveredModelIds = ClientDiscoveredEntriesData.Models.getDiscoveredModels();
var discoveredModelObserverIds = ClientDiscoveredEntriesData.Models.getObserverModels();
var model =new DiscoveredModelSelectElement.DiscoveredModelSelectorModel(
var model = new DiscoveredModelSelectElement.DiscoveredModelSelectorModel(
ObservableSupplier.of(() -> gearPiece, SideOnlyFixer::stackEqualExact), discoveredModelObserverIds, x -> {});
var mEntries = model.getEntries();
for (var x : mEntries) {

View file

@ -0,0 +1,166 @@
package com.radimous.vhatcaniroll.ui;
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.LabelElement;
import iskallia.vault.client.gui.framework.element.VerticalScrollClipContainer;
import iskallia.vault.client.gui.framework.spatial.Padding;
import iskallia.vault.client.gui.framework.spatial.Spatials;
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.init.ModConfigs;
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<UniqueGearListContainer> 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);
Map<ResourceLocation, UniqueGearConfig.Entry> uniqueRegistry = ((UniqueGearConfigAccessor) ModConfigs.UNIQUE_GEAR).getRegistry();
var regName = gearPiece.getItem().getRegistryName();
if (regName == null) {
return;
}
var regPath = regName.getPath();
var goodEntries = uniqueRegistry.entrySet().stream().filter(entry -> entry.getValue().getModel() != null && entry.getValue().getModel().toString().contains(regPath)).toList();
List<Map.Entry<ResourceLocation, UniqueGearConfig.Entry>> 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();
List<String> modifierTags = value.getModifierTags() == null ? List.of("missing") : value.getModifierTags();
Map<UniqueGearConfig.AffixTargetType, List<ResourceLocation>> modifierIdentifiers = value.getModifierIdentifiers() == null ? Map.of(UniqueGearConfig.AffixTargetType.PREFIX, List.of(new ResourceLocation("minecraft", "missing"))) : value.getModifierIdentifiers();
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;
LabelElement<?> nameLabel = new LabelElement<>(
Spatials.positionXY(labelX, labelY).width(this.innerWidth() - labelX).height(15),
new TextComponent(
"Name: " + name), LabelTextStyle.defaultStyle()
);
this.addElement(nameLabel);
labelY += 10;
LabelElement<?> modelLabel = new LabelElement<>(
Spatials.positionXY(labelX, labelY).width(this.innerWidth() - labelX).height(15),
new TextComponent(
"Model: " + model.toString()), LabelTextStyle.defaultStyle()
);
this.addElement(modelLabel);
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<UniqueGearConfig.AffixTargetType, List<ResourceLocation>> modifierIdentifier : modifierIdentifiers.entrySet()) {
if (modifierIdentifier.getValue().isEmpty()) {
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<VaultGearTierConfig.ModifierAffixTagGroup, VaultGearTierConfig.AttributeGroup> ff = uniqueConfig1.getModifierGroup();
List<VaultGearTierConfig.AttributeGroup> kk = new ArrayList<>();
for (Map.Entry<VaultGearTierConfig.ModifierAffixTagGroup, VaultGearTierConfig.AttributeGroup> 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;
}
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;
}
}
public float getScroll() {
return this.verticalScrollBarElement.getValue();
}
public void setScroll(float scroll) {
this.verticalScrollBarElement.setValue(scroll);
}
@Override
public InnerGearScreen create(ISpatial spatial, int lvl, ModifierCategory modifierCategory, ItemStack gearPiece) {
return new UniqueGearListContainer(spatial, lvl, modifierCategory, gearPiece);
}
}

View file

@ -5,11 +5,12 @@
"compatibilityLevel": "JAVA_8",
"refmap": "vhatcaniroll.refmap.json",
"mixins": [
"EffectConfigAccessor"
],
"client": [
"StatisticsElementContainerScreenMixin",
"VaultGearTierConfigAccessor"
"VaultGearTierConfigAccessor",
"EffectConfigAccessor",
"UniqueGearConfigAccessor"
],
"injectors": {
"defaultRequire": 1