-
Notifications
You must be signed in to change notification settings - Fork 214
Expand file tree
/
Copy pathOreProperty.java
More file actions
226 lines (189 loc) · 6 KB
/
OreProperty.java
File metadata and controls
226 lines (189 loc) · 6 KB
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
package gregtech.api.unification.material.properties;
import gregtech.api.unification.material.Material;
import net.minecraft.util.math.MathHelper;
import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
public class OreProperty implements IMaterialProperty {
/**
* List of Ore byproducts.
* <p>
* Default: none, meaning only this property's Material.
*/
// @ZenProperty
private final List<Material> oreByProducts = new ArrayList<>();
/**
* Crushed Ore output amount multiplier during Maceration.
* <p>
* Default: 1 (no multiplier).
*/
// @ZenProperty
private int oreMultiplier;
/**
* Byproducts output amount multiplier during Maceration.
* <p>
* Default: 1 (no multiplier).
*/
// @ZenProperty
private int byProductMultiplier;
/**
* Should ore block use the emissive texture.
* <p>
* Default: false.
*/
// @ZenProperty
private boolean emissive;
/**
* Material to which smelting of this Ore will result.
* <p>
* Material will have a Dust Property.
* Default: none.
*/
// @ZenProperty
@Nullable
private Material directSmeltResult;
/**
* Material in which this Ore should be washed to give additional output.
* <p>
* Material will have a Fluid Property.
* Default: none.
*/
// @ZenProperty
@Nullable
private Material washedIn;
/**
* The amount of Material that the ore should be washed in
* in the Chemical Bath.
* <p>
* Default 100 mb
*/
private int washedAmount = 100;
/**
* During Electromagnetic Separation, this Ore will be separated
* into this Material and the Material specified by this field.
* Limit 2 Materials
* <p>
* Material will have a Dust Property.
* Default: none.
*/
// @ZenProperty
private final List<Material> separatedInto = new ArrayList<>();
public OreProperty(int oreMultiplier, int byProductMultiplier) {
this.oreMultiplier = oreMultiplier;
this.byProductMultiplier = byProductMultiplier;
this.emissive = false;
}
public OreProperty(int oreMultiplier, int byProductMultiplier, boolean emissive) {
this.oreMultiplier = oreMultiplier;
this.byProductMultiplier = byProductMultiplier;
this.emissive = emissive;
}
/**
* Default values constructor.
*/
public OreProperty() {
this(1, 1);
}
public OreProperty setOreMultiplier(int multiplier) {
this.oreMultiplier = multiplier;
return this;
}
public int getOreMultiplier() {
return this.oreMultiplier;
}
public OreProperty setByProductMultiplier(int multiplier) {
this.byProductMultiplier = multiplier;
return this;
}
public int getByProductMultiplier() {
return this.byProductMultiplier;
}
public boolean isEmissive() {
return emissive;
}
public OreProperty setEmissive(boolean emissive) {
this.emissive = emissive;
return this;
}
public OreProperty setDirectSmeltResult(@Nullable Material m) {
this.directSmeltResult = m;
return this;
}
@Nullable
public Material getDirectSmeltResult() {
return this.directSmeltResult;
}
public OreProperty setWashedIn(@Nullable Material m) {
this.washedIn = m;
return this;
}
public OreProperty setWashedIn(@Nullable Material m, int washedAmount) {
this.washedIn = m;
this.washedAmount = washedAmount;
return this;
}
public Pair<Material, Integer> getWashedIn() {
return Pair.of(this.washedIn, this.washedAmount);
}
public OreProperty setSeparatedInto(Material... materials) {
this.separatedInto.addAll(Arrays.asList(materials));
return this;
}
@Nullable
public List<Material> getSeparatedInto() {
return this.separatedInto;
}
/**
* Set the ore byproducts for this property
*
* @param materials the materials to use as byproducts
*/
public OreProperty setOreByProducts(@NotNull Material... materials) {
setOreByProducts(Arrays.asList(materials));
return this;
}
/**
* Set the ore byproducts for this property
*
* @param materials the materials to use as byproducts
*/
public OreProperty setOreByProducts(@NotNull Collection<Material> materials) {
this.oreByProducts.clear();
this.oreByProducts.addAll(materials);
return this;
}
/**
* Add ore byproducts to this property
*
* @param materials the materials to add as byproducts
*/
public OreProperty addOreByProducts(@NotNull Material... materials) {
this.oreByProducts.addAll(Arrays.asList(materials));
return this;
}
public List<Material> getOreByProducts() {
return this.oreByProducts;
}
@Nullable
public final Material getOreByProduct(int index) {
if (this.oreByProducts.isEmpty()) return null;
return this.oreByProducts.get(MathHelper.clamp(index, 0, this.oreByProducts.size() - 1));
}
@NotNull
public final Material getOreByProduct(int index, @NotNull Material fallback) {
Material material = getOreByProduct(index);
return material != null ? material : fallback;
}
@Override
public void verifyProperty(MaterialProperties properties) {
properties.ensureSet(PropertyKey.DUST, true);
if (directSmeltResult != null) directSmeltResult.getProperties().ensureSet(PropertyKey.DUST, true);
if (washedIn != null) washedIn.getProperties().ensureSet(PropertyKey.FLUID, true);
separatedInto.forEach(m -> m.getProperties().ensureSet(PropertyKey.DUST, true));
oreByProducts.forEach(m -> m.getProperties().ensureSet(PropertyKey.DUST, true));
}
}