diff --git a/src/main/java/org/betterx/bclib/items/complex/EquipmentSet.java b/src/main/java/org/betterx/bclib/items/complex/EquipmentSet.java index a0872575..890ce64a 100644 --- a/src/main/java/org/betterx/bclib/items/complex/EquipmentSet.java +++ b/src/main/java/org/betterx/bclib/items/complex/EquipmentSet.java @@ -9,9 +9,79 @@ import net.minecraft.world.level.ItemLike; import java.util.HashMap; import java.util.Map; +import java.util.function.Function; import org.jetbrains.annotations.NotNull; public abstract class EquipmentSet { + public static class AttackDamage { + public static SetValues IRON_LEVEL = EquipmentSet.SetValues + .create() + .add(EquipmentSet.SWORD_SLOT, 3) + .add(EquipmentSet.AXE_SLOT, 6) + .add(EquipmentSet.SHOVEL_SLOT, 1.5f) + .add(EquipmentSet.PICKAXE_SLOT, 1) + .add(EquipmentSet.HOE_SLOT, -2); + + public static SetValues DIAMOND_LEVEL = EquipmentSet.SetValues + .create() + .add(EquipmentSet.SWORD_SLOT, 3) + .add(EquipmentSet.AXE_SLOT, 5) + .add(EquipmentSet.SHOVEL_SLOT, 1.5f) + .add(EquipmentSet.PICKAXE_SLOT, 1) + .add(EquipmentSet.HOE_SLOT, -3); + } + + public static class AttackSpeed { + public static SetValues IRON_LEVEL = EquipmentSet.SetValues + .create() + .add(EquipmentSet.SWORD_SLOT, -2.4f) + .add(EquipmentSet.AXE_SLOT, -3.1f) + .add(EquipmentSet.SHOVEL_SLOT, -3.0f) + .add(EquipmentSet.PICKAXE_SLOT, -2.8f) + .add(EquipmentSet.HOE_SLOT, -1.0f); + + public static SetValues DIAMOND_LEVEL = EquipmentSet.SetValues + .create() + .add(EquipmentSet.SWORD_SLOT, -2.4f) + .add(EquipmentSet.AXE_SLOT, -3.0f) + .add(EquipmentSet.SHOVEL_SLOT, -3.0f) + .add(EquipmentSet.PICKAXE_SLOT, -2.8f) + .add(EquipmentSet.HOE_SLOT, 0.0f); + } + + public interface ItemDescriptorCreator { + EquipmentDescription build(Item base, Function creator); + } + + public interface DescriptorCreator { + EquipmentDescription build(Function creator); + } + + public interface ItemCreator { + I build(Tier t, float attackDamage, float attackSpeed); + } + + public static class SetValues { + private final Map values; + + private SetValues() { + values = new HashMap<>(); + } + + public static SetValues create() { + return new SetValues(); + } + + public SetValues add(String slot, float value) { + values.put(slot, value); + return this; + } + + public float get(String slot) { + return values.getOrDefault(slot, 0.0f); + } + } + public final Tier material; public final String baseName; public final String modID; @@ -28,19 +98,52 @@ public abstract class EquipmentSet { public static final String LEGGINGS_SLOT = "leggings"; public static final String BOOTS_SLOT = "boots"; + public final SetValues attackDamage; + public final SetValues attackSpeed; + private final Map> descriptions = new HashMap<>(); - public EquipmentSet(Tier material, String modID, String baseName, ItemLike stick) { + public EquipmentSet( + Tier material, + String modID, + String baseName, + ItemLike stick, + SetValues attackDamage, + SetValues attackSpeed + ) { this.material = material; this.baseName = baseName; this.modID = modID; this.stick = stick; + this.attackDamage = attackDamage; + this.attackSpeed = attackSpeed; } protected void add(String slot, EquipmentDescription desc) { descriptions.put(slot, desc); } + protected void add( + String slot, + EquipmentSet baseSet, + ItemDescriptorCreator descriptor, + ItemCreator item + ) { + EquipmentDescription desc = descriptor.build( + baseSet.getSlot(slot), + (tier) -> item.build(tier, this.attackDamage.get(slot), this.attackSpeed.get(slot)) + ); + descriptions.put(slot, desc); + } + + protected void add(String slot, DescriptorCreator descriptor, ItemCreator item) { + EquipmentDescription desc = descriptor.build( + (tier) -> item.build(tier, this.attackDamage.get(slot), this.attackSpeed.get(slot)) + ); + descriptions.put(slot, desc); + } + + public EquipmentSet init(ItemRegistry itemsRegistry) { for (var desc : descriptions.entrySet()) { desc.getValue()