use of net.silentchaos512.gear.api.stats.StatInstance.Operation in project Silent-Gear by SilentChaos512.
the class StatInstance method getMaterialWeightedAverageMod.
public static StatInstance getMaterialWeightedAverageMod(Collection<StatInstance> modifiers, Operation op) {
float value = ItemStat.getMaterialWeightedAverage(modifiers, op);
StatGearKey key = getMostSpecificKey(modifiers);
return new StatInstance(value, op, key);
}
use of net.silentchaos512.gear.api.stats.StatInstance.Operation in project Silent-Gear by SilentChaos512.
the class StatModifierMap method formatText.
public static MutableComponent formatText(Collection<StatInstance> mods, ItemStat stat, int maxDecimalPlaces, boolean addModColors) {
if (mods.size() == 1) {
StatInstance inst = mods.iterator().next();
int decimalPlaces = inst.getPreferredDecimalPlaces(stat, maxDecimalPlaces);
return inst.getFormattedText(stat, decimalPlaces, addModColors);
}
// Sort modifiers by operation
MutableComponent result = new TextComponent("");
List<StatInstance> toSort = new ArrayList<>(mods);
toSort.sort(Comparator.comparing(inst -> inst.getOp().ordinal()));
for (StatInstance inst : toSort) {
if (!result.getSiblings().isEmpty()) {
result.append(", ");
}
result.append(inst.getFormattedText(stat, inst.getPreferredDecimalPlaces(stat, maxDecimalPlaces), addModColors));
}
return result;
}
use of net.silentchaos512.gear.api.stats.StatInstance.Operation 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.stats.StatInstance.Operation in project SilentGems by SilentChaos512.
the class ToolPartTip method getStatModifier.
@Override
public ItemStatModifier getStatModifier(ItemStat stat, EnumMaterialGrade grade) {
float val = stats.getStat(stat);
Operation op = ItemStatModifier.Operation.ADD;
if (stat == CommonItemStats.ATTACK_SPEED)
val -= 1f;
else if (stat == CommonItemStats.HARVEST_LEVEL)
op = ItemStatModifier.Operation.MAX;
return new ItemStatModifier(getUnlocalizedName(), val, op);
}
use of net.silentchaos512.gear.api.stats.StatInstance.Operation in project Silent-Gear by SilentChaos512.
the class ItemStat method computeForDisplay.
public StatInstance computeForDisplay(float baseValue, GearType gearType, Collection<StatInstance> modifiers) {
if (modifiers.isEmpty()) {
return StatInstance.of(baseValue, Operation.AVG, StatInstance.DEFAULT_KEY);
}
int add = 1;
for (StatInstance inst : modifiers) {
Operation op = inst.getOp();
if (op == Operation.AVG || op == Operation.ADD || op == Operation.MAX) {
add = 0;
break;
}
}
float value = compute(baseValue + add, false, gearType, modifiers) - add;
Operation op = modifiers.iterator().next().getOp();
return StatInstance.of(value, op, StatInstance.DEFAULT_KEY);
}
Aggregations