diff --git a/src/main/java/com/legobmw99/allomancy/api/data/IAllomancerData.java b/src/main/java/com/legobmw99/allomancy/api/data/IAllomancerData.java index f2030ed3..ae2603a6 100644 --- a/src/main/java/com/legobmw99/allomancy/api/data/IAllomancerData.java +++ b/src/main/java/com/legobmw99/allomancy/api/data/IAllomancerData.java @@ -7,6 +7,11 @@ public interface IAllomancerData { + /** + * Maximum amount of metal that can be stored. + */ + int MAX_STORAGE = 10; + /** * Called each worldTick, checking the burn times, abilities, and metal * amounts. Then syncs to the client to make sure everyone is on the same diff --git a/src/main/java/com/legobmw99/allomancy/modules/consumables/item/VialItem.java b/src/main/java/com/legobmw99/allomancy/modules/consumables/item/VialItem.java index 7a7f39d8..aee76757 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/consumables/item/VialItem.java +++ b/src/main/java/com/legobmw99/allomancy/modules/consumables/item/VialItem.java @@ -1,11 +1,11 @@ package com.legobmw99.allomancy.modules.consumables.item; import com.legobmw99.allomancy.Allomancy; +import com.legobmw99.allomancy.api.data.IAllomancerData; import com.legobmw99.allomancy.api.enums.Metal; import com.legobmw99.allomancy.modules.consumables.ConsumeSetup; import com.legobmw99.allomancy.modules.consumables.item.component.FlakeStorage; import com.legobmw99.allomancy.modules.powers.data.AllomancerAttachment; -import com.legobmw99.allomancy.modules.powers.data.AllomancerData; import net.minecraft.core.component.DataComponents; import net.minecraft.nbt.CompoundTag; import net.minecraft.sounds.SoundEvents; @@ -52,7 +52,7 @@ public InteractionResult use(Level worldIn, Player playerIn, InteractionHand han for (Metal mt : Metal.values()) { if (storage.contains(mt)) { filling++; - if (data.getStored(mt) >= AllomancerData.MAX_STORAGE) { + if (data.getStored(mt) >= IAllomancerData.MAX_STORAGE) { full++; } } diff --git a/src/main/java/com/legobmw99/allomancy/modules/consumables/item/component/FlakeStorage.java b/src/main/java/com/legobmw99/allomancy/modules/consumables/item/component/FlakeStorage.java index db288db6..b81ab340 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/consumables/item/component/FlakeStorage.java +++ b/src/main/java/com/legobmw99/allomancy/modules/consumables/item/component/FlakeStorage.java @@ -1,8 +1,8 @@ package com.legobmw99.allomancy.modules.consumables.item.component; +import com.legobmw99.allomancy.api.data.IAllomancerData; import com.legobmw99.allomancy.api.enums.Metal; import com.legobmw99.allomancy.modules.powers.data.AllomancerAttachment; -import com.legobmw99.allomancy.modules.powers.data.AllomancerData; import com.legobmw99.allomancy.util.ItemDisplay; import com.mojang.serialization.Codec; import io.netty.buffer.ByteBuf; @@ -124,7 +124,7 @@ public void onConsume(Level level, LivingEntity entity, ItemStack stack, Consuma } var data = entity.getData(AllomancerAttachment.ALLOMANCY_DATA); if (stack.getItem() == Items.ENCHANTED_GOLDEN_APPLE && storage.contains(Metal.GOLD)) { - for (int i = 0; i < AllomancerData.MAX_STORAGE; i++) { + for (int i = 0; i < IAllomancerData.MAX_STORAGE; i++) { data.incrementStored(Metal.GOLD); } } diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/data/AllomancerData.java b/src/main/java/com/legobmw99/allomancy/modules/powers/data/AllomancerData.java index f782d7cb..15d06e83 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/data/AllomancerData.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/data/AllomancerData.java @@ -14,7 +14,6 @@ import java.util.Arrays; public class AllomancerData implements IAllomancerData, INBTSerializable { - public static final int MAX_STORAGE = 10; private static final int[] MAX_BURN_TIME = {1800, 1800, 3600, 600, 1800, 1800, 2400, 1600, 100, 20, 300, 40, 1000, 10000, 3600, 160}; private final boolean[] allomantic_powers; diff --git a/src/test/java/com/legobmw99/allomancy/test/modules/consumables/recipe/GrinderCraftingTest.java b/src/test/java/com/legobmw99/allomancy/test/modules/consumables/recipe/GrinderCraftingTest.java index bf130c41..e913decf 100644 --- a/src/test/java/com/legobmw99/allomancy/test/modules/consumables/recipe/GrinderCraftingTest.java +++ b/src/test/java/com/legobmw99/allomancy/test/modules/consumables/recipe/GrinderCraftingTest.java @@ -52,7 +52,8 @@ public static void register(Consumer add) { String structureName = AllomancyTest.MODID + ":crafter"; for (int i = 0; i < MaterialsSetup.METAL_ITEM_LEN; i++) { int I = i; - add.accept(new CallbackTest("crafting_" + getMetalName(i) + "_flakes", helper -> { + String metal = getMetalName(i); + add.accept(new CallbackTest("crafting_" + metal + "_flakes", helper -> { var ingot = getIngotItem(I); var flake = MaterialsSetup.FLAKES.get(I).get(); helper.succeedIfCrafts(barrel -> { @@ -61,7 +62,8 @@ public static void register(Consumer add) { var damagedGrinder = barrel.getItem(1).getDamageValue() == 1; return craftedFlake && retainedGrinder && damagedGrinder; }, () -> "Failed to craft flakes", ConsumeSetup.ALLOMANTIC_GRINDER, ingot); - }, structureName, "crafting")); + }, structureName, "crafting", "Tests that " + metal + + " flake crafting works and the grinder is maintained")); } } } diff --git a/src/test/java/com/legobmw99/allomancy/test/util/CallbackTest.java b/src/test/java/com/legobmw99/allomancy/test/util/CallbackTest.java index edfc2fb6..a4a2b41e 100644 --- a/src/test/java/com/legobmw99/allomancy/test/util/CallbackTest.java +++ b/src/test/java/com/legobmw99/allomancy/test/util/CallbackTest.java @@ -19,11 +19,13 @@ public class CallbackTest extends AbstractTest.Dynamic { public CallbackTest(String id, Consumer callback, String structureName, - @Nullable String group) { + @Nullable String group, + @Nullable String description) { this.callback = callback; this.id = id; - this.visuals = new Visuals(Component.literal(TestFrameworkImpl.capitaliseWords(id, "_")), List.of()); + this.visuals = new Visuals(Component.literal(TestFrameworkImpl.capitaliseWords(id, "_")), + description == null ? List.of() : List.of(Component.literal(description))); if (group != null) { this.groups.add(group); } @@ -32,7 +34,7 @@ public CallbackTest(String id, } CallbackTest(String id, Consumer callback, String structureName) { - this(id, callback, structureName, null); + this(id, callback, structureName, null, null); } @Override