Skip to content

Commit

Permalink
More clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
legobmw99 committed Jan 8, 2025
1 parent 87eb1bd commit 9e2ac61
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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++;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import java.util.Arrays;

public class AllomancerData implements IAllomancerData, INBTSerializable<CompoundTag> {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public static void register(Consumer<Test> 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 -> {
Expand All @@ -61,7 +62,8 @@ public static void register(Consumer<Test> 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"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ public class CallbackTest extends AbstractTest.Dynamic {
public CallbackTest(String id,
Consumer<AllomancyTestHelper> 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);
}
Expand All @@ -32,7 +34,7 @@ public CallbackTest(String id,
}

CallbackTest(String id, Consumer<AllomancyTestHelper> callback, String structureName) {
this(id, callback, structureName, null);
this(id, callback, structureName, null, null);
}

@Override
Expand Down

0 comments on commit 9e2ac61

Please sign in to comment.