aboutsummaryrefslogtreecommitdiff
path: root/gtpp/src/main/java/gtPlusPlus/plugin/agrichem/logic/AlgaeGeneticData.java
blob: 6b7b72aa71486a47fba2a139e9b0854cd745d7dc (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package gtPlusPlus.plugin.agrichem.logic;

import net.minecraft.nbt.NBTTagCompound;

import gtPlusPlus.api.objects.data.AutoMap;

public class AlgaeGeneticData {

    private final int mLifespan;

    private final int mGeneration;

    private final boolean mIsDominant;

    private final boolean mRequiresLight;

    private final boolean mSaltWater;

    private final boolean mFreshWater;

    private final byte mTempTolerance;

    private final float mFertility;

    private final float mProductionSpeed;

    private final AutoMap<AlgaeGrowthRequirement> mSpecialRequirements;

    public AlgaeGeneticData() {
        this(true, true, true, true, (byte) 0, 1f, 1f, (byte) 30, 0, new AutoMap<>());
    }

    public AlgaeGeneticData(boolean isDominant, boolean requiresLight, boolean isSalt, boolean isFresh,
        byte aTempTolerance, float aFertility, float aSpeed, byte aLifespan, int aGeneration,
        AutoMap<AlgaeGrowthRequirement> aRequirements) {
        mIsDominant = isDominant;
        mRequiresLight = requiresLight;
        mSaltWater = isSalt;
        mFreshWater = isFresh;
        mTempTolerance = aTempTolerance;
        mFertility = aFertility;
        mProductionSpeed = aSpeed;
        mLifespan = aLifespan;
        mGeneration = aGeneration;
        mSpecialRequirements = aRequirements;
    }

    public AlgaeGeneticData(NBTTagCompound aNBT) {
        if (aNBT == null || aNBT.hasNoTags()) {
            mIsDominant = true;
            mRequiresLight = true;
            mSaltWater = true;
            mFreshWater = true;
            mTempTolerance = 0;
            mFertility = 1;
            mProductionSpeed = 1;
            mLifespan = 30;
            mGeneration = 0;
        } else {
            mIsDominant = aNBT.getBoolean("mIsDominant");
            mRequiresLight = aNBT.getBoolean("mRequiresLight");
            mSaltWater = aNBT.getBoolean("mSaltWater");
            mFreshWater = aNBT.getBoolean("mFreshWater");
            mTempTolerance = aNBT.getByte("mTempTolerance");
            mFertility = aNBT.getFloat("mFertility");
            mProductionSpeed = aNBT.getFloat("mProductionSpeed");
            mLifespan = aNBT.getByte("mLifespan");
            mGeneration = aNBT.getInteger("mGeneration");
        }
        mSpecialRequirements = new AutoMap<>();
    }

    /**
     * In MC Days
     */
    public final int getLifespan() {
        return this.mLifespan;
    }

    public final boolean isDominant() {
        return this.mIsDominant;
    }

    public final boolean RequiresLight() {
        return this.mRequiresLight;
    }

    public final boolean isSaltWater() {
        return this.mSaltWater;
    }

    public final boolean isFreshWater() {
        return this.mFreshWater;
    }

    public final byte getTempTolerance() {
        return this.mTempTolerance;
    }

    public final float getFertility() {
        return this.mFertility;
    }

    public final float getProductionSpeed() {
        return this.mProductionSpeed;
    }

    public final int getGeneration() {
        return this.mGeneration;
    }

    public final AutoMap<AlgaeGrowthRequirement> getSpecialRequirements() {
        return this.mSpecialRequirements;
    }

    public NBTTagCompound writeToNBT() {
        NBTTagCompound aGenes = new NBTTagCompound();
        aGenes.setBoolean("mIsDominant", this.mIsDominant);
        aGenes.setBoolean("mRequiresLight", this.mRequiresLight);
        aGenes.setBoolean("mSaltWater", this.mSaltWater);
        aGenes.setBoolean("mFreshWater", this.mFreshWater);
        aGenes.setInteger("mLifespan", this.mLifespan);
        aGenes.setInteger("mGeneration", this.mGeneration);
        aGenes.setByte("mTempTolerance", this.mTempTolerance);
        aGenes.setFloat("mFertility", this.mFertility);
        aGenes.setFloat("mProductionSpeed", this.mProductionSpeed);
        return aGenes;
    }
}