diff options
author | Linnea Gräf <nea@nea.moe> | 2024-10-13 17:32:10 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-10-13 17:32:10 +0200 |
commit | e6142bb93619dee768fc18b87ffdd28558d4bcab (patch) | |
tree | 03df79712151f7579cd683c8340741ebb3191822 /src/test/kotlin/testutil | |
parent | daa63bd914a2f6c5e9b668abb8474884685ee818 (diff) | |
download | Firmament-e6142bb93619dee768fc18b87ffdd28558d4bcab.tar.gz Firmament-e6142bb93619dee768fc18b87ffdd28558d4bcab.tar.bz2 Firmament-e6142bb93619dee768fc18b87ffdd28558d4bcab.zip |
Make pickaxe ability display use AbilityUtils
[no changelog]
Diffstat (limited to 'src/test/kotlin/testutil')
-rw-r--r-- | src/test/kotlin/testutil/ItemResources.kt | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/test/kotlin/testutil/ItemResources.kt b/src/test/kotlin/testutil/ItemResources.kt new file mode 100644 index 0000000..bd3c438 --- /dev/null +++ b/src/test/kotlin/testutil/ItemResources.kt @@ -0,0 +1,30 @@ +package moe.nea.firmament.test.testutil + +import net.minecraft.item.ItemStack +import net.minecraft.nbt.NbtCompound +import net.minecraft.nbt.NbtOps +import net.minecraft.nbt.StringNbtReader +import moe.nea.firmament.test.FirmTestBootstrap + +object ItemResources { + init { + FirmTestBootstrap.bootstrapMinecraft() + } + + fun loadString(path: String): String { + require(!path.startsWith("/")) + return ItemResources::class.java.classLoader + .getResourceAsStream(path)!! + .readAllBytes().decodeToString() + } + + fun loadSNbt(path: String): NbtCompound { + return StringNbtReader.parse(loadString(path)) + } + + fun loadItem(name: String): ItemStack { + // TODO: make the load work with enchantments + return ItemStack.CODEC.parse(NbtOps.INSTANCE, loadSNbt("testdata/items/$name.snbt")) + .getOrThrow { IllegalStateException("Could not load test item '$name': $it") } + } +} |