Skip to content

Commit 6ace360

Browse files
committed
2.0.23
1 parent 3b708c8 commit 6ace360

12 files changed

Lines changed: 158 additions & 66 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.0.23
2+
3+
- Improved initial config load times by 20-50% due to custom registry loading logic
4+
15
## 2.0.22
26

37
- Fixed actual use of structure set's "is_disabled" property (it was not used at all)

buildSrc/src/main/kotlin/multiloader-loader.gradle.kts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import java.nio.charset.StandardCharsets
2+
import java.nio.file.Files
3+
14
plugins {
25
id("java")
36
id("idea")
@@ -29,3 +32,56 @@ tasks {
2932
from(commonResources)
3033
}
3134
}
35+
36+
val generateIdeaRunConfig = tasks.register("generateIdeaRunConfig") {
37+
doLast {
38+
val loader = requireNotNull(prop("loader"))
39+
val loaderName = requireNotNull(prop("loader_name"))
40+
val version = stonecutterBuild.current.version
41+
42+
listOf("Client", "Server").forEach { side ->
43+
val taskName = "run$side"
44+
val runFile = rootProject.file(".idea/runConfigurations/${loaderName}_${taskName}${version}.xml")
45+
val text = """
46+
<component name="ProjectRunConfigurationManager">
47+
<configuration default="false" name="Run $version $loaderName $side" type="GradleRunConfiguration" factoryName="Gradle" nameIsGenerated="false">
48+
<ExternalSystemSettings>
49+
<option name="executionName" />
50+
<option name="externalProjectPath" value="${rootProject.projectDir.absolutePath}" />
51+
<option name="externalSystemIdString" value="GRADLE" />
52+
<option name="scriptParameters" value="" />
53+
<option name="taskDescriptions">
54+
<list />
55+
</option>
56+
<option name="taskNames">
57+
<list>
58+
<option value=":$loader:$version:$taskName" />
59+
</list>
60+
</option>
61+
<option name="vmOptions" />
62+
</ExternalSystemSettings>
63+
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
64+
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
65+
<ExternalSystemDebugDisabled>false</ExternalSystemDebugDisabled>
66+
<DebugAllEnabled>false</DebugAllEnabled>
67+
<RunAsTest>false</RunAsTest>
68+
<GradleProfilingDisabled>false</GradleProfilingDisabled>
69+
<GradleCoverageDisabled>false</GradleCoverageDisabled>
70+
<method v="2" />
71+
</configuration>
72+
</component>
73+
""".trimIndent()
74+
75+
val current = if (runFile.exists()) runFile.readText() else null
76+
if (current != text) {
77+
runFile.parentFile.mkdirs()
78+
Files.writeString(runFile.toPath(), text, StandardCharsets.UTF_8)
79+
println("Updated run config: ${runFile.absolutePath}")
80+
}
81+
}
82+
}
83+
}
84+
85+
tasks.matching { it.name == "ideaSyncTask" || it.name == "neoForgeIdeSync" || it.name == "forgeIdeSync"}.configureEach {
86+
dependsOn(generateIdeaRunConfig)
87+
}

common/src/main/java/com/faboslav/structurify/common/registry/StructurifyRegistryManagerProvider.java

Lines changed: 81 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,36 @@
11
package com.faboslav.structurify.common.registry;
22

33
import com.faboslav.structurify.common.Structurify;
4-
import com.mojang.serialization.Lifecycle;
5-
import net.minecraft.util.Util;
6-
import net.minecraft.commands.Commands;
7-
import net.minecraft.core.HolderLookup;
8-
import net.minecraft.core.MappedRegistry;
4+
import com.mojang.serialization.Codec;
5+
import net.minecraft.core.*;
6+
import net.minecraft.resources.RegistryDataLoader;
7+
import net.minecraft.resources.ResourceKey;
8+
import net.minecraft.server.packs.PackType;
9+
import net.minecraft.server.packs.resources.MultiPackResourceManager;
910
import net.minecraft.core.registries.Registries;
10-
import net.minecraft.server.WorldLoader;
11-
import net.minecraft.server.WorldStem;
1211
import net.minecraft.server.packs.repository.PackRepository;
1312
import net.minecraft.server.packs.repository.RepositorySource;
14-
import net.minecraft.world.level.WorldDataConfiguration;
1513
import net.minecraft.world.level.biome.Biome;
16-
import net.minecraft.world.level.levelgen.presets.WorldPresets;
14+
import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver;
15+
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
16+
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
1717
import net.minecraft.world.level.levelgen.structure.Structure;
18+
import net.minecraft.world.level.levelgen.structure.StructureSet;
19+
import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool;
20+
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorType;
1821
import org.jetbrains.annotations.Nullable;
22+
import java.util.List;
23+
24+
//? if >= 1.21.3 {
25+
import net.minecraft.server.RegistryLayer;
26+
import net.minecraft.tags.TagLoader;
27+
//?} else {
28+
/*import net.minecraft.core.registries.BuiltInRegistries;
29+
*///?}
1930

