From 24a350283dee1f6babe993114d6b94e394b4dd60 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 6 Jan 2025 21:46:57 -0500 Subject: [PATCH] Cleanup --- .../allomancy/datagen/LootModifiers.java | 4 +- .../allomancy/modules/combat/CombatSetup.java | 22 +++--- .../test/modules/powers/PassivePowerTest.java | 68 ++++++++++++++++++- 3 files changed, 77 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/legobmw99/allomancy/datagen/LootModifiers.java b/src/main/java/com/legobmw99/allomancy/datagen/LootModifiers.java index c30c84fb..42983762 100644 --- a/src/main/java/com/legobmw99/allomancy/datagen/LootModifiers.java +++ b/src/main/java/com/legobmw99/allomancy/datagen/LootModifiers.java @@ -15,8 +15,8 @@ class LootModifiers extends GlobalLootModifierProvider { - LootModifiers(PackOutput output, CompletableFuture regisrties) { - super(output, regisrties, Allomancy.MODID); + LootModifiers(PackOutput output, CompletableFuture registries) { + super(output, registries, Allomancy.MODID); } private static final ResourceLocation DUNGEON = ResourceLocation.withDefaultNamespace("chests/simple_dungeon"); diff --git a/src/main/java/com/legobmw99/allomancy/modules/combat/CombatSetup.java b/src/main/java/com/legobmw99/allomancy/modules/combat/CombatSetup.java index 6d0e01bf..2737adb6 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/combat/CombatSetup.java +++ b/src/main/java/com/legobmw99/allomancy/modules/combat/CombatSetup.java @@ -9,7 +9,6 @@ import net.minecraft.core.component.DataComponents; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; import net.minecraft.tags.ItemTags; import net.minecraft.tags.TagKey; @@ -39,21 +38,18 @@ public final class CombatSetup { private static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(Allomancy.MODID); - public static final TagKey IS_COIN_HIT = TagKey.create(Registries.DAMAGE_TYPE, - ResourceLocation.fromNamespaceAndPath( - Allomancy.MODID, "is_coin_hit")); - public static final ResourceKey COIN_DAMAGE = ResourceKey.create(Registries.DAMAGE_TYPE, - ResourceLocation.fromNamespaceAndPath( - Allomancy.MODID, "coin")); + public static final TagKey IS_COIN_HIT = + TagKey.create(Registries.DAMAGE_TYPE, Allomancy.rl("is_coin_hit")); + public static final ResourceKey COIN_DAMAGE = + ResourceKey.create(Registries.DAMAGE_TYPE, Allomancy.rl("coin")); public static final DeferredItem COIN_BAG = ITEMS.registerItem("coin_bag", CoinBagItem::new); public static final DeferredItem OBSIDIAN_DAGGER = ITEMS.registerItem("obsidian_dagger", ObsidianDaggerItem::new); public static final DeferredItem KOLOSS_BLADE = ITEMS.registerItem("koloss_blade", KolossBladeItem::new); - public static final ResourceKey WOOL = ResourceKey.create(EquipmentAssets.ROOT_ID, - ResourceLocation.fromNamespaceAndPath( - Allomancy.MODID, "wool")); + public static final ResourceKey WOOL = + ResourceKey.create(EquipmentAssets.ROOT_ID, Allomancy.rl("wool")); public static final TagKey REPAIRS_MISTCLOAK = ItemTags.create(Allomancy.rl("repairs_wool_armor")); @@ -81,10 +77,8 @@ public final class CombatSetup { // TODO: would be nice if this used the iron_darker override - public static final ResourceKey ALUMINUM = ResourceKey.create(EquipmentAssets.ROOT_ID, - ResourceLocation.fromNamespaceAndPath( - Allomancy.MODID, - "aluminum")); + public static final ResourceKey ALUMINUM = + ResourceKey.create(EquipmentAssets.ROOT_ID, Allomancy.rl("aluminum")); public static final TagKey REPAIRS_ALUMINUM = ItemTags.create(Allomancy.rl("repairs_aluminum_armor")); diff --git a/src/test/java/com/legobmw99/allomancy/test/modules/powers/PassivePowerTest.java b/src/test/java/com/legobmw99/allomancy/test/modules/powers/PassivePowerTest.java index 17727c06..387359a1 100644 --- a/src/test/java/com/legobmw99/allomancy/test/modules/powers/PassivePowerTest.java +++ b/src/test/java/com/legobmw99/allomancy/test/modules/powers/PassivePowerTest.java @@ -207,7 +207,6 @@ public static void duraluminPewterDamageOutput(AllomancyTestHelper helper) { } - @GameTest @EmptyTemplate(value = "5x3x5", floor = true) @TestHolder(description = "Tests that duralumin and electrum moves you to your spawn") @@ -293,6 +292,73 @@ public static void duraluminCopperMakesYouInvis(AllomancyTestHelper helper) { }); } + @GameTest + @EmptyTemplate("1x3x1") + @TestHolder(description = "Tests that cadmium grants slow falling") + public static void cadmiumGrantsSlowFall(AllomancyTestHelper helper) { + var player = helper.makeMistbornPlayer(); + var data = player.getData(AllomancerAttachment.ALLOMANCY_DATA); + + data.setBurning(Metal.CADMIUM, true); + + helper.succeedOnTickWhen(1, () -> { + helper.assertMobEffectPresent(player, MobEffects.SLOW_FALLING, "Cadmium didn't grant slow fall"); + helper.assertMobEffectPresent(player, MobEffects.MOVEMENT_SLOWDOWN, "Cadmium also slowed player"); + }); + } + + + @GameTest + @EmptyTemplate(value = "5x3x5", floor = true) + @TestHolder(description = "Tests that cadmium slows nearby entities falling") + public static void cadmiumSlowsNearby(AllomancyTestHelper helper) { + var player = helper.makeMistbornPlayer(); + var data = player.getData(AllomancerAttachment.ALLOMANCY_DATA); + + data.setBurning(Metal.CADMIUM, true); + + var zombie = helper.spawnWithNoFreeWill(EntityType.ZOMBIE, new BlockPos(1, 1, 1)); + + helper.succeedOnTickWhen(1, () -> { + helper.assertMobEffectPresent(zombie, MobEffects.SLOW_FALLING, "Cadmium didn't grant slow fall"); + helper.assertMobEffectPresent(zombie, MobEffects.MOVEMENT_SLOWDOWN, "Cadmium didn't grant slow fall"); + }); + } + + @GameTest + @EmptyTemplate("1x3x1") + @TestHolder(description = "Tests that bendalloy grants haste") + public static void bendalloyGrantsHaste(AllomancyTestHelper helper) { + var player = helper.makeMistbornPlayer(); + var data = player.getData(AllomancerAttachment.ALLOMANCY_DATA); + + data.setBurning(Metal.BENDALLOY, true); + + helper.succeedOnTickWhen(1, () -> { + helper.assertMobEffectPresent(player, MobEffects.DIG_SPEED, "Bendalloy didn't grant haste"); + }); + } + + @GameTest + @EmptyTemplate(value = "5x3x5", floor = true) + @TestHolder(description = "Tests that bendalloy grants haste") + public static void bendalloyAndCadmiumCancel(AllomancyTestHelper helper) { + var player = helper.makeMistbornPlayer(); + var data = player.getData(AllomancerAttachment.ALLOMANCY_DATA); + + var zombie = helper.spawnWithNoFreeWill(EntityType.ZOMBIE, new BlockPos(1, 1, 1)); + + data.setBurning(Metal.BENDALLOY, true); + data.setBurning(Metal.CADMIUM, true); + helper.startSequence().thenIdle(10).thenExecute(() -> { + helper.assertMobEffectAbsent(player, MobEffects.DIG_SPEED, "Bendalloy still grant haste"); + helper.assertMobEffectAbsent(player, MobEffects.SLOW_FALLING, "Cadmium still grant slow fall"); + helper.assertMobEffectAbsent(zombie, MobEffects.SLOW_FALLING, "Cadmium still grant slow fall"); + helper.assertMobEffectAbsent(zombie, MobEffects.MOVEMENT_SLOWDOWN, "Cadmium still grant slow fall"); + }).thenSucceed(); + } + + @RegisterStructureTemplate(AllomancyTest.MODID + ":wheat") public static final StructureTemplate WHEAT = StructureTemplateBuilder .withSize(3, 5, 3)