blob: 59f1659be474f5ccea5d46316f23427edaca6424 (
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
|
package shcm.shsupercm.fabric.citresewn.pack;
import net.minecraft.resource.ResourcePack;
import shcm.shsupercm.fabric.citresewn.pack.cits.CIT;
import java.util.*;
public class CITPack {
public final ResourcePack resourcePack;
public final Collection<CIT> cits = new ArrayList<>();
public EnchantmentMergeMethod method = EnchantmentMergeMethod.AVERAGE;
public Integer cap = 8;
public Float fade = 0.5f;
public Boolean useGlint = true;
public CITPack(ResourcePack resourcePack) {
this.resourcePack = resourcePack;
}
public void loadGlobalProperties(Properties properties) throws Exception {
try {
this.method = properties.containsKey("method") ? CITPack.EnchantmentMergeMethod.valueOf(properties.getProperty("method").toUpperCase(Locale.ENGLISH)) : null;
if (properties.containsKey("cap")) {
this.cap = Integer.parseInt(properties.getProperty("cap"));
if (this.cap < 0)
throw new Exception("cap cannot be negative");
} else
this.cap = null;
if (properties.containsKey("fade")) {
this.fade = Float.parseFloat(properties.getProperty("fade"));
if (this.fade < 0f)
throw new Exception("fade cannot be negative");
} else
this.fade = null;
this.useGlint = properties.containsKey("useGlint") ? switch (properties.getProperty("useGlint").toLowerCase(Locale.ENGLISH)) {
case "true" -> true;
case "false" -> false;
default -> throw new Exception("useGlint is not a boolean");
} : null;
} catch (Exception e) {
this.method = null;
this.cap = null;
this.fade = null;
this.useGlint = null;
throw e;
}
}
public void loadGlobalProperties(CITPack properties) {
if (properties.method != null)
this.method = properties.method;
if (properties.cap != null)
this.cap = properties.cap;
if (properties.fade != null)
this.fade = properties.fade;
if (properties.useGlint != null)
this.useGlint = properties.useGlint;
}
public enum EnchantmentMergeMethod {
AVERAGE,
LAYERED,
CYCLE
}
}
|