Skip to content

Commit

Permalink
WIP [NEW] Change NbtName repsentation from compound nesting
Browse files Browse the repository at this point in the history
Simplify naming code by switching away from single-entry-compound code
with verification.

SNBT now doesn't print root name since it's an unnamed variant, which
matches the behavior of Minecraft Java's net.minecraft.data.Main
NBT -> SNBT data generator tool with the --dev flag.
  • Loading branch information
BenWoodworth committed Sep 5, 2024
1 parent efcdd66 commit 349191a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/commonTest/kotlin/test/verify/VerifyingNbtWriter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal class VerifyingNbtWriter(
override fun beginRootTag(type: NbtTagType, name: String): Unit = transitionState(::beginRootTag) {
assertStateIs<State.InRoot>(state)
assertWrittenRootTypeEquals(tag.value.type, type)
// TODO Check name (named AND unnamed variants)
assertWrittenRootNameEquals(tag.name, name)

Unit to State.AwaitingValue(tag.value, State.Complete)
}
Expand Down Expand Up @@ -258,6 +258,10 @@ internal class VerifyingNbtWriter(
assertEquals(expected, actual, messagePrefix + "Incorrect root type was written")
}

fun assertWrittenRootNameEquals(expected: String, actual: String) {
assertEquals(expected, actual, messagePrefix + "Incorrect root name was written")
}

inline fun <reified T : NbtTag> assertWrittenTagTypeEquals(expected: NbtTag, actual: KClass<T>) {
contract { returns() implies (expected is T) }

Expand Down

0 comments on commit 349191a

Please sign in to comment.