Skip to content

Commit 33f3506

Browse files
committed
2.0.25
1 parent 37a93a2 commit 33f3506

6 files changed

Lines changed: 120 additions & 76 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 2.0.25
2+
3+
- Fixed biome loading
4+
- Fixed crash related to loading of modded jigsaw structures
5+
16
## 2.0.24
27

38
- Fixed crash related to Yung's API

common/src/main/java/com/faboslav/structurify/common/config/data/WorldgenDataProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public static Map<String, StructureData> loadStructures() {
157157
});
158158

159159
StructureData structureData = new StructureData(defaultBiomes, structure.step(), structure.terrainAdaptation());
160-
JsonObject structureJson = JigsawStructureUtil.getStructureData(structure);
160+
@Nullable JsonObject structureJson = JigsawStructureUtil.getStructureData(structure);
161161

162162
if (JigsawStructureUtil.isJigsawLikeStructure(structure, structureJson)) {
163163
var maxDistanceFromCenter = JigsawStructureUtil.getMaxDistanceFromCenterForStructure(structure, structureJson);
@@ -181,6 +181,7 @@ public static Map<String, StructureData> loadStructures() {
181181

182182
var projectStartToHeightmap = JigsawStructureUtil.getProjectStartToHeightMap(structure, structureJson);
183183
@Nullable ProjectStartToHeightmap projectStartToHeightmapOption;
184+
184185
if(projectStartToHeightmap == null) {
185186
projectStartToHeightmapOption = null;
186187
} else {

common/src/main/java/com/faboslav/structurify/common/config/serialization/StructureDataSerializer.java

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,29 @@ public static void load(JsonObject structureJson, StructureData structureData) {
4040
var blacklistedBiomes = new ArrayList<>(structureData.getDefaultBiomes());
4141
blacklistedBiomes.removeAll(structureJson.getAsJsonArray(BIOMES_PROPERTY).asList().stream().map(JsonElement::getAsString).collect(Collectors.toCollection(ArrayList::new)));
4242
blacklistedBiomes.stream().distinct().forEach(biomes::remove);
43-
} else if (structureJson.has(WHITELISTED_BIOMES_PROPERTY) && structureJson.has(BLACKLISTED_BIOMES_PROPERTY)) {
44-
var whitelistedBiomes = structureJson.getAsJsonArray(WHITELISTED_BIOMES_PROPERTY);
45-
for (JsonElement whitelistedBiome : whitelistedBiomes) {
46-
if (biomes.contains(whitelistedBiome.getAsString())) {
47-
continue;
43+
} else if (structureJson.has(WHITELISTED_BIOMES_PROPERTY) || structureJson.has(BLACKLISTED_BIOMES_PROPERTY)) {
44+
Structurify.getLogger().info("LOADING");
45+
if(structureJson.has(WHITELISTED_BIOMES_PROPERTY)) {
46+
var whitelistedBiomes = structureJson.getAsJsonArray(WHITELISTED_BIOMES_PROPERTY);
47+
for (JsonElement whitelistedBiome : whitelistedBiomes) {
48+
if (biomes.contains(whitelistedBiome.getAsString())) {
49+
continue;
50+
}
51+
52+
biomes.add(whitelistedBiome.getAsString());
4853
}
49-
50-
biomes.add(whitelistedBiome.getAsString());
5154
}
5255

53-
var blacklistedBiomes = structureJson.getAsJsonArray(BLACKLISTED_BIOMES_PROPERTY);
56+
if(structureJson.has(BLACKLISTED_BIOMES_PROPERTY)) {
57+
var blacklistedBiomes = structureJson.getAsJsonArray(BLACKLISTED_BIOMES_PROPERTY);
5458

55-
for (JsonElement blacklistedBiome : blacklistedBiomes) {
56-
if (!biomes.contains(blacklistedBiome.getAsString())) {
57-
continue;
58-
}
59+
for (JsonElement blacklistedBiome : blacklistedBiomes) {
60+
if (!biomes.contains(blacklistedBiome.getAsString())) {
61+
continue;
62+
}
5963

60-
biomes.remove(blacklistedBiome.getAsString());
64+
biomes.remove(blacklistedBiome.getAsString());
65+
}
6166
}
6267
}
6368

common/src/main/java/com/faboslav/structurify/common/util/JigsawStructureUtil.java

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.faboslav.structurify.common.registry.StructurifyRegistryManagerProvider;
77
import com.google.gson.JsonElement;
88
import com.google.gson.JsonObject;
9+
import net.minecraft.core.Holder;
910
import net.minecraft.world.level.levelgen.Heightmap;
1011
import net.minecraft.world.level.levelgen.heightproviders.HeightProvider;
1112
import net.minecraft.world.level.levelgen.structure.Structure;
@@ -35,16 +36,33 @@ public static JsonObject getStructureData(Structure structure) {
3536
return null;
3637
}
3738

38-
return Structure.DIRECT_CODEC
39-
.encodeStart(serializationContext, structure)
40-
.result()
41-
.map(e -> (JsonElement) e)
42-
.filter(JsonElement::isJsonObject)
43-
.map(JsonElement::getAsJsonObject)
44-
.orElse(null);
39+
try {
40+
return Structure.DIRECT_CODEC
41+
.encodeStart(serializationContext, structure)
42+
.result()
43+
.filter(JsonElement::isJsonObject)
44+
.map(JsonElement::getAsJsonObject)
45+
.orElseThrow();
46+
} catch(Exception exception) {
47+
try {
48+
//? if >= 1.21.1 {
49+
return JigsawStructure.CODEC.codec()
50+
//?} else {
51+
/*return JigsawStructure.CODEC
52+
*///?}
53+
.encodeStart(serializationContext, (JigsawStructure) structure)
54+
.result()
55+
.filter(JsonElement::isJsonObject)
56+
.map(JsonElement::getAsJsonObject)
57+
.orElseThrow();
58+
} catch (Exception ignored) {
59+
}
60+
61+
return null;
62+
}
4563
}
4664

47-
public static boolean isJigsawLikeStructure(Structure structure, JsonObject structureJson) {
65+
public static boolean isJigsawLikeStructure(Structure structure, @Nullable JsonObject structureJson) {
4866
if (structure instanceof JigsawStructure) {
4967
return true;
5068
}
@@ -61,7 +79,7 @@ public static boolean isJigsawLikeStructure(Structure structure, JsonObject stru
6179
}
6280
*///?}
6381

64-
if (structureJson.has("max_distance_from_center") || structureJson.has("max_depth") || structureJson.has("size") || structureJson.has("start_height") || structureJson.has("project_start_to_heightmap")) {
82+
if (structureJson != null && (structureJson.has("max_distance_from_center") || structureJson.has("max_depth") || structureJson.has("size") || structureJson.has("start_height") || structureJson.has("project_start_to_heightmap"))) {
6583
return true;
6684
}
6785

forge/build.gradle.kts

Lines changed: 67 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
val IS_CI = System.getenv("CI") == "true"
2+
13
plugins {
24
`multiloader-loader`
35
id("net.neoforged.moddev.legacyforge")
@@ -79,65 +81,78 @@ dependencies {
7981
modImplementation(commonMod.modrinth("structure-gel-api", structureGelApiVersion)) { isTransitive = false }
8082
}
8183

82-
// Better modlist
83-
val betterModListDeps: List<Dependency> = fletchingTable.modrinthBundle("better-modlist", commonMod.mc, "forge") {
84-
recursive = true
85-
include("required", "optional", "embedded")
86-
}
87-
for (mod in betterModListDeps) modImplementation(mod)
84+
if(!IS_CI) {
85+
// Better modlist
86+
val betterModListDeps: List<Dependency> =
87+
fletchingTable.modrinthBundle("better-modlist", commonMod.mc, "forge") {
88+
recursive = true
89+
include("required", "optional", "embedded")
90+
}
91+
for (mod in betterModListDeps) modImplementation(mod)
8892

89-
// ChoiceTheorem's Overhauled Village
90-
val ctov: List<Dependency> = fletchingTable.modrinthBundle("ct-overhaul-village", commonMod.mc, "forge") {
91-
recursive = true
92-
include("required", "optional", "embedded")
93-
}
94-
for (mod in ctov) modImplementation(mod)
93+
// ChoiceTheorem's Overhauled Village
94+
val ctov: List<Dependency> = fletchingTable.modrinthBundle("ct-overhaul-village", commonMod.mc, "forge") {
95+
recursive = true
96+
include("required", "optional", "embedded")
97+
}
98+
for (mod in ctov) modImplementation(mod)
9599

96-
// Fantasy structures
97-
val fantasyStructures: List<Dependency> = fletchingTable.modrinthBundle("fantasy-structures-(by-berezka)", commonMod.mc, "forge") {
98-
recursive = true
99-
include("required", "optional", "embedded")
100-
}
101-
for (mod in fantasyStructures) modImplementation(mod)
100+
// Fantasy structures
101+
val fantasyStructures: List<Dependency> =
102+
fletchingTable.modrinthBundle("fantasy-structures-(by-berezka)", commonMod.mc, "forge") {
103+
recursive = true
104+
include("required", "optional", "embedded")
105+
}
106+
for (mod in fantasyStructures) modImplementation(mod)
102107

103-
// Alex Caves
104-
val alexCavesWithDeps: List<Dependency> = fletchingTable.modrinthBundle("alexs-caves", commonMod.mc, "forge") {
105-
recursive = true
106-
include("required", "optional", "embedded")
107-
}
108-
for (mod in alexCavesWithDeps) modImplementation(mod)
108+
// Alex Caves
109+
val alexCavesWithDeps: List<Dependency> = fletchingTable.modrinthBundle("alexs-caves", commonMod.mc, "forge") {
110+
recursive = true
111+
include("required", "optional", "embedded")
112+
}
113+
for (mod in alexCavesWithDeps) modImplementation(mod)
109114

110-
// Aquamira
111-
val aquamiraeWithDeps: List<Dependency> = fletchingTable.modrinthBundle("aquamirae", commonMod.mc, "forge") {
112-
recursive = true
113-
include("required", "optional", "embedded")
114-
}
115-
for (mod in aquamiraeWithDeps) modImplementation(mod)
115+
// Aquamira
116+
val aquamiraeWithDeps: List<Dependency> = fletchingTable.modrinthBundle("aquamirae", commonMod.mc, "forge") {
117+
recursive = true
118+
include("required", "optional", "embedded")
119+
}
120+
for (mod in aquamiraeWithDeps) modImplementation(mod)
116121

117-
val fossilsAndArcheologyRevivalWithDeps: List<Dependency> = fletchingTable.modrinthBundle("fossils-and-archeology-revival", commonMod.mc, "forge") {
118-
recursive = true
119-
include("required", "optional", "embedded")
120-
}
121-
for (mod in fossilsAndArcheologyRevivalWithDeps) modImplementation(mod)
122+
val fossilsAndArcheologyRevivalWithDeps: List<Dependency> =
123+
fletchingTable.modrinthBundle("fossils-and-archeology-revival", commonMod.mc, "forge") {
124+
recursive = true
125+
include("required", "optional", "embedded")
126+
}
127+
for (mod in fossilsAndArcheologyRevivalWithDeps) modImplementation(mod)
122128

123-
val dungeonNowLoadingWithDeps: List<Dependency> = fletchingTable.modrinthBundle("dungeon-now-loading", commonMod.mc, "forge") {
124-
recursive = true
125-
include("required", "optional", "embedded")
126-
}
127-
for (mod in dungeonNowLoadingWithDeps) modImplementation(mod)
128-
129-
//modImplementation(fletchingTable.modrinth("fungal-infectionspore", commonMod.mc, "forge"))
130-
//modImplementation(fletchingTable.modrinth("dungeons-enhanced", commonMod.mc, "forge"))
131-
//modImplementation(fletchingTable.modrinth("legendary-monsters", commonMod.mc, "forge"))
132-
/*
133-
val endersCataclysmWithDeps: List<Dependency> = fletchingTable.modrinthBundle("l_enders-cataclysm", commonMod.mc, "forge") {
134-
recursive = true
135-
include("required", "optional", "embedded")
136-
}
137-
for (mod in endersCataclysmWithDeps) modImplementation(mod)*/
129+
val dungeonNowLoadingWithDeps: List<Dependency> =
130+
fletchingTable.modrinthBundle("dungeon-now-loading", commonMod.mc, "forge") {
131+
recursive = true
132+
include("required", "optional", "embedded")
133+
}
134+
for (mod in dungeonNowLoadingWithDeps) modImplementation(mod)
138135

139-
// For debugging
140-
// modImplementation(modrinth("blue-skies", "1.3.31")) { transitive = false }
136+
// Explorations
137+
val explorations: List<Dependency> = fletchingTable.modrinthBundle("explorations", commonMod.mc, "forge") {
138+
recursive = true
139+
include("required", "optional", "embedded")
140+
}
141+
for (mod in explorations) modImplementation(mod)
142+
143+
//modImplementation(fletchingTable.modrinth("fungal-infectionspore", commonMod.mc, "forge"))
144+
//modImplementation(fletchingTable.modrinth("dungeons-enhanced", commonMod.mc, "forge"))
145+
//modImplementation(fletchingTable.modrinth("legendary-monsters", commonMod.mc, "forge"))
146+
/*
147+
val endersCataclysmWithDeps: List<Dependency> = fletchingTable.modrinthBundle("l_enders-cataclysm", commonMod.mc, "forge") {
148+
recursive = true
149+
include("required", "optional", "embedded")
150+
}
151+
for (mod in endersCataclysmWithDeps) modImplementation(mod)*/
152+
153+
// For debugging
154+
// modImplementation(modrinth("blue-skies", "1.3.31")) { transitive = false }
155+
}
141156
}
142157

143158
legacyForge {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ java.version=
1111
mod.name=Structurify
1212
mod.id=structurify
1313
mod.group=com.faboslav.structurify
14-
mod.version=2.0.24
14+
mod.version=2.0.25
1515
mod.author=Faboslav
1616
mod.description=Configuration mod that makes configuring everything related to structures very easy and accessible, eliminating the hassle of creating multiple datapacks.
1717
mod.license=CC-BY-NC-ND-4.0

0 commit comments

Comments
 (0)