Skip to content

Commit 076e2c2

Browse files
committed
Some fixes
1 parent a0ade28 commit 076e2c2

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

common/src/main/kotlin/com/lambda/interaction/construction/StructureRegistry.kt

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.lambda.interaction.construction
22

33
import com.lambda.Lambda.LOG
4-
import com.lambda.Lambda.mc
54
import com.lambda.core.Loadable
65
import com.lambda.util.Communication.logError
76
import com.lambda.util.FolderRegister
@@ -14,7 +13,6 @@ import net.minecraft.nbt.NbtIo
1413
import net.minecraft.nbt.NbtSizeTracker
1514
import net.minecraft.registry.Registries
1615
import net.minecraft.structure.StructureTemplate
17-
import net.minecraft.util.WorldSavePath
1816
import java.nio.file.*
1917
import java.nio.file.StandardWatchEventKinds.ENTRY_CREATE
2018
import 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

Comments
 (0)