diff options
| author | viciscat <51047087+viciscat@users.noreply.github.com> | 2025-06-01 02:25:16 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-01 08:25:16 +0800 |
| commit | 4c822a6383d8f92dc850c82b93fa6cd4a67f2610 (patch) | |
| tree | 714dcfd9eaa66da04546832f2a27574843d280d3 /src/test/java | |
| parent | 86f36d661f551f8639b30fb39312b6b9290b8a02 (diff) | |
| download | Skyblocker-4c822a6383d8f92dc850c82b93fa6cd4a67f2610.tar.gz Skyblocker-4c822a6383d8f92dc850c82b93fa6cd4a67f2610.tar.bz2 Skyblocker-4c822a6383d8f92dc850c82b93fa6cd4a67f2610.zip | |
Epic Armor Customization GUI (#1215)
* start creating the screen
* trim selection
* colo(u)ring and button in inventory
* translation and little touches
* translation and little touches
* things i forgot
* remove debug stuff oops
* replace speed by duration
* 1.12.5
- Remake the trim buttons because mojang hates me
- Undo the OkLabColor cache
* some docs and things
* requested changes
* fix crash in tests
* changes!
* clean up
* Test animated dye interpolation
* Add DFU for animated dye and item background
* Add slider steps
* Add config data fixer test
* Draw trim material item
* remove old stuff
* Clean up interpolate and gui code
* supplier
* 180
* grrrrr
---------
Co-authored-by: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>
Diffstat (limited to 'src/test/java')
4 files changed, 40 insertions, 4 deletions
diff --git a/src/test/java/de/hysky/skyblocker/config/datafixer/ConfigDataFixerTest.java b/src/test/java/de/hysky/skyblocker/config/datafixer/ConfigDataFixerTest.java index fcdbc314..ac3e5a1a 100644 --- a/src/test/java/de/hysky/skyblocker/config/datafixer/ConfigDataFixerTest.java +++ b/src/test/java/de/hysky/skyblocker/config/datafixer/ConfigDataFixerTest.java @@ -37,6 +37,16 @@ public class ConfigDataFixerTest { @SuppressWarnings("DataFlowIssue") JsonObject expectedNewConfig = GSON.fromJson(new InputStreamReader(ConfigDataFixerTest.class.getResourceAsStream("/assets/skyblocker/config/skyblocker-v3.json")), JsonObject.class); - Assertions.assertEquals(expectedNewConfig, ConfigDataFixer.apply(oldConfig)); + Assertions.assertEquals(expectedNewConfig, ConfigDataFixer.apply(oldConfig, 3)); } + + @Test + void testDataFixer3() { + @SuppressWarnings("DataFlowIssue") + JsonObject oldConfig = GSON.fromJson(new InputStreamReader(ConfigDataFixerTest.class.getResourceAsStream("/assets/skyblocker/config/skyblocker-v3.json")), JsonObject.class); + @SuppressWarnings("DataFlowIssue") + JsonObject expectedNewConfig = GSON.fromJson(new InputStreamReader(ConfigDataFixerTest.class.getResourceAsStream("/assets/skyblocker/config/skyblocker-v4.json")), JsonObject.class); + + Assertions.assertEquals(expectedNewConfig, ConfigDataFixer.apply(oldConfig, 4)); + } } diff --git a/src/test/java/de/hysky/skyblocker/skyblock/item/ArmorTrimIdSerializationTest.java b/src/test/java/de/hysky/skyblocker/skyblock/item/ArmorTrimIdSerializationTest.java index 8d2bfd60..a0b1b64f 100644 --- a/src/test/java/de/hysky/skyblocker/skyblock/item/ArmorTrimIdSerializationTest.java +++ b/src/test/java/de/hysky/skyblocker/skyblock/item/ArmorTrimIdSerializationTest.java @@ -4,7 +4,7 @@ import com.google.gson.Gson; import com.google.gson.JsonElement; import com.mojang.serialization.JsonOps; -import de.hysky.skyblocker.skyblock.item.CustomArmorTrims.ArmorTrimId; +import de.hysky.skyblocker.skyblock.item.custom.CustomArmorTrims.ArmorTrimId; import net.minecraft.util.Identifier; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/src/test/java/de/hysky/skyblocker/skyblock/item/custom/CustomArmorAnimatedDyesTest.java b/src/test/java/de/hysky/skyblocker/skyblock/item/custom/CustomArmorAnimatedDyesTest.java new file mode 100644 index 00000000..3e1c5d6a --- /dev/null +++ b/src/test/java/de/hysky/skyblocker/skyblock/item/custom/CustomArmorAnimatedDyesTest.java @@ -0,0 +1,25 @@ +package de.hysky.skyblocker.skyblock.item.custom; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.util.List; + +public class CustomArmorAnimatedDyesTest { + @Test + void testInterpolate() { + CustomArmorAnimatedDyes.AnimatedDye animatedDye = new CustomArmorAnimatedDyes.AnimatedDye(List.of(new CustomArmorAnimatedDyes.Keyframe(0xFF0000, 0), new CustomArmorAnimatedDyes.Keyframe(0x0000FF, 1)), true, 0, 1); + CustomArmorAnimatedDyes.AnimatedDyeStateTracker tracker = new CustomArmorAnimatedDyes.AnimatedDyeStateTracker(animatedDye); + // Expected values at 0, 0.25, 0.5, 0.75, and 1 progress + // See https://observablehq.com/@aras-p/oklab-interpolation-test for an online interpolation tool + Assertions.assertEquals(0xFE0000, tracker.interpolate(animatedDye, 0)); + Assertions.assertEquals(0xC5496C, tracker.interpolate(animatedDye, 5)); + Assertions.assertEquals(0x8C53A2, tracker.interpolate(animatedDye, 5)); + Assertions.assertEquals(0x5047D1, tracker.interpolate(animatedDye, 5)); + Assertions.assertEquals(0x0000FE, tracker.interpolate(animatedDye, 5)); + Assertions.assertEquals(0x5047D1, tracker.interpolate(animatedDye, 5)); + Assertions.assertEquals(0x8C53A2, tracker.interpolate(animatedDye, 5)); + Assertions.assertEquals(0xC5496C, tracker.interpolate(animatedDye, 5)); + Assertions.assertEquals(0xFE0000, tracker.interpolate(animatedDye, 5)); + } +} diff --git a/src/test/java/de/hysky/skyblocker/utils/datafixer/ItemStackComponentizationFixerTest.java b/src/test/java/de/hysky/skyblocker/utils/datafixer/ItemStackComponentizationFixerTest.java index bab93dfc..42d9df9e 100644 --- a/src/test/java/de/hysky/skyblocker/utils/datafixer/ItemStackComponentizationFixerTest.java +++ b/src/test/java/de/hysky/skyblocker/utils/datafixer/ItemStackComponentizationFixerTest.java @@ -1,5 +1,6 @@ package de.hysky.skyblocker.utils.datafixer; +import de.hysky.skyblocker.utils.Utils; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -26,7 +27,7 @@ public class ItemStackComponentizationFixerTest { private final ItemStack TEST_STACK = Util.make(new ItemStack(Items.DIAMOND_SWORD, 1), item -> { ItemEnchantmentsComponent.Builder builder = new ItemEnchantmentsComponent.Builder(ItemEnchantmentsComponent.DEFAULT); - builder.add(ItemStackComponentizationFixer.getRegistryLookup().getOrThrow(RegistryKeys.ENCHANTMENT).getOrThrow(Enchantments.SHARPNESS), 1); + builder.add(Utils.getRegistryWrapperLookup().getOrThrow(RegistryKeys.ENCHANTMENT).getOrThrow(Enchantments.SHARPNESS), 1); item.set(DataComponentTypes.ENCHANTMENTS, builder.build()); }); @@ -44,7 +45,7 @@ public class ItemStackComponentizationFixerTest { @Test void testDataFixer() { ItemStack fixedStack = ItemStackComponentizationFixer.fixUpItem(NBT); - JsonElement stackJson = ItemStack.CODEC.encodeStart(ItemStackComponentizationFixer.getRegistryLookup().getOps(JsonOps.INSTANCE), fixedStack).getOrThrow(); + JsonElement stackJson = ItemStack.CODEC.encodeStart(Utils.getRegistryWrapperLookup().getOps(JsonOps.INSTANCE), fixedStack).getOrThrow(); Assertions.assertEquals("{\"id\":\"minecraft:diamond_sword\",\"count\":1,\"components\":{\"minecraft:custom_data\":{\"ExtraAttributes\":{\"id\":\"TEST\"}}}}", GSON.toJson(stackJson)); } |