20-
//? if >= 1.21.11 {
21-
import net.minecraft.server.permissions.PermissionSet;
31+
//? if >= 26.1 {
32+
import net.minecraft.resources.RegistryValidator;
33+
import net.minecraft.util.Util;
2234
//?}
2335

2436
public final class StructurifyRegistryManagerProvider
@@ -77,46 +89,71 @@ public static void loadRegistryManager() {
7789
}
7890

7991
var resourcePackManager = new PackRepository(StructurifyResourcePackProvider.getResourcePackProviders().toArray(new RepositorySource[0]));
80-
var dataPacks = new WorldLoader.PackConfig(resourcePackManager, WorldDataConfiguration.DEFAULT, false, false);
81-
var serverConfig = new WorldLoader.InitConfig(dataPacks, Commands.CommandSelection.INTEGRATED, /*? if >= 1.21.11 {*/PermissionSet.ALL_PERMISSIONS/*?} else {*//*2*//*?}*/);
82-
83-
var saveLoader = Util.blockUntilDone(executor ->
84-
WorldLoader.load(serverConfig, loadContextSupplierContext -> {
85-
var registry = new MappedRegistry<>(Registries.LEVEL_STEM, Lifecycle.stable()).freeze();
86-
87-
//? if >=1.21.3 {
88-
var dimensionsConfig = loadContextSupplierContext
89-
.datapackWorldgen()
90-
.lookupOrThrow(Registries.WORLD_PRESET)
91-
.getOrThrow(WorldPresets.FLAT)
92-
.value()
93-
.createWorldDimensions()
94-
.bake(registry);
95-
//?} else {
96-
/*var dimensionsConfig = loadContextSupplierContext
97-
.datapackWorldgen()
98-
.registryOrThrow(Registries.WORLD_PRESET)
99-
.getHolderOrThrow(WorldPresets.FLAT)
100-
.value()
101-
.createWorldDimensions()
102-
.bake(registry);
103-
*///?}
104-
105-
return new WorldLoader.DataLoadOutput<>(null, dimensionsConfig.dimensionsRegistryAccess());
106-
}, WorldStem::new, Util.backgroundExecutor(), executor)
107-
).get();
108-
109-
if (saveLoader == null || saveLoader.registries() == null) {
110-
Structurify.getLogger().error("SaveLoader or CombinedDynamicRegistries is null.");
111-
return;
92+
resourcePackManager.reload();
93+
resourcePackManager.setSelected(resourcePackManager.getAvailableIds());
94+
95+
try (var resourceManager = new MultiPackResourceManager(
96+
PackType.SERVER_DATA,
97+
resourcePackManager.openAllSelected()
98+
)) {
99+
List<RegistryDataLoader.RegistryData<?>> registries = List.of(
100+
getRegistryDataLoader(Registries.BIOME, Biome.DIRECT_CODEC),
101+
getRegistryDataLoader(Registries.CONFIGURED_CARVER, ConfiguredWorldCarver.DIRECT_CODEC),
102+
getRegistryDataLoader(Registries.PROCESSOR_LIST, StructureProcessorType.DIRECT_CODEC),
103+
getRegistryDataLoader(Registries.TEMPLATE_POOL, StructureTemplatePool.DIRECT_CODEC),
104+
getRegistryDataLoader(Registries.CONFIGURED_FEATURE, ConfiguredFeature.DIRECT_CODEC),
105+
getRegistryDataLoader(Registries.PLACED_FEATURE, PlacedFeature.DIRECT_CODEC),
106+
getRegistryDataLoader(Registries.STRUCTURE, Structure.DIRECT_CODEC),
107+
getRegistryDataLoader(Registries.STRUCTURE_SET, StructureSet.DIRECT_CODEC)
108+
);
109+
//? if >= 1.21.3 {
110+
LayeredRegistryAccess<RegistryLayer> initialLayers = RegistryLayer.createRegistryAccess();
111+
List<Registry.PendingTags<?>> staticLayerTags = TagLoader.loadTagsForExistingRegistries(
112+
resourceManager,
113+
initialLayers.getLayer(RegistryLayer.STATIC)
114+
);
115+
var baseRegistryAccess = TagLoader.buildUpdatedLookups(
116+
initialLayers.getAccessForLoading(RegistryLayer.WORLDGEN),
117+
staticLayerTags
118+
);
119+
//?} else {
120+
/*var baseRegistryAccess = RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY);
121+
*///?}
122+
//? if >= 26.1 {
123+
var registryAccess = Util.blockUntilDone(executor ->
124+
RegistryDataLoader.load(
125+
resourceManager,
126+
baseRegistryAccess,
127+
registries,
128+
executor
129+
)
130+
).get();
131+
//?} else {
132+
/*var registryAccess = RegistryDataLoader.load(
133+
resourceManager,
134+
baseRegistryAccess,
135+
registries
136+
);
137+
*///?}
138+
139+
setRegistryManager(registryAccess);
112140
}
113141

114-
setRegistryManager(saveLoader.registries().compositeAccess());
115142
Structurify.getLogger().info("Finished loading registry manager");
116143
} catch (Exception exception) {
117144
Structurify.getLogger().error("Failed to load registry manager.", exception);
118145
} finally {
119146
isLoading = false;
120147
}
121148
}
149+
150+
private static <T> RegistryDataLoader.RegistryData<T> getRegistryDataLoader(ResourceKey<? extends Registry<T>> key, Codec<T> codec) {
151+
//? if >= 26.1 {
152+
return new RegistryDataLoader.RegistryData<>(key, codec, RegistryValidator.none());
153+
//?} else if >= 1.21.1 {
154+
/*return new RegistryDataLoader.RegistryData<>(key, codec, false);
155+
*///?} else {
156+
/*return new RegistryDataLoader.RegistryData<>(key, codec);
157+
*///?}
158+
}
122159
}

common/src/main/resources/structurify-common.mixins.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"LevelChunkMixin",
1414
"LocateCommandInvoker",
1515
"LocateCommandMixin",
16-
"ResourceKeyArgumentInvoker",
16+
"ResourceKeyArgumentInvoker",
1717
"ResourcePackManagerAccessor",
1818
"StructureManagerMixin",
1919
"compat.RepurposedStructuresModifySpreadMixin",

fabric/build.gradle.kts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,12 @@ dependencies {
7575
}*/
7676

7777
// Litostitched
78+
/*
7879
commonMod.depOrNull("lithostitched_minecraft")?.let { lithostitchedMcVersion ->
7980
commonMod.depOrNull("lithostitched")?.let { lithostitchedVersion ->
8081
modImplementation(commonMod.modrinth("lithostitched", "${lithostitchedVersion}-fabric-${lithostitchedMcVersion}"))
8182
}
82-
}
83+
}*/
8384

8485
// Yungs api
8586
commonMod.depOrNull("yungs_api_minecraft")?.let { yungsApiMcVersion ->
@@ -106,12 +107,12 @@ loom {
106107
getByName("client") {
107108
client()
108109
configName = "Fabric Client"
109-
ideConfigGenerated(true)
110+
ideConfigGenerated(false)
110111
}
111112
getByName("server") {
112113
server()
113114
configName = "Fabric Server"
114-
ideConfigGenerated(true)
115+
ideConfigGenerated(false)
115116
}
116117
}
117118

@@ -121,13 +122,4 @@ loom {
121122
defaultRefmapName = "${mod.id}.refmap.json"
122123
}
123124
}
124-
}
125-
126-
for (meta in stonecutter.versions) tasks.register("runActive${meta.version}") {
127-
dependsOn(":${meta.project}:runClient")
128-
}
129-
130-
if (stonecutter.current.isActive) tasks.register("runActiveFabricClient") {
131-
dependsOn("runClient")
132-
description = "Fabric Client for ${stonecutter.current.version}"
133125
}

fabric/gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
loader=fabric
1+
loader=fabric
2+
loader_name=Fabric

forge/build.gradle.kts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,12 @@ legacyForge {
137137
runs {
138138
register("client") {
139139
client()
140+
ideFolderName = "Forge"
140141
ideName = "Forge Client (${project.path})"
141142
}
142143
register("server") {
143144
server()
145+
ideFolderName = "Forge"
144146
ideName = "Forge Server (${project.path})"
145147
}
146148
}
@@ -174,8 +176,4 @@ tasks {
174176
)
175177
}
176178
}
177-
}
178-
179-
if (stonecutter.current.isActive) tasks.register("buildActive") {
180-
dependsOn("build")
181179
}

forge/gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
loader=forge
1+
loader=forge
2+
loader_name=Forge

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.22
14+
mod.version=2.0.23
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

neoforge/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,12 @@ neoForge {
6262
runs {
6363
register("client") {
6464
client()
65+
ideFolderName = "NeoForge"
6566
ideName = "NeoForge Client (${project.path})"
6667
}
6768
register("server") {
6869
server()
70+
ideFolderName = "NeoForge"
6971
ideName = "NeoForge Server (${project.path})"
7072
}
7173
}

0 commit comments

Comments
 (0)