aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/power/Power.java
blob: 28cdfa3559053632687b2bee5f1e1f3e2ef89a6a (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package gregtech.common.power;

import gregtech.api.util.GT_Utility;

public abstract class Power {

    protected final byte tier;
    protected int recipeEuPerTick;
    protected int recipeDuration;
    protected final int specialValue;

    public Power(byte tier) {
        this(tier, 0);
    }

    public Power(byte tier, int specialValue) {
        this.tier = tier;
        this.specialValue = specialValue;
    }

    public byte getTier() {
        return tier;
    }

    public abstract String getTierString();

    /**
     * This method should be called prior to usage of any value except the power tier.
     */
    public abstract void computePowerUsageAndDuration(int euPerTick, int duration);

    public void computePowerUsageAndDuration(int euPerTick, int duration, int specialValue) {
        computePowerUsageAndDuration(euPerTick, duration);
    }

    public int getEuPerTick() {
        return recipeEuPerTick;
    }

    public int getDurationTicks() {
        return recipeDuration;
    }

    public double getDurationSeconds() {
        return 0.05d * getDurationTicks();
    }

    public String getDurationStringSeconds() {
        return GT_Utility.formatNumbers(getDurationSeconds()) + GT_Utility.trans("161", " secs");
    }

    public String getDurationStringTicks() {
        if (getDurationTicks() == 1) {
            return GT_Utility.formatNumbers(getDurationTicks()) + GT_Utility.trans("209.1", " tick");
        }
        return GT_Utility.formatNumbers(getDurationTicks()) + GT_Utility.trans("209", " ticks");
    }

    public abstract String getTotalPowerString();

    public abstract String getPowerUsageString();

    public abstract String getVoltageString();

    public abstract String getAmperageString();

    public int compareTo(byte tier, int specialValue) {
        if (this.tier < tier) {
            return this.tier - tier;
        }
        return this.specialValue - specialValue;
    }
}