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 | |
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')
-rw-r--r-- | src/test/kotlin/root.kt | 29 | ||||
-rw-r--r-- | src/test/kotlin/testutil/ItemResources.kt | 30 | ||||
-rw-r--r-- | src/test/kotlin/util/ColorCodeTest.kt (renamed from src/test/kotlin/moe/nea/firmament/test/ColorCode.kt) | 7 | ||||
-rw-r--r-- | src/test/kotlin/util/skyblock/AbilityUtilsTest.kt | 79 | ||||
-rw-r--r-- | src/test/resources/testdata/items/aspect-of-the-void.snbt | 59 | ||||
-rw-r--r-- | src/test/resources/testdata/items/diamond-pickaxe.snbt | 48 | ||||
-rw-r--r-- | src/test/resources/testdata/items/titanium-drill.snbt | 97 |
7 files changed, 346 insertions, 3 deletions
diff --git a/src/test/kotlin/root.kt b/src/test/kotlin/root.kt new file mode 100644 index 0000000..679ecb4 --- /dev/null +++ b/src/test/kotlin/root.kt @@ -0,0 +1,29 @@ +package moe.nea.firmament.test + +import net.minecraft.Bootstrap +import net.minecraft.SharedConstants +import moe.nea.firmament.util.TimeMark + + object FirmTestBootstrap { + val loadStart = TimeMark.now() + + init { + println("Bootstrap started at $loadStart") + } + + init { + SharedConstants.createGameVersion() + Bootstrap.initialize() + } + + val loadEnd = TimeMark.now() + + val loadDuration = loadStart.passedAt(loadEnd) + + init { + println("Bootstrap completed at $loadEnd after $loadDuration") + } + + fun bootstrapMinecraft() { + } +} 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") } + } +} diff --git a/src/test/kotlin/moe/nea/firmament/test/ColorCode.kt b/src/test/kotlin/util/ColorCodeTest.kt index 5889bc7..d9de36a 100644 --- a/src/test/kotlin/moe/nea/firmament/test/ColorCode.kt +++ b/src/test/kotlin/util/ColorCodeTest.kt @@ -1,12 +1,13 @@ - -package moe.nea.firmament.test +package moe.nea.firmament.test.util import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test +import net.minecraft.Bootstrap +import net.minecraft.SharedConstants import moe.nea.firmament.util.removeColorCodes -class ColorCode { +class ColorCodeTest { @Test fun testWhatever() { Assertions.assertEquals("", "".removeColorCodes().toString()) diff --git a/src/test/kotlin/util/skyblock/AbilityUtilsTest.kt b/src/test/kotlin/util/skyblock/AbilityUtilsTest.kt new file mode 100644 index 0000000..abe739d --- /dev/null +++ b/src/test/kotlin/util/skyblock/AbilityUtilsTest.kt @@ -0,0 +1,79 @@ +package moe.nea.firmament.test.util.skyblock + +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 moe.nea.firmament.test.testutil.ItemResources +import moe.nea.firmament.util.skyblock.AbilityUtils +import moe.nea.firmament.util.unformattedString + +class AbilityUtilsTest { + + fun List<AbilityUtils.ItemAbility>.stripDescriptions() = map { + it.copy(descriptionLines = it.descriptionLines.map { Text.literal(it.unformattedString) }) + } + + @Test + fun testUnpoweredDrill() { + Assertions.assertEquals( + listOf( + AbilityUtils.ItemAbility( + "Pickobulus", + false, + AbilityUtils.AbilityActivation.RIGHT_CLICK, + null, + listOf("Throw your pickaxe to create an", + "explosion mining all ores in a 3 block", + "radius.").map(Text::literal), + 48.seconds + ) + ), + AbilityUtils.getAbilities(ItemResources.loadItem("titanium-drill")).stripDescriptions() + ) + } + + @Test + fun testPoweredPickaxe() { + Assertions.assertEquals( + listOf( + AbilityUtils.ItemAbility( + "Mining Speed Boost", + true, + AbilityUtils.AbilityActivation.RIGHT_CLICK, + null, + listOf("Grants +200% ⸕ Mining Speed for", + "10s.").map(Text::literal), + 2.minutes + ) + ), + AbilityUtils.getAbilities(ItemResources.loadItem("diamond-pickaxe")).stripDescriptions() + ) + } + + @Test + fun testAOTV() { + Assertions.assertEquals( + listOf( + AbilityUtils.ItemAbility( + "Instant Transmission", true, AbilityUtils.AbilityActivation.RIGHT_CLICK, 23, + listOf("Teleport 12 blocks ahead of you and", + "gain +50 ✦ Speed for 3 seconds.").map(Text::literal), + null + ), + AbilityUtils.ItemAbility( + "Ether Transmission", + false, + AbilityUtils.AbilityActivation.SNEAK_RIGHT_CLICK, + 90, + listOf("Teleport to your targeted block up", + "to 61 blocks away.", + "Soulflow Cost: 1").map(Text::literal), + null + ) + ), + AbilityUtils.getAbilities(ItemResources.loadItem("aspect-of-the-void")).stripDescriptions() + ) + } +} diff --git a/src/test/resources/testdata/items/aspect-of-the-void.snbt b/src/test/resources/testdata/items/aspect-of-the-void.snbt new file mode 100644 index 0000000..180c069 --- /dev/null +++ b/src/test/resources/testdata/items/aspect-of-the-void.snbt @@ -0,0 +1,59 @@ +{ + components: { + "minecraft:attribute_modifiers": { + modifiers: [ + ], + show_in_tooltip: 0b + }, + "minecraft:custom_data": { + donated_museum: 1b, + enchantments: { + ultimate_wise: 5 + }, + ethermerge: 1b, + gems: { + }, + id: "ASPECT_OF_THE_VOID", + modifier: "heroic", + originTag: "ASPECT_OF_THE_VOID", + power_ability_scroll: "SAPPHIRE_POWER_SCROLL", + timestamp: 1641640380000L, + tuned_transmission: 4, + uuid: "b0572534-eb14-46cd-90c6-0df878fd56a2" + }, + "minecraft:custom_name": '{"extra":[{"color":"dark_purple","text":"Heroic Aspect of the Void"}],"italic":false,"text":""}', + "minecraft:enchantment_glint_override": 1b, + "minecraft:hide_additional_tooltip": { + }, + "minecraft:lore": [ + '{"extra":[{"color":"gray","text":"Damage: "},{"color":"red","text":"+120"}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":"Strength: "},{"color":"red","text":"+132 "},{"color":"blue","text":"(+32)"}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":"Bonus Attack Speed: "},{"color":"red","text":"+3% "},{"color":"blue","text":"(+3%)"}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":"Intelligence: "},{"color":"green","text":"+80 "},{"color":"blue","text":"(+80)"}],"italic":false,"text":""}', + '{"extra":[" ",{"color":"dark_gray","text":"["},{"color":"gray","text":"✎"},{"color":"dark_gray","text":"]"}],"italic":false,"text":""}', + '{"italic":false,"text":""}', + '{"extra":[{"color":"blue","text":""},{"bold":true,"color":"light_purple","text":"Ultimate Wise V"}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":"Reduces the ability mana cost of this"}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":"item by "},{"color":"green","text":"50%"},{"color":"gray","text":"."}],"italic":false,"text":""}', + '{"italic":false,"text":""}', + '{"extra":[{"bold":true,"color":"aqua","text":"⦾ "},{"color":"gold","text":"Ability: Instant Transmission "},{"bold":true,"color":"yellow","text":"RIGHT CLICK"}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":"Teleport "},{"color":"green","text":"12 blocks"},{"color":"gray","text":" ahead of you and"}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":"gain "},{"color":"green","text":"+50 "},{"color":"white","text":"✦ Speed"},{"color":"gray","text":" for "},{"color":"green","text":"3 seconds"},{"color":"gray","text":"."}],"italic":false,"text":""}', + '{"extra":[{"color":"dark_gray","text":"Mana Cost: "},{"color":"dark_aqua","text":"23"}],"italic":false,"text":""}', + '{"italic":false,"text":""}', + '{"extra":[{"color":"gold","text":"Ability: Ether Transmission "},{"bold":true,"color":"yellow","text":"SNEAK RIGHT CLICK"}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":"Teleport to your targeted block up"}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":"to "},{"color":"green","text":"61 blocks "},{"color":"gray","text":"away."}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":""},{"color":"dark_gray","text":"Soulflow Cost: "},{"color":"dark_aqua","text":"1"}],"italic":false,"text":""}', + '{"extra":[{"color":"dark_gray","text":"Mana Cost: "},{"color":"dark_aqua","text":"90"}],"italic":false,"text":""}', + '{"italic":false,"text":""}', + '{"extra":[{"bold":true,"color":"dark_gray","text":"* "},{"color":"dark_gray","text":"Co-op Soulbound "},{"bold":true,"color":"dark_gray","text":"*"}],"italic":false,"text":""}', + '{"extra":[{"bold":true,"color":"dark_purple","text":"EPIC SWORD"}],"italic":false,"text":""}' + ], + "minecraft:unbreakable": { + show_in_tooltip: 0b + } + }, + count: 1, + id: "minecraft:diamond_shovel" +} diff --git a/src/test/resources/testdata/items/diamond-pickaxe.snbt b/src/test/resources/testdata/items/diamond-pickaxe.snbt new file mode 100644 index 0000000..cce12f9 --- /dev/null +++ b/src/test/resources/testdata/items/diamond-pickaxe.snbt @@ -0,0 +1,48 @@ +{ + components: { + "minecraft:attribute_modifiers": { + modifiers: [ + ], + show_in_tooltip: 0b + }, + "minecraft:custom_data": { + enchantments: { + efficiency: 10 + }, + id: "DIAMOND_PICKAXE", + power_ability_scroll: "SAPPHIRE_POWER_SCROLL", + timestamp: 1659795180000L, + uuid: "d213f48e-d927-4748-a58c-eb80735025b7" + }, + "minecraft:custom_name": '{"extra":[{"color":"green","text":"Diamond Pickaxe"}],"italic":false,"text":""}', + "minecraft:enchantments": { + levels: { + } + }, + "minecraft:hide_additional_tooltip": { + }, + "minecraft:lore": [ + '{"extra":[{"color":"dark_gray","text":"Breaking Power 4"}],"italic":false,"text":""}', + '{"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":"Damage: "},{"color":"red","text":"+30"}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":"Mining Speed: "},{"color":"green","text":"+220"}],"italic":false,"text":""}', + '{"italic":false,"text":""}', + '{"extra":[{"color":"blue","text":"Efficiency X"}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":"Increases how quickly your tool"}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":"breaks blocks."}],"italic":false,"text":""}', + '{"italic":false,"text":""}', + '{"extra":[{"bold":true,"color":"aqua","text":"⦾ "},{"color":"gold","text":"Ability: Mining Speed Boost "},{"bold":true,"color":"yellow","text":"RIGHT CLICK"}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":"Grants "},{"color":"gold","text":"+200% "},{"color":"gold","text":"⸕ Mining Speed "},{"color":"gray","text":"for"}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":""},{"color":"green","text":"10s"},{"color":"gray","text":"."}],"italic":false,"text":""}', + '{"extra":[{"color":"dark_gray","text":"Cooldown: "},{"color":"green","text":"120s"}],"italic":false,"text":""}', + '{"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":""},{"color":"dark_gray","text":"This item can be reforged!"}],"italic":false,"text":""}', + '{"extra":[{"bold":true,"color":"green","text":"UNCOMMON PICKAXE"}],"italic":false,"text":""}' + ], + "minecraft:unbreakable": { + show_in_tooltip: 0b + } + }, + count: 1, + id: "minecraft:diamond_pickaxe" +} diff --git a/src/test/resources/testdata/items/titanium-drill.snbt b/src/test/resources/testdata/items/titanium-drill.snbt new file mode 100644 index 0000000..e3b6819 --- /dev/null +++ b/src/test/resources/testdata/items/titanium-drill.snbt @@ -0,0 +1,97 @@ +{ + components: { + "minecraft:attribute_modifiers": { + modifiers: [ + ], + show_in_tooltip: 0b + }, + "minecraft:custom_data": { + compact_blocks: 1023815, + donated_museum: 1b, + drill_fuel: 16621, + drill_part_fuel_tank: "titanium_fuel_tank", + drill_part_upgrade_module: "goblin_omelette_blue_cheese", + enchantments: { + compact: 10, + efficiency: 5, + experience: 3, + fortune: 3, + paleontologist: 2, + pristine: 5 + }, + gems: { + AMBER_0: { + quality: "PERFECT", + uuid: "d28be6ae-75eb-49e4-90d8-31759db18d79" + }, + JADE_0: { + quality: "PERFECT", + uuid: "657fea0b-88e2-483d-9d2c-0b821797a55a" + }, + MINING_0: { + quality: "PERFECT", + uuid: "257bdcd2-585b-48b9-9517-a2e841dc0574" + }, + MINING_0_gem: "TOPAZ", + unlocked_slots: [ + "JADE_0", + "MINING_0" + ] + }, + id: "TITANIUM_DRILL_4", + modifier: "auspicious", + rarity_upgrades: 1, + timestamp: 1700577120000L, + uuid: "367b85ab-5bb4-43b6-a055-084cbaaafc1c" + }, + "minecraft:custom_name": '{"extra":[{"color":"light_purple","text":"Auspicious Titanium Drill DR-X655"}],"italic":false,"text":""}', + "minecraft:enchantment_glint_override": 1b, + "minecraft:hide_additional_tooltip": { + }, + "minecraft:lore": [ + '{"extra":[{"color":"dark_gray","text":"Breaking Power 9"}],"italic":false,"text":""}', + '{"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":"Damage: "},{"color":"red","text":"+75"}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":"Mining Speed: "},{"color":"green","text":"+1,885 "},{"color":"blue","text":"(+75) "},{"color":"light_purple","text":"(+100)"}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":"Pristine: "},{"color":"green","text":"+4.5 "},{"color":"light_purple","text":"(+2)"}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":"Mining Fortune: "},{"color":"green","text":"+220 "},{"color":"blue","text":"(+20) "},{"color":"light_purple","text":"(+50)"}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":"Mining Wisdom: "},{"color":"green","text":"+10"}],"italic":false,"text":""}', + '{"extra":[" ",{"color":"gold","text":"["},{"color":"gold","text":"⸕"},{"color":"gold","text":"] "},{"color":"gold","text":"["},{"color":"green","text":"☘"},{"color":"gold","text":"] "},{"color":"gold","text":"["},{"color":"yellow","text":"✦"},{"color":"gold","text":"]"}],"italic":false,"text":""}', + '{"italic":false,"text":""}', + '{"extra":[{"color":"blue","text":"Compact X"}],"italic":false,"text":""}', + '{"extra":[{"color":"blue","text":"Efficiency V"}],"italic":false,"text":""}', + '{"extra":[{"color":"blue","text":"Experience III"}],"italic":false,"text":""}', + '{"extra":[{"color":"blue","text":"Fortune III"}],"italic":false,"text":""}', + '{"extra":[{"color":"blue","text":"Paleontologist II"}],"italic":false,"text":""}', + '{"extra":[{"color":"blue","text":"Prismatic V"}],"italic":false,"text":""}', + '{"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":""},{"color":"green","text":"Titanium-Infused Fuel Tank."}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":""},{"color":"gray","text":""},{"color":"dark_green","text":"25,000 Max Fuel Capacity."}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":""},{"color":"gray","text":""},{"color":"green","text":"-4% Pickaxe Ability Cooldown."}],"italic":false,"text":""}', + '{"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":""},{"color":"gray","text":"Drill Engine: "},{"color":"red","text":"Not Installed"}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":""},{"color":"gray","text":"Increases "},{"color":"gold","text":"⸕ Mining Speed "},{"color":"gray","text":"with part"}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":"installed."}],"italic":false,"text":""}', + '{"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":""},{"color":"green","text":"Blue Cheese Goblin Omelette Part."}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":"Adds "},{"color":"green","text":"+1 Level "},{"color":"gray","text":"to all of your unlocked "},{"color":"dark_purple","text":"Heart of"}],"italic":false,"text":""}', + '{"extra":[{"color":"dark_purple","text":"the Mountain "},{"color":"gray","text":"perks."}],"italic":false,"text":""}', + '{"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":""},{"color":"gray","text":"Fuel: "},{"color":"dark_green","text":"16,621"},{"color":"dark_gray","text":"/25k"}],"italic":false,"text":""}', + '{"italic":false,"text":""}', + '{"extra":[{"color":"gold","text":"Ability: Pickobulus "},{"bold":true,"color":"yellow","text":"RIGHT CLICK"}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":"Throw your pickaxe to create an"}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":"explosion mining all ores in a "},{"color":"green","text":"3 "},{"color":"gray","text":"block"}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":"radius."}],"italic":false,"text":""}', + '{"extra":[{"color":"dark_gray","text":"Cooldown: "},{"color":"green","text":"48s"}],"italic":false,"text":""}', + '{"italic":false,"text":""}', + '{"extra":[{"color":"blue","text":"Auspicious Bonus"}],"italic":false,"text":""}', + '{"extra":[{"color":"gray","text":"Grants "},{"color":"gold","text":"+0.9% "},{"color":"gold","text":"☘ Mining Fortune"},{"color":"gray","text":"."}],"italic":false,"text":""}', + '{"italic":false,"text":""}', + '{"extra":[{"bold":true,"color":"dark_gray","text":"* "},{"color":"dark_gray","text":"Co-op Soulbound "},{"bold":true,"color":"dark_gray","text":"*"}],"italic":false,"text":""}', + '{"extra":[{"bold":true,"color":"light_purple","obfuscated":true,"text":"a"},"",{"bold":false,"extra":[" "],"italic":false,"obfuscated":false,"strikethrough":false,"text":"","underlined":false},{"bold":true,"color":"light_purple","text":"MYTHIC DRILL "},{"bold":true,"color":"light_purple","obfuscated":true,"text":"a"}],"italic":false,"text":""}' + ] + }, + count: 1, + id: "minecraft:prismarine_shard" +} |