-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathChromaConfig.java
173 lines (148 loc) · 6.13 KB
/
ChromaConfig.java
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*******************************************************************************
* @author Reika Kalseki
*
* Copyright 2017
*
* All rights reserved.
* Distribution of the software in any form is only allowed with
* explicit, prior permission from the owner.
******************************************************************************/
package Reika.ChromatiCraft;
import java.util.ArrayList;
import java.util.HashSet;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
import Reika.ChromatiCraft.Registry.ChromaOptions;
import Reika.ChromatiCraft.Registry.CrystalElement;
import Reika.ChromatiCraft.TileEntity.Acquisition.TileEntityMiner.MineralCategory;
import Reika.DragonAPI.ModList;
import Reika.DragonAPI.Auxiliary.Trackers.KeyWatcher.Key;
import Reika.DragonAPI.Base.DragonAPIMod;
import Reika.DragonAPI.Instantiable.IO.ControlledConfig;
import Reika.DragonAPI.Interfaces.Configuration.ConfigList;
import Reika.DragonAPI.Interfaces.Registry.IDRegistry;
import Reika.DragonAPI.Libraries.Java.ReikaJVMParser;
import Reika.DragonAPI.Libraries.Java.ReikaJavaLibrary;
import Reika.DragonAPI.Libraries.Java.ReikaStringParser;
import Reika.DragonAPI.Libraries.Registry.ReikaTreeHelper;
import Reika.DragonAPI.ModRegistry.ModWoodList;
public class ChromaConfig extends ControlledConfig {
private static final ArrayList<String> modTrees = getModTrees();
private static final int treeLength = modTrees.size();
private static final int vanillaTreeCount = ReikaTreeHelper.treeList.length;
private final DataElement<Boolean>[] trees = new DataElement[treeLength+vanillaTreeCount];
private final DataElement<Float>[] dyeChances = new DataElement[ReikaJavaLibrary.getEnumLengthWithoutInitializing(CrystalElement.class)];
private DataElement<String[]> guardianExceptions;
private DataElement<String[]> customMinerBlocks;
private Key superbuildKey;
private DataElement<int[]> structureDimensionBlacklist;
private HashSet<Integer> structureDimensionBlacklistSet;
public ChromaConfig(DragonAPIMod mod, ConfigList[] option, IDRegistry[] id) {
super(mod, option, id);
for (int i = 0; i < vanillaTreeCount; i++) {
String name = ReikaTreeHelper.treeList[i].getName();
trees[i] = this.registerAdditionalOption("Generate Vanilla Logs", name, true);
}
for (int i = 0; i < treeLength; i++) {
String name = modTrees.get(i);
trees[i+vanillaTreeCount] = this.registerAdditionalOption("Generate Mod Logs", name, true);
}
ArrayList<String> elements = ReikaJavaLibrary.getEnumEntriesWithoutInitializing(CrystalElement.class);
for (int i = 0; i < dyeChances.length; i++) {
dyeChances[i] = this.registerAdditionalOption("Vanilla Dye Drop Chances", elements.get(i), 100F);
}
this.registerProperty("t2ConfigModel", ReikaJVMParser.isArgumentPresent("-ChromaTrustingConfigModel"));
guardianExceptions = this.registerAdditionalOption("Other Options", "Guardian Stone Exceptions", this.getDefaultGuardstoneExceptions());
customMinerBlocks = this.registerAdditionalOption("Other Options", "Custom Mineral Extractor Mappings", this.getDefaultMinerblockConfig());
structureDimensionBlacklist = this.registerAdditionalOption("Other Options", "Structure Dimension Blacklist", new int[0]);
}
@Override
protected void afterInit() {
superbuildKey = Key.readFromConfig(configMod, ChromaOptions.SUPERBUILDKEYBIND);
}
public Key getSuperbuildKey() {
Key k = superbuildKey;
if (k == null)
k = Key.LCTRL;
return k;
}
private String[] getDefaultGuardstoneExceptions() {
ArrayList<String> li = new ArrayList();
for (Action a : Action.values())
li.add("none#"+a.name());
li.add(ModList.EXTRAUTILS.modLabel+":dark_portal:2#"+Action.RIGHT_CLICK_BLOCK.name()); //last millenium portal
return li.toArray(new String[li.size()]);
}
private String[] getDefaultMinerblockConfig() {
ArrayList<String> li = new ArrayList();
for (MineralCategory cat : MineralCategory.values()) {
if (cat != MineralCategory.ANY)
li.add("none#"+cat.name());
}
return li.toArray(new String[li.size()]);
}
public ArrayList<String> getGuardianExceptions() {
return ReikaJavaLibrary.makeListFromArray(guardianExceptions.getData());
}
public ArrayList<String> getMinerBlockExtras() {
return ReikaJavaLibrary.makeListFromArray(customMinerBlocks.getData());
}
private static ArrayList<String> getModTrees() {
ArrayList<String> base = ReikaJavaLibrary.getEnumEntriesWithoutInitializing(ModWoodList.class);
ArrayList<String> li = new ArrayList();
for (int i = 0; i < base.size(); i++) {
StringBuilder sb = new StringBuilder();
String sg = base.get(i);
if (sg.startsWith("BOP")) {
sg = sg.substring(3);
sb.append("Biomes O Plenty ");
sb.append(ReikaStringParser.capFirstChar(sg));
}
else if (sg.startsWith("BXL")) {
sg = sg.substring(3);
sb.append("ExtraBiomes XL ");
sb.append(ReikaStringParser.capFirstChar(sg));
}
else if (sg.startsWith("MFR")) {
sg = sg.substring(3);
sb.append("MineFactory Reloaded ");
sb.append(ReikaStringParser.capFirstChar(sg));
}
else if (sg.startsWith("IC2")) {
sg = sg.substring(3);
sb.append("IndustrialCraft ");
sb.append(ReikaStringParser.capFirstChar(sg));
}
else if (sg.startsWith("NATURA")) {
sg = sg.substring(6);
sb.append("Natura ");
sb.append(ReikaStringParser.capFirstChar(sg));
}
else {
sb.append(ReikaStringParser.capFirstChar(sg));
}
li.add(sb.toString());
}
return li;
}
public boolean shouldGenerateLogType(ModWoodList tree) {
return trees[tree.ordinal()+ReikaTreeHelper.treeList.length].getData();
}
public boolean shouldGenerateLogType(ReikaTreeHelper tree) {
return trees[tree.ordinal()].getData();
}
public float getVanillaDyeChance(CrystalElement e) {
return this.getVanillaDyeChance(e.ordinal());
}
public float getVanillaDyeChance(int idx) {
return dyeChances[idx%16].getData();
}
public boolean isDimensionBlacklistedForStructures(int dim) {
if (structureDimensionBlacklistSet == null) {
structureDimensionBlacklistSet = new HashSet();
for (int val : structureDimensionBlacklist.getData()) {
structureDimensionBlacklistSet.add(val);
}
}
return structureDimensionBlacklistSet.contains(dim);
}
}