use of net.silentchaos512.gear.api.util.StatGearKey in project Silent-Gear by SilentChaos512.
the class IStatModProvider method getStatUnclamped.
default float getStatUnclamped(D instance, PartType partType, StatGearKey key, ItemStack gear) {
ItemStat stat = ItemStats.get(key.getStat());
if (stat == null)
return key.getStat().getDefaultValue();
Collection<StatInstance> mods = getStatModifiers(instance, partType, key, gear);
return stat.compute(stat.getBaseValue(), false, key.getGearType(), mods);
}
use of net.silentchaos512.gear.api.util.StatGearKey in project Silent-Gear by SilentChaos512.
the class GearData method getStatModifiers.
public static StatModifierMap getStatModifiers(ItemStack stack, ICoreItem item, PartDataList parts) {
GearType gearType = item.getGearType();
StatModifierMap stats = new StatModifierMap();
for (ItemStat stat : ItemStats.allStatsOrderedExcluding(item.getExcludedStats(stack))) {
StatGearKey itemKey = StatGearKey.of(stat, gearType);
for (PartData part : parts) {
for (StatInstance mod : part.getStatModifiers(itemKey, stack)) {
StatInstance modCopy = StatInstance.of(mod.getValue(), mod.getOp(), itemKey);
stats.put(modCopy.getKey(), modCopy);
}
}
}
return stats;
}
use of net.silentchaos512.gear.api.util.StatGearKey in project Silent-Gear by SilentChaos512.
the class MaterialBuilder method stat.
public MaterialBuilder stat(PartType partType, IItemStat stat, GearType gearType, float value, StatInstance.Operation operation) {
StatGearKey key = StatGearKey.of(stat, gearType);
StatInstance mod = StatInstance.of(value, operation, key);
StatModifierMap map = stats.computeIfAbsent(partType, pt -> new StatModifierMap());
map.put(stat, gearType, mod);
return this;
}
use of net.silentchaos512.gear.api.util.StatGearKey in project Silent-Gear by SilentChaos512.
the class StatInstance method getWeightedAverageMod.
public static StatInstance getWeightedAverageMod(Collection<StatInstance> modifiers, Operation op) {
float value = ItemStat.getWeightedAverage(modifiers, op);
StatGearKey key = getMostSpecificKey(modifiers);
return new StatInstance(value, op, key);
}
use of net.silentchaos512.gear.api.util.StatGearKey in project Silent-Gear by SilentChaos512.
the class StatInstance method getMostSpecificKey.
private static StatGearKey getMostSpecificKey(Collection<StatInstance> modifiers) {
// Gets the key furthest down the gear type hierarchy (key with most parents)
Set<StatGearKey> found = new HashSet<>();
for (StatInstance mod : modifiers) {
found.add(mod.key);
}
StatGearKey ret = null;
int best = 0;
for (StatGearKey key : found) {
int parents = 0;
StatGearKey parent = key.getParent();
while (parent != null) {
parent = parent.getParent();
++parents;
}
if (parents > best || ret == null) {
best = parents;
ret = key;
}
}
return ret != null ? ret : DEFAULT_KEY;
}
Aggregations