tangled
alpha
login
or
join now
codexarchonic.nekoweb.org
/
ProjectInfinity
0
fork
atom
Inspired by 2020's April Fools' 20w14infinite Snapshot, this mod brings endless randomly generated dimensions into Minecraft.
0
fork
atom
overview
issues
6
pulls
pipelines
null safety!
cassian.cc
10 months ago
2d69dfa2
58195f43
+43
-32
3 changed files
expand all
collapse all
unified
split
common
src
main
java
net
lerariemann
infinity
compat
cloth
AmendmentConfigFactory.java
resources
assets
infinity
lang
en_us.json
gradle.properties
+41
-31
common/src/main/java/net/lerariemann/infinity/compat/cloth/AmendmentConfigFactory.java
reviewed
···
21
21
import static net.lerariemann.infinity.compat.cloth.ClothConfigFactory.*;
22
22
23
23
public class AmendmentConfigFactory {
24
24
-
enum AreasEnum {
25
25
-
BLOCKS,
26
26
-
FLUIDS,
27
27
-
ITEMS,
28
28
-
STRUCTURES,
29
29
-
MOBS;
30
30
-
}
31
24
32
25
public static void build(ConfigBuilder builder) {
33
26
···
37
30
var elements = amendmentList.getAsJsonArray("elements");
38
31
int i = 0;
39
32
for (JsonElement amendmentElement : elements) {
40
40
-
SubCategoryBuilder subCategory = builder.entryBuilder().startSubCategory(Text.translatable("config.infinity.amendment", String.valueOf(i)));
41
41
-
JsonObject amendment = amendmentElement.getAsJsonObject();
42
42
-
addStringDropdownOption("area", builder, subCategory, i, amendment, Lists.newArrayList("blocks", "fluids", "items", "structures", "trees", "mobs"));
43
43
-
addStringOption("mod", builder, subCategory, i, amendment);
44
44
-
addStringDropdownOption("selector", builder, subCategory, i, amendment, Lists.newArrayList("all", "matching", "matching_any", "matching_block_tag", "containing"));
45
45
-
if (amendment.get("selector").getAsString().equals("matching_any"))
46
46
-
addListOption("matching", builder, subCategory, i, amendment);
47
47
-
else if (amendment.get("selector").getAsString().equals("matching")) {
48
48
-
addStringOption("matching", builder, subCategory, i, amendment);
49
49
-
}
50
50
-
addStringDropdownOption("results", builder, subCategory, i, amendment, Lists.newArrayList("set_value", "set_field", "erase"));
51
51
-
if (amendment.get("results").getAsString().equals("set_value"))
52
52
-
addDoubleOption("value", builder, subCategory, i, amendment);
53
53
-
else if (amendment.get("results").getAsString().equals("set_field"))
54
54
-
addStringDropdownOption("field_name", builder, subCategory, i, amendment, Lists.newArrayList("full", "float", "top", "laggy"));
55
55
-
56
56
-
amendmentCategory.addEntry(subCategory.build());
57
57
-
i++;
33
33
+
i = addAmendment(builder, amendmentElement, i, amendmentCategory);
58
34
}
35
35
+
// todo new amendments
36
36
+
// addAmendment(builder, null, i, amendmentCategory);
59
37
amendmentCategory.addEntry(builder.entryBuilder().startTextDescription(Text.literal("To add new entries, edit amendments.json.").setStyle(Style.EMPTY)).build());
60
38
}
61
39
40
40
+
private static int addAmendment(ConfigBuilder builder, JsonElement amendmentElement, int i, ConfigCategory amendmentCategory) {
41
41
+
JsonObject amendment;
42
42
+
SubCategoryBuilder subCategory;
43
43
+
if (amendmentElement != null) {
44
44
+
subCategory = builder.entryBuilder().startSubCategory(Text.translatable("config.infinity.amendment", String.valueOf(i)));
45
45
+
amendment = amendmentElement.getAsJsonObject();
46
46
+
} else {
47
47
+
subCategory = builder.entryBuilder().startSubCategory(Text.translatable("config.infinity.amendment.new"));
48
48
+
amendment = new JsonObject();
49
49
+
}
50
50
+
addStringDropdownOption("area", builder, subCategory, i, amendment, Lists.newArrayList("blocks", "fluids", "items", "structures", "trees", "mobs"));
51
51
+
addStringOption("mod", builder, subCategory, i, amendment);
52
52
+
addStringDropdownOption("selector", builder, subCategory, i, amendment, Lists.newArrayList("all", "matching", "matching_any", "matching_block_tag", "containing"));
53
53
+
if (getSafeString(amendment, "selector").equals("matching_any"))
54
54
+
addListOption("matching", builder, subCategory, i, amendment);
55
55
+
else if (getSafeString(amendment, "selector").equals("matching")) {
56
56
+
addStringOption("matching", builder, subCategory, i, amendment);
57
57
+
}
58
58
+
addStringDropdownOption("results", builder, subCategory, i, amendment, Lists.newArrayList("set_value", "set_field", "erase"));
59
59
+
if (getSafeString(amendment, "results").equals("set_value"))
60
60
+
addDoubleOption("value", builder, subCategory, i, amendment);
61
61
+
else if (getSafeString(amendment, "results").equals("set_field"))
62
62
+
addStringDropdownOption("field_name", builder, subCategory, i, amendment, Lists.newArrayList("full", "float", "top", "laggy"));
63
63
+
64
64
+
amendmentCategory.addEntry(subCategory.build());
65
65
+
i++;
66
66
+
return i;
67
67
+
}
68
68
+
69
69
+
private static String getSafeString(JsonObject amendment, String key) {
70
70
+
var amend = amendment.get(key);
71
71
+
if (amend != null)
72
72
+
return amend.getAsString();
73
73
+
else return "";
74
74
+
}
75
75
+
62
76
private static void addStringOption(String name, ConfigBuilder builder, SubCategoryBuilder subCategory, int i, JsonObject amendment) {
63
63
-
String current;
64
64
-
if (amendment.get(name) == null) current = "";
65
65
-
else current = amendment.get(name).getAsString();
77
77
+
String current = getSafeString(amendment, name);
66
78
subCategory.add(builder.entryBuilder().startStrField(
67
79
Text.translatable("config.infinity.amendments."+name),
68
80
current)
···
72
84
}
73
85
74
86
private static void addStringDropdownOption(String name, ConfigBuilder builder, SubCategoryBuilder subCategory, int i, JsonObject amendment, List<String> options) {
75
75
-
String current;
76
76
-
if (amendment.get(name) == null) current = "";
77
77
-
else current = amendment.get(name).getAsString();
87
87
+
String current = getSafeString(amendment, name);
78
88
subCategory.add(builder.entryBuilder().startDropdownMenu(Text.translatable("config.infinity.amendments."+name), DropdownMenuBuilder.TopCellElementBuilder.of(current, (s) -> s))
79
89
.setTooltip(amendmentTooltip(name))
80
90
.setSuggestionMode(false)
+1
common/src/main/resources/assets/infinity/lang/en_us.json
reviewed
···
168
168
"config.infinity.title.features_chances": "Feature Chances",
169
169
"config.infinity.title.rootChances": "Root Chances",
170
170
"config.infinity.amendment": "Amendment #%s",
171
171
+
"config.infinity.amendment.new": "New Amendment",
171
172
"config.infinity.amendments.area": "Area",
172
173
"config.infinity.amendments.area.description": "What part of Infinite Dimensions generation to affect. Options include blocks, fluids, trees, mobs, structures.",
173
174
"config.infinity.amendments.mod": "Mod Name",
+1
-1
gradle.properties
reviewed
···
7
7
maven_group = net.lerariemann
8
8
archives_name = infinity
9
9
enabled_platforms = fabric,neoforge
10
10
-
tbversion = 3
10
10
+
tbversion = 4
11
11
12
12
# Minecraft properties
13
13
minecraft_version = 1.21.1