diff --git a/src/main/java/dev/cammiescorner/arcanuscontinuum/api/entities/ArcanusEntityAttributes.java b/src/main/java/dev/cammiescorner/arcanuscontinuum/api/entities/ArcanusEntityAttributes.java index 9b9fe056..99e5a1fc 100644 --- a/src/main/java/dev/cammiescorner/arcanuscontinuum/api/entities/ArcanusEntityAttributes.java +++ b/src/main/java/dev/cammiescorner/arcanuscontinuum/api/entities/ArcanusEntityAttributes.java @@ -21,6 +21,7 @@ public class ArcanusEntityAttributes { public static final RegistrySupplier BURNOUT_REGEN = ENTITY_ATTRIBUTES.register("burnout_regen", () -> new ClampedEntityAttribute(Arcanus.translationKey("attribute.name.generic", "burnout_regen"), 0.5D, 0D, 1024D).setTracked(true)); public static final RegistrySupplier MANA_LOCK = ENTITY_ATTRIBUTES.register("mana_lock", () -> new ClampedEntityAttribute(Arcanus.translationKey("attribute.name.generic", "mana_lock"), 0D, 0D, 1024D).setTracked(true)); public static final RegistrySupplier SPELL_POTENCY = ENTITY_ATTRIBUTES.register("spell_potency", () -> new ClampedEntityAttribute(Arcanus.translationKey("attribute.name.generic", "spell_potency"), 1D, 0D, 1024D).setTracked(true)); + public static final RegistrySupplier MANA_COST_MULT = ENTITY_ATTRIBUTES.register("mana_cost_multiplier", () -> new ClampedEntityAttribute(Arcanus.translationKey("attribute.name.generic", "mana_cost_multiplier"), 1D, 0D, 1024D).setTracked(true)); public static final RegistrySupplier MAGIC_RESISTANCE = ENTITY_ATTRIBUTES.register("magic_resistance", () -> new ClampedEntityAttribute(Arcanus.translationKey("attribute.name.generic", "magic_resistance"), 1D, 0D, 1024D).setTracked(true)); public static void registerAll(RegistryService registryService) { diff --git a/src/main/java/dev/cammiescorner/arcanuscontinuum/common/items/WizardArmorItem.java b/src/main/java/dev/cammiescorner/arcanuscontinuum/common/items/WizardArmorItem.java index ff97f275..4a0080a1 100644 --- a/src/main/java/dev/cammiescorner/arcanuscontinuum/common/items/WizardArmorItem.java +++ b/src/main/java/dev/cammiescorner/arcanuscontinuum/common/items/WizardArmorItem.java @@ -32,7 +32,7 @@ public class WizardArmorItem extends DyeableArmorItem { ); private final Supplier> attributeModifiers; - public WizardArmorItem(ArmorMaterial armorMaterial, ArmorSlot equipmentSlot, double manaRegen, double magicResist, double spellPotency) { + public WizardArmorItem(ArmorMaterial armorMaterial, ArmorSlot equipmentSlot, double manaRegen, double magicResist, double spellPotency, double manaCostMultiplier) { super(armorMaterial, equipmentSlot, new QuiltItemSettings().maxCount(1)); this.attributeModifiers = Suppliers.memoize(() -> { @@ -43,6 +43,7 @@ public WizardArmorItem(ArmorMaterial armorMaterial, ArmorSlot equipmentSlot, dou .put(ArcanusEntityAttributes.MANA_REGEN.get(), new EntityAttributeModifier(modifierID, "Armor modifier", manaRegen, EntityAttributeModifier.Operation.ADDITION)) .put(ArcanusEntityAttributes.MAGIC_RESISTANCE.get(), new EntityAttributeModifier(modifierID, "Armor modifier", magicResist, EntityAttributeModifier.Operation.MULTIPLY_BASE)) .put(ArcanusEntityAttributes.SPELL_POTENCY.get(), new EntityAttributeModifier(modifierID, "Armor modifier", spellPotency, EntityAttributeModifier.Operation.MULTIPLY_BASE)) + .put(ArcanusEntityAttributes.MANA_COST_MULT.get(), new EntityAttributeModifier(modifierID, "Armor modifier", manaCostMultiplier, EntityAttributeModifier.Operation.MULTIPLY_BASE)) .build(); }); diff --git a/src/main/java/dev/cammiescorner/arcanuscontinuum/common/packets/c2s/CastSpellPacket.java b/src/main/java/dev/cammiescorner/arcanuscontinuum/common/packets/c2s/CastSpellPacket.java index fcc24f17..e8a47f9c 100644 --- a/src/main/java/dev/cammiescorner/arcanuscontinuum/common/packets/c2s/CastSpellPacket.java +++ b/src/main/java/dev/cammiescorner/arcanuscontinuum/common/packets/c2s/CastSpellPacket.java @@ -1,6 +1,7 @@ package dev.cammiescorner.arcanuscontinuum.common.packets.c2s; import dev.cammiescorner.arcanuscontinuum.Arcanus; +import dev.cammiescorner.arcanuscontinuum.api.entities.ArcanusEntityAttributes; import dev.cammiescorner.arcanuscontinuum.api.spells.Spell; import dev.cammiescorner.arcanuscontinuum.api.spells.SpellComponent; import dev.cammiescorner.arcanuscontinuum.api.spells.SpellGroup; @@ -58,7 +59,7 @@ public static void handler(MinecraftServer server, ServerPlayerEntity player, Se return; } - if(!ArcanusComponents.drainMana(player, spell.getManaCost(), false)) { + if(!ArcanusComponents.drainMana(player, spell.getManaCost() * player.getAttributeValue(ArcanusEntityAttributes.MANA_COST_MULT.get()), false)) { player.sendMessage(Arcanus.translate("spell", "not_enough_mana").formatted(Formatting.RED, Formatting.ITALIC), true); return; } diff --git a/src/main/java/dev/cammiescorner/arcanuscontinuum/common/packets/c2s/SyncPatternPacket.java b/src/main/java/dev/cammiescorner/arcanuscontinuum/common/packets/c2s/SyncPatternPacket.java index 8bb042b1..d46053ca 100644 --- a/src/main/java/dev/cammiescorner/arcanuscontinuum/common/packets/c2s/SyncPatternPacket.java +++ b/src/main/java/dev/cammiescorner/arcanuscontinuum/common/packets/c2s/SyncPatternPacket.java @@ -1,6 +1,7 @@ package dev.cammiescorner.arcanuscontinuum.common.packets.c2s; import dev.cammiescorner.arcanuscontinuum.Arcanus; +import dev.cammiescorner.arcanuscontinuum.api.entities.ArcanusEntityAttributes; import dev.cammiescorner.arcanuscontinuum.api.spells.Pattern; import dev.cammiescorner.arcanuscontinuum.api.spells.Spell; import dev.cammiescorner.arcanuscontinuum.api.spells.SpellComponent; @@ -74,7 +75,7 @@ public static void handler(MinecraftServer server, ServerPlayerEntity player, Se return; } - if(!ArcanusComponents.drainMana(player, spell.getManaCost(), player.isCreative())) { + if(!ArcanusComponents.drainMana(player, spell.getManaCost() * player.getAttributeValue(ArcanusEntityAttributes.MANA_COST_MULT.get()), player.isCreative())) { player.sendMessage(Arcanus.translate("spell", "not_enough_mana"), true); return; } diff --git a/src/main/java/dev/cammiescorner/arcanuscontinuum/common/registry/ArcanusItems.java b/src/main/java/dev/cammiescorner/arcanuscontinuum/common/registry/ArcanusItems.java index f38ed864..e5b831ac 100644 --- a/src/main/java/dev/cammiescorner/arcanuscontinuum/common/registry/ArcanusItems.java +++ b/src/main/java/dev/cammiescorner/arcanuscontinuum/common/registry/ArcanusItems.java @@ -33,14 +33,14 @@ public class ArcanusItems { public static final RegistrySupplier MAGIC_TOME = ITEMS.register("magic_tome", () -> new StaffItem(StaffType.BOOK, 0x8b4513, 0x1e1b1b, true)); public static final RegistrySupplier MAGE_PISTOL = ITEMS.register("mage_pistol", () -> new StaffItem(StaffType.GUN, 0xffffff, 0xffffff, true)); - public static final RegistrySupplier WIZARD_HAT = ITEMS.register("wizard_hat", () -> new WizardArmorItem(ArcanusArmourMaterials.WIZARD, ArmorItem.ArmorSlot.HELMET, 1.5, 0.15, 0.2)); - public static final RegistrySupplier WIZARD_ROBES = ITEMS.register("wizard_robes", () -> new WizardArmorItem(ArcanusArmourMaterials.WIZARD, ArmorItem.ArmorSlot.CHESTPLATE, 1.5, 0.15, 0.4)); - public static final RegistrySupplier WIZARD_PANTS = ITEMS.register("wizard_pants", () -> new WizardArmorItem(ArcanusArmourMaterials.WIZARD, ArmorItem.ArmorSlot.LEGGINGS, 1.5, 0.15, 0.3)); - public static final RegistrySupplier WIZARD_BOOTS = ITEMS.register("wizard_boots", () -> new WizardArmorItem(ArcanusArmourMaterials.WIZARD, ArmorItem.ArmorSlot.BOOTS, 1.5, 0.15, 0.1)); -// public static final RegistrySupplier BATTLE_MAGE_HELMET = ITEMS.register("battle_mage_helmet", () -> new WizardArmorItem(ArcanusArmourMaterials.BATTLE_MAGE, ArmorItem.ArmorSlot.HELMET, 0.5, 0.1, 0.1)); -// public static final RegistrySupplier BATTLE_MAGE_CHESTPLATE = ITEMS.register("battle_mage_chestplate", () -> new WizardArmorItem(ArcanusArmourMaterials.BATTLE_MAGE, ArmorItem.ArmorSlot.CHESTPLATE, 0.5, 0.1, 0.2)); -// public static final RegistrySupplier BATTLE_MAGE_LEGGINGS = ITEMS.register("battle_mage_leggings", () -> new WizardArmorItem(ArcanusArmourMaterials.BATTLE_MAGE, ArmorItem.ArmorSlot.LEGGINGS, 0.5, 0.1, 0.15)); -// public static final RegistrySupplier BATTLE_MAGE_BOOTS = ITEMS.register("battle_mage_boots", () -> new WizardArmorItem(ArcanusArmourMaterials.BATTLE_MAGE, ArmorItem.ArmorSlot.BOOTS, 0.5, 0.1, 0.05)); + public static final RegistrySupplier WIZARD_HAT = ITEMS.register("wizard_hat", () -> new WizardArmorItem(ArcanusArmourMaterials.WIZARD, ArmorItem.ArmorSlot.HELMET, 1.5, 0.15, 0, -0.1)); + public static final RegistrySupplier WIZARD_ROBES = ITEMS.register("wizard_robes", () -> new WizardArmorItem(ArcanusArmourMaterials.WIZARD, ArmorItem.ArmorSlot.CHESTPLATE, 1.5, 0.15, 0, -0.2)); + public static final RegistrySupplier WIZARD_PANTS = ITEMS.register("wizard_pants", () -> new WizardArmorItem(ArcanusArmourMaterials.WIZARD, ArmorItem.ArmorSlot.LEGGINGS, 1.5, 0.15, 0, -0.15)); + public static final RegistrySupplier WIZARD_BOOTS = ITEMS.register("wizard_boots", () -> new WizardArmorItem(ArcanusArmourMaterials.WIZARD, ArmorItem.ArmorSlot.BOOTS, 1.5, 0.15, 0, -0.05)); +// public static final RegistrySupplier BATTLE_MAGE_HELMET = ITEMS.register("battle_mage_helmet", () -> new WizardArmorItem(ArcanusArmourMaterials.BATTLE_MAGE, ArmorItem.ArmorSlot.HELMET, 0.5, 0.1, 0.2, 0)); +// public static final RegistrySupplier BATTLE_MAGE_CHESTPLATE = ITEMS.register("battle_mage_chestplate", () -> new WizardArmorItem(ArcanusArmourMaterials.BATTLE_MAGE, ArmorItem.ArmorSlot.CHESTPLATE, 0.5, 0.1, 0.4, 0)); +// public static final RegistrySupplier BATTLE_MAGE_LEGGINGS = ITEMS.register("battle_mage_leggings", () -> new WizardArmorItem(ArcanusArmourMaterials.BATTLE_MAGE, ArmorItem.ArmorSlot.LEGGINGS, 0.5, 0.1, 0.3, 0)); +// public static final RegistrySupplier BATTLE_MAGE_BOOTS = ITEMS.register("battle_mage_boots", () -> new WizardArmorItem(ArcanusArmourMaterials.BATTLE_MAGE, ArmorItem.ArmorSlot.BOOTS, 0.5, 0.1, 0.1, 0)); // // public static final RegistrySupplier BATTLE_MAGE_UPGRADE_SMITHING_TEMPLATE = ITEMS.register("battle_mage_upgrade_smithing_template", ArcanusItems::getBattleMageUpgrade); public static final RegistrySupplier SPELL_BOOK = ITEMS.register("spell_book", SpellBookItem::new); diff --git a/src/main/java/dev/cammiescorner/arcanuscontinuum/mixin/common/ItemStackMixin.java b/src/main/java/dev/cammiescorner/arcanuscontinuum/mixin/common/ItemStackMixin.java new file mode 100644 index 00000000..9bbfd681 --- /dev/null +++ b/src/main/java/dev/cammiescorner/arcanuscontinuum/mixin/common/ItemStackMixin.java @@ -0,0 +1,45 @@ +package dev.cammiescorner.arcanuscontinuum.mixin.common; + +import com.google.common.collect.Multimap; +import com.llamalad7.mixinextras.sugar.Share; +import com.llamalad7.mixinextras.sugar.ref.LocalRef; +import dev.cammiescorner.arcanuscontinuum.api.entities.ArcanusEntityAttributes; +import net.minecraft.client.item.TooltipContext; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.attribute.EntityAttribute; +import net.minecraft.entity.attribute.EntityAttributeModifier; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.text.MutableText; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.Slice; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +@Mixin(ItemStack.class) +public abstract class ItemStackMixin { + @Inject(method = "getTooltip", at = @At(value = "INVOKE", + target = "Ljava/util/Map$Entry;getValue()Ljava/lang/Object;" + ), locals = LocalCapture.CAPTURE_FAILSOFT) + private void arcanuscontinuum$captureEntry(PlayerEntity player, TooltipContext context, CallbackInfoReturnable> cir, List list, MutableText mutableText, int i, EquipmentSlot[] var6, int var7, int var8, EquipmentSlot equipmentSlot, Multimap multimap, Iterator var11, Map.Entry entry, @Share("entry") LocalRef> ref) { + ref.set(entry); + } + + @ModifyArg(method = "getTooltip", slice = @Slice(from = @At(value = "FIELD", + target = "Lnet/minecraft/util/Formatting;BLUE:Lnet/minecraft/util/Formatting;" + )), at = @At(value = "INVOKE", + target = "Lnet/minecraft/text/MutableText;formatted(Lnet/minecraft/util/Formatting;)Lnet/minecraft/text/MutableText;" + )) + private Formatting arcanuscontinuum$switchColour(Formatting formatting, @Share("entry") LocalRef> ref) { + return ref.get().getKey() == ArcanusEntityAttributes.MANA_COST_MULT.get() ? (formatting == Formatting.BLUE ? Formatting.RED : Formatting.BLUE) : formatting; + } +} diff --git a/src/main/java/dev/cammiescorner/arcanuscontinuum/mixin/common/LivingEntityMixin.java b/src/main/java/dev/cammiescorner/arcanuscontinuum/mixin/common/LivingEntityMixin.java index 9efdb92a..d57bacef 100644 --- a/src/main/java/dev/cammiescorner/arcanuscontinuum/mixin/common/LivingEntityMixin.java +++ b/src/main/java/dev/cammiescorner/arcanuscontinuum/mixin/common/LivingEntityMixin.java @@ -214,7 +214,8 @@ public LivingEntityMixin(EntityType type, World world) { .add(ArcanusEntityAttributes.BURNOUT_REGEN.get()) .add(ArcanusEntityAttributes.MANA_LOCK.get()) .add(ArcanusEntityAttributes.SPELL_POTENCY.get()) - .add(ArcanusEntityAttributes.MAGIC_RESISTANCE.get()); + .add(ArcanusEntityAttributes.MAGIC_RESISTANCE.get()) + .add(ArcanusEntityAttributes.MANA_COST_MULT.get()); else return builder; } diff --git a/src/main/resources/arcanuscontinuum.mixins.json b/src/main/resources/arcanuscontinuum.mixins.json index 183631f7..19dd2162 100644 --- a/src/main/resources/arcanuscontinuum.mixins.json +++ b/src/main/resources/arcanuscontinuum.mixins.json @@ -12,6 +12,7 @@ "common.FallingBlockMixin", "common.HungerManagerMixin", "common.ItemEntityMixin", + "common.ItemStackMixin", "common.LecternBlockEntityMixin", "common.LivingEntityMixin", "common.MilkBucketItemMixin", diff --git a/src/main/resources/assets/arcanuscontinuum/lang/en_us.json b/src/main/resources/assets/arcanuscontinuum/lang/en_us.json index d98c1b04..4a6542ee 100644 --- a/src/main/resources/assets/arcanuscontinuum/lang/en_us.json +++ b/src/main/resources/assets/arcanuscontinuum/lang/en_us.json @@ -195,6 +195,7 @@ "attribute.name.generic.arcanuscontinuum.burnout_regen": "Burnout Regen", "attribute.name.generic.arcanuscontinuum.mana_lock": "Mana Lock", "attribute.name.generic.arcanuscontinuum.spell_potency": "Spell Potency", + "attribute.name.generic.arcanuscontinuum.mana_cost_multiplier": "Mana Cost", "attribute.name.generic.arcanuscontinuum.magic_resistance": "Magic Resistance", "config.arcanuscontinuum.spellShapesCategory": "Spell Shapes",