diff options
| author | Linnea Gräf <nea@nea.moe> | 2025-11-17 19:55:02 +0100 |
|---|---|---|
| committer | Linnea Gräf <nea@nea.moe> | 2025-11-17 19:55:02 +0100 |
| commit | c93a04a001b0f66b2724d46b04b6d1ed49a08d07 (patch) | |
| tree | 5869ca70acc482ef0362f27785c3d3f1cbb9ffae /src/test | |
| parent | af9893b59407c69d31ebd2ed513f0396ab4d2dc9 (diff) | |
| download | Firmament-c93a04a001b0f66b2724d46b04b6d1ed49a08d07.tar.gz Firmament-c93a04a001b0f66b2724d46b04b6d1ed49a08d07.tar.bz2 Firmament-c93a04a001b0f66b2724d46b04b6d1ed49a08d07.zip | |
refactor: port to mojmaps
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/kotlin/features/macros/KeyComboTrieCreation.kt | 8 | ||||
| -rw-r--r-- | src/test/kotlin/root.kt | 6 | ||||
| -rw-r--r-- | src/test/kotlin/testutil/ItemResources.kt | 50 | ||||
| -rw-r--r-- | src/test/kotlin/util/math/ProjectionsBoxTest.kt | 6 | ||||
| -rw-r--r-- | src/test/kotlin/util/skyblock/AbilityUtilsTest.kt | 12 |
5 files changed, 41 insertions, 41 deletions
diff --git a/src/test/kotlin/features/macros/KeyComboTrieCreation.kt b/src/test/kotlin/features/macros/KeyComboTrieCreation.kt index c3372e4..31fc3f7 100644 --- a/src/test/kotlin/features/macros/KeyComboTrieCreation.kt +++ b/src/test/kotlin/features/macros/KeyComboTrieCreation.kt @@ -2,7 +2,7 @@ package moe.nea.firmament.test.features.macros import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test -import net.minecraft.client.util.InputUtil +import com.mojang.blaze3d.platform.InputConstants import moe.nea.firmament.features.macros.Branch import moe.nea.firmament.features.macros.ComboKeyAction import moe.nea.firmament.features.macros.CommandAction @@ -12,9 +12,9 @@ import moe.nea.firmament.keybindings.SavedKeyBinding class KeyComboTrieCreation { val basicAction = CommandAction("ac Hello") - val aPress = SavedKeyBinding.keyWithoutMods(InputUtil.GLFW_KEY_A) - val bPress = SavedKeyBinding.keyWithoutMods(InputUtil.GLFW_KEY_B) - val cPress = SavedKeyBinding.keyWithoutMods(InputUtil.GLFW_KEY_C) + val aPress = SavedKeyBinding.keyWithoutMods(InputConstants.KEY_A) + val bPress = SavedKeyBinding.keyWithoutMods(InputConstants.KEY_B) + val cPress = SavedKeyBinding.keyWithoutMods(InputConstants.KEY_C) @Test fun testValidShortTrie() { diff --git a/src/test/kotlin/root.kt b/src/test/kotlin/root.kt index 000ddda..74549e1 100644 --- a/src/test/kotlin/root.kt +++ b/src/test/kotlin/root.kt @@ -1,6 +1,6 @@ package moe.nea.firmament.test -import net.minecraft.Bootstrap +import net.minecraft.server.Bootstrap import net.minecraft.SharedConstants import moe.nea.firmament.util.TimeMark @@ -12,8 +12,8 @@ object FirmTestBootstrap { } init { - SharedConstants.createGameVersion() - Bootstrap.initialize() + SharedConstants.tryDetectVersion() + Bootstrap.bootStrap() } val loadEnd = TimeMark.now() diff --git a/src/test/kotlin/testutil/ItemResources.kt b/src/test/kotlin/testutil/ItemResources.kt index 60925c7..5f08847 100644 --- a/src/test/kotlin/testutil/ItemResources.kt +++ b/src/test/kotlin/testutil/ItemResources.kt @@ -4,17 +4,17 @@ import com.mojang.datafixers.DSL import com.mojang.serialization.Dynamic import com.mojang.serialization.JsonOps import net.minecraft.SharedConstants -import net.minecraft.datafixer.Schemas -import net.minecraft.datafixer.TypeReferences -import net.minecraft.item.ItemStack -import net.minecraft.nbt.NbtCompound -import net.minecraft.nbt.NbtElement +import net.minecraft.util.datafix.DataFixers +import net.minecraft.util.datafix.fixes.References +import net.minecraft.world.item.ItemStack +import net.minecraft.nbt.CompoundTag +import net.minecraft.nbt.Tag import net.minecraft.nbt.NbtOps -import net.minecraft.nbt.NbtString -import net.minecraft.nbt.StringNbtReader -import net.minecraft.registry.RegistryOps -import net.minecraft.text.Text -import net.minecraft.text.TextCodecs +import net.minecraft.nbt.StringTag +import net.minecraft.nbt.TagParser +import net.minecraft.resources.RegistryOps +import net.minecraft.network.chat.Component +import net.minecraft.network.chat.ComponentSerialization import moe.nea.firmament.features.debug.ExportedTestConstantMeta import moe.nea.firmament.test.FirmTestBootstrap import moe.nea.firmament.util.MC @@ -32,22 +32,22 @@ object ItemResources { .readAllBytes().decodeToString() } - fun loadSNbt(path: String): NbtCompound { - return StringNbtReader.readCompound(loadString(path)) + fun loadSNbt(path: String): CompoundTag { + return TagParser.parseCompoundFully(loadString(path)) } - fun getNbtOps(): RegistryOps<NbtElement> = MC.currentOrDefaultRegistries.getOps(NbtOps.INSTANCE) + fun getNbtOps(): RegistryOps<Tag> = MC.currentOrDefaultRegistries.createSerializationContext(NbtOps.INSTANCE) fun tryMigrateNbt( - nbtCompound: NbtCompound, - typ: DSL.TypeReference?, - ): NbtElement { - val source = nbtCompound.get("source", ExportedTestConstantMeta.CODEC) + nbtCompound: CompoundTag, + typ: DSL.TypeReference?, + ): Tag { + val source = nbtCompound.read("source", ExportedTestConstantMeta.CODEC) nbtCompound.remove("source") if (source.isPresent) { - val wrappedNbtSource = if (typ == TypeReferences.TEXT_COMPONENT && source.get().dataVersion < 4325) { + val wrappedNbtSource = if (typ == References.TEXT_COMPONENT && source.get().dataVersion < 4325) { // Per 1.21.5 text components are wrapped in a string, which firmament unwrapped in the snbt files - NbtString.of( + StringTag.valueOf( NbtOps.INSTANCE.convertTo(JsonOps.INSTANCE, nbtCompound) .toString() ) @@ -55,12 +55,12 @@ object ItemResources { nbtCompound } if (typ != null) { - return Schemas.getFixer() + return DataFixers.getDataFixer() .update( typ, Dynamic(NbtOps.INSTANCE, wrappedNbtSource), source.get().dataVersion, - SharedConstants.getGameVersion().dataVersion().id + SharedConstants.getCurrentVersion().dataVersion().version ).value } else { wrappedNbtSource @@ -76,17 +76,17 @@ object ItemResources { ).getOrThrow { IllegalStateException("Could not load tablist '$name': $it") } } - fun loadText(name: String): Text { - return TextCodecs.CODEC.parse( + fun loadText(name: String): Component { + return ComponentSerialization.CODEC.parse( getNbtOps(), - tryMigrateNbt(loadSNbt("testdata/chat/$name.snbt"), TypeReferences.TEXT_COMPONENT) + tryMigrateNbt(loadSNbt("testdata/chat/$name.snbt"), References.TEXT_COMPONENT) ).getOrThrow { IllegalStateException("Could not load test chat '$name': $it") } } fun loadItem(name: String): ItemStack { try { val itemNbt = loadSNbt("testdata/items/$name.snbt") - return ItemStack.CODEC.parse(getNbtOps(), tryMigrateNbt(itemNbt, TypeReferences.ITEM_STACK)).orThrow + return ItemStack.CODEC.parse(getNbtOps(), tryMigrateNbt(itemNbt, References.ITEM_STACK)).orThrow } catch (ex: Exception) { throw RuntimeException("Could not load item resource '$name'", ex) } diff --git a/src/test/kotlin/util/math/ProjectionsBoxTest.kt b/src/test/kotlin/util/math/ProjectionsBoxTest.kt index 04720a3..dc06e4b 100644 --- a/src/test/kotlin/util/math/ProjectionsBoxTest.kt +++ b/src/test/kotlin/util/math/ProjectionsBoxTest.kt @@ -5,7 +5,7 @@ import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.DynamicTest import org.junit.jupiter.api.TestFactory import kotlin.streams.asStream -import net.minecraft.util.math.Vec2f +import net.minecraft.world.phys.Vec2 import moe.nea.firmament.util.math.Projections class ProjectionsBoxTest { @@ -14,8 +14,8 @@ class ProjectionsBoxTest { @TestFactory fun testProjections(): Stream<DynamicTest> { return sequenceOf( - 0.0.degrees to Vec2f(1F, 0F), - 63.4349.degrees to Vec2f(0.5F, 1F), + 0.0.degrees to Vec2(1F, 0F), + 63.4349.degrees to Vec2(0.5F, 1F), ).map { (angle, expected) -> DynamicTest.dynamicTest("ProjectionsBoxTest::projectAngleOntoUnitBox(${angle})") { val actual = Projections.Two.projectAngleOntoUnitBox(angle) diff --git a/src/test/kotlin/util/skyblock/AbilityUtilsTest.kt b/src/test/kotlin/util/skyblock/AbilityUtilsTest.kt index 9d25aad..43a3212 100644 --- a/src/test/kotlin/util/skyblock/AbilityUtilsTest.kt +++ b/src/test/kotlin/util/skyblock/AbilityUtilsTest.kt @@ -4,7 +4,7 @@ import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds -import net.minecraft.text.Text +import net.minecraft.network.chat.Component import moe.nea.firmament.test.testutil.ItemResources import moe.nea.firmament.util.skyblock.AbilityUtils import moe.nea.firmament.util.unformattedString @@ -12,7 +12,7 @@ import moe.nea.firmament.util.unformattedString class AbilityUtilsTest { fun List<AbilityUtils.ItemAbility>.stripDescriptions() = map { - it.copy(descriptionLines = it.descriptionLines.map { Text.literal(it.unformattedString) }) + it.copy(descriptionLines = it.descriptionLines.map { Component.literal(it.unformattedString) }) } @Test @@ -28,7 +28,7 @@ class AbilityUtilsTest { "Throw your pickaxe to create an", "explosion mining all ores in a 3 block", "radius." - ).map(Text::literal), + ).map(Component::literal), 48.seconds ) ), @@ -48,7 +48,7 @@ class AbilityUtilsTest { listOf( "Grants +200% ⸕ Mining Speed for", "10s." - ).map(Text::literal), + ).map(Component::literal), 2.minutes ) ), @@ -65,7 +65,7 @@ class AbilityUtilsTest { listOf( "Teleport 12 blocks ahead of you and", "gain +50 ✦ Speed for 3 seconds." - ).map(Text::literal), + ).map(Component::literal), null ), AbilityUtils.ItemAbility( @@ -77,7 +77,7 @@ class AbilityUtilsTest { "Teleport to your targeted block up", "to 61 blocks away.", "Soulflow Cost: 1" - ).map(Text::literal), + ).map(Component::literal), null ) ), |
