aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/nei/formatter/SimpleSpecialValueFormatter.java
blob: 93b060eacb7eefab4dd0b0f674f181fc4f6c6a99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package gregtech.nei.formatter;

import java.util.Collections;
import java.util.List;

import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;

import net.minecraft.util.StatCollector;

import gregtech.api.util.GTUtility;
import gregtech.api.util.MethodsReturnNonnullByDefault;
import gregtech.nei.RecipeDisplayInfo;

/**
 * Simple formatter for recipe's special value.
 */
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class SimpleSpecialValueFormatter implements INEISpecialInfoFormatter {

    @Nullable
    private final String translationKey;
    private final int multiplier;

    /**
     * @param translationKey Localization key to format
     * @param multiplier     Number to multiply to special value for display
     */
    public SimpleSpecialValueFormatter(@Nullable String translationKey, int multiplier) {
        this.translationKey = translationKey;
        this.multiplier = multiplier;
    }

    /**
     * @param translationKey Localization key to format
     */
    public SimpleSpecialValueFormatter(@Nullable String translationKey) {
        this(translationKey, 1);
    }

    @Override
    public List<String> format(RecipeDisplayInfo recipeInfo) {
        return Collections.singletonList(
            StatCollector.translateToLocalFormatted(
                translationKey,
                GTUtility.formatNumbers((long) recipeInfo.recipe.mSpecialValue * multiplier)));
    }
}