aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/galacticgreg/api/ModContainer.java
blob: fa5a33f4c64d29900113e734d71e6a7b7e16d36e (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
package galacticgreg.api;

import java.util.ArrayList;
import java.util.List;

import gregtech.api.enums.Mods;

/**
 * Defines a Mod where this Generator shall be active. Note: This will only work (obviously) for Dimensions where
 * either: - Gregtech has a hook in the OreGen or - For mods which are addons to GalactiCraft
 *
 */
public class ModContainer {

    private final List<ModDimensionDef> _mDimensionLookup;
    private final Mods mod;

    /**
     * Define a new Mod where GT OreGen shall be enabled
     *
     * @param mod The Mods enum value.
     */
    public ModContainer(Mods mod) {
        this.mod = mod;
        _mDimensionLookup = new ArrayList<>();
    }

    public boolean isModLoaded() {
        return this.mod.isModLoaded();
    }

    /**
     * Internal function
     *
     * @return The mods name
     */
    public String getModName() {
        return mod.ID;
    }

    /**
     * Internal function
     *
     * @return The list of attached dimensions for this mod
     */
    public List<ModDimensionDef> getDimensionList() {
        return _mDimensionLookup;
    }

    /**
     * Adds a new dimension to this modcontainer. Make sure you've added all blocks there first
     *
     * @param pDimDef The dimension definition to be added
     * @return true if it could be added, false if not
     */
    public boolean addDimensionDef(ModDimensionDef pDimDef) {
        for (ModDimensionDef mdd : _mDimensionLookup) {
            if (mdd.getChunkProviderName()
                .equals(pDimDef.getChunkProviderName())) {
                // Cannot add DimensionDefinition; The Given chunk-provider name is already taken!
                return false;
            }
        }

        // Set the parent modName of this dimension. This will finalize it
        pDimDef.setParentModName(mod.ID);
        _mDimensionLookup.add(pDimDef);
        return true;
    }
}