aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/common/tileentities/TE_SpaceElevatorCapacitor.java
blob: ea5211bfba8d9c438de438853300595489844b97 (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
package common.tileentities;

import net.minecraft.tileentity.TileEntity;

public class TE_SpaceElevatorCapacitor extends TileEntity {

    private float chargeLevel = 0.0F;
    private boolean isDamaged = true;

    /**
     * Called by {@link GTMTE_SpaceElevator} while charging
     * 
     * @param charge    Current elevator charge
     * @param maxCharge Charge level it is trying to reach
     */
    public void updateChargeLevel(int charge, int maxCharge) {
        chargeLevel = ((float) charge) / ((float) maxCharge);
    }

    /**
     * Called by {@link client.renderer.TESR_SECapacitor} to calculate the block's colour saturation
     * 
     * @return Charge level from 0.0F to 1.0F
     */
    public float getChargeLevel() {
        return chargeLevel;
    }

    /**
     * Called by {@link GTMTE_SpaceElevator} in case of power loss
     */
    public void resetChargeLevel() {
        chargeLevel = 0.0F;
    }

    /**
     * Called by {@link GTMTE_SpaceElevator} in case of maintenance issues
     * 
     * @param isDamaged has maintenance issue
     */
    public void setIsDamaged(boolean isDamaged) {
        this.isDamaged = isDamaged;
    }

    /**
     * Called by {@link client.renderer.TESR_SECapacitor} to check whether the block should be rendered red
     * 
     * @return should be rendered red
     */
    public boolean isDamaged() {
        return isDamaged;
    }
}