@@ -30,6 +30,7 @@ import net.minecraft.nbt.NbtIo
3030import net.minecraft.nbt.NbtSizeTracker
3131import net.minecraft.registry.Registries
3232import net.minecraft.structure.StructureTemplate
33+ import java.io.FileNotFoundException
3334import java.nio.file.FileSystems
3435import java.nio.file.Files
3536import java.nio.file.Path
@@ -74,25 +75,26 @@ object StructureRegistry : ConcurrentHashMap<String, StructureTemplate>(), Loada
7475 * @param convert Whether to replace the file after converting it.
7576 *
7677 * @throws IllegalStateException if there was an error while parsing the data
78+ * @throws FileNotFoundException when the given path doesn't exist
7779 */
7880 fun loadStructureByRelativePath (
7981 relativePath : Path ,
8082 convert : Boolean = true,
8183 ): StructureTemplate {
82- updateFileWatcher()
84+ updateFileWatcher(convert )
8385
84- val struct = loadFileAndCreate(relativePath, convert)
85- putIfAbsent(relativePath.pathString.lowercase(), struct )
86+ val structure = loadFileAndCreate(relativePath, convert)
87+ putIfAbsent(relativePath.pathString, structure )
8688
87- return struct
89+ return structure
8890 }
8991
9092 /* *
9193 * Poll directory file events to load many structures at once.
9294 * They might not show up in the command suggestion, but they are
9395 * present in the map.
9496 */
95- private fun updateFileWatcher () {
97+ private fun updateFileWatcher (convert : Boolean ) {
9698 pathWatcher.poll()?.let { key ->
9799 key.pollEvents()
98100 ?.filterIsInstance<WatchEvent <Path >>()
@@ -102,8 +104,8 @@ object StructureRegistry : ConcurrentHashMap<String, StructureTemplate>(), Loada
102104 when (event.kind()) {
103105 ENTRY_DELETE -> remove(newPath.pathString)
104106 ENTRY_CREATE -> {
105- putIfAbsent (newPath.pathString,
106- loadStructureByRelativePath (newPath, convert = true ))
107+ put (newPath.pathString,
108+ loadFileAndCreate (newPath, convert))
107109 }
108110 }
109111
0 commit comments