Skip to content

Commit

Permalink
Fixed #12.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxenceDC committed Jan 3, 2024
1 parent ff3eb2b commit 08a1875
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies {
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
//modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
}

processResources {
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.20.2
yarn_mappings=1.20.2+build.4
loader_version=0.14.24
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.15.3

# Mod Properties
mod_version = 2.1
mod_version = 2.2
maven_group = io.github.maxencedc
archives_base_name = sparsestructures

# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.90.7+1.20.2
fabric_version=0.91.0+1.20.1
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,19 @@ private static <E> void load(RegistryOps.RegistryInfoGetter registryInfoGetter,
String structure_set = registryKey.getValue().toString();
return structure_set.equals(s.structure()) || jsonElement.getAsJsonObject().getAsJsonArray("structures").asList().stream().anyMatch(p -> p.getAsJsonObject().get("structure").getAsString().equals(s.structure()));
}).findFirst().orElse(new CustomSpreadFactors("", SparseStructures.config.spreadFactor())).factor();
int spacing = (int)(Math.min(jsonElement.getAsJsonObject().getAsJsonObject("placement").get("spacing").getAsDouble() * factor, 4096.0));
int separation = (int)(Math.min(jsonElement.getAsJsonObject().getAsJsonObject("placement").get("separation").getAsDouble() * factor, 4096.0));

int spacing;
int separation;

if (jsonElement.getAsJsonObject().getAsJsonObject("placement").get("spacing") == null) spacing = 1;
else spacing = (int)(Math.min(jsonElement.getAsJsonObject().getAsJsonObject("placement").get("spacing").getAsDouble() * factor, 4096.0));
if (jsonElement.getAsJsonObject().getAsJsonObject("placement").get("separation") == null) separation = 1;
else separation = (int)(Math.min(jsonElement.getAsJsonObject().getAsJsonObject("placement").get("separation").getAsDouble() * factor, 4096.0));
if (separation >= spacing) {
if (spacing == 0) spacing = 1;
separation = spacing - 1;
}

jsonElement.getAsJsonObject().getAsJsonObject("placement").addProperty("spacing", spacing);
jsonElement.getAsJsonObject().getAsJsonObject("placement").addProperty("separation", separation);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"version": "${version}",

"name": "Sparse Structures",
"description": "Makes all structures more spread out. Now configurable.",
"description": "Makes all structures more spread out. Configurable.",
"authors": [
"MaxenceDC (ign: EulerIdentity)"
"MaxenceDC (ign: Mythologique)"
],
"contact": {
"website": "https://maxencedc.github.io",
Expand Down

0 comments on commit 08a1875

Please sign in to comment.