11package com.lambda.interaction.construction
22
33import com.lambda.Lambda.LOG
4- import com.lambda.Lambda.mc
54import com.lambda.core.Loadable
65import com.lambda.util.Communication.logError
76import com.lambda.util.FolderRegister
@@ -14,7 +13,6 @@ import net.minecraft.nbt.NbtIo
1413import net.minecraft.nbt.NbtSizeTracker
1514import net.minecraft.registry.Registries
1615import net.minecraft.structure.StructureTemplate
17- import net.minecraft.util.WorldSavePath
1816import java.nio.file.*
1917import java.nio.file.StandardWatchEventKinds.ENTRY_CREATE
2018import java.nio.file.StandardWatchEventKinds.ENTRY_DELETE
@@ -57,20 +55,10 @@ object StructureRegistry : ConcurrentHashMap<String, StructureTemplate?>(), Load
5755 relativePath : Path ,
5856 convert : Boolean = true,
5957 ): StructureTemplate ? {
60- if (! structurePath.isDirectory()) {
61- logError(
62- " Invalid structure template: $relativePath " ,
63- " The structure folder is not a folder"
64- )
65- return null
66- }
67-
6858 updateFileWatcher()
6959
7060 return computeIfAbsent(relativePath.pathString.lowercase()) {
71- loadFileAndCreate(relativePath, convert)?.also {
72- LOG .info(" Loaded structure template $relativePath by ${it.author} with dimensions ${it.size.toShortString()} " )
73- }
61+ loadFileAndCreate(relativePath, convert)
7462 }
7563 }
7664
@@ -124,10 +112,7 @@ object StructureRegistry : ConcurrentHashMap<String, StructureTemplate?>(), Load
124112 if (compound.isValidStructureTemplate()) {
125113 template
126114 } else {
127- logError(
128- " Invalid structure template: $path " ,
129- " File does not match template format, it might have been corrupted" ,
130- )
115+ logError(" Corrupted structure file: ${path.pathString} " )
131116 null
132117 }
133118 }
@@ -143,7 +128,7 @@ object StructureRegistry : ConcurrentHashMap<String, StructureTemplate?>(), Load
143128 serializers[suffix]
144129 ?.invoke(this , Registries .BLOCK .readOnlyWrapper, nbt)
145130 ?.let { error ->
146- logError(" Could not create structure from file" , error.message ? : " " )
131+ logError(" Could not create structure from file: ${ error.message} " )
147132 return null
148133 }
149134 }
@@ -155,7 +140,7 @@ object StructureRegistry : ConcurrentHashMap<String, StructureTemplate?>(), Load
155140 * @param structure The [StructureTemplate] to save.
156141 */
157142 private fun saveStructure (relativePath : String , structure : StructureTemplate ) {
158- val path = structurePath.resolve(" $ relativePath.nbt " )
143+ val path = structurePath.resolve(relativePath)
159144 val compound = structure.writeNbt(NbtCompound ())
160145
161146 Files .createDirectories(path.parent)
0 commit comments