Skip to content

Commit

Permalink
change wizard armour to not give potency, but reduced mana cost
Browse files Browse the repository at this point in the history
  • Loading branch information
CammiePone committed Jan 8, 2024
1 parent 222552d commit b060435
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class ArcanusEntityAttributes {
public static final RegistrySupplier<EntityAttribute> 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<EntityAttribute> 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<EntityAttribute> 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<EntityAttribute> 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<EntityAttribute> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class WizardArmorItem extends DyeableArmorItem {
);
private final Supplier<Multimap<EntityAttribute, EntityAttributeModifier>> 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(() -> {
Expand All @@ -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();
});

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ public class ArcanusItems {
public static final RegistrySupplier<Item> MAGIC_TOME = ITEMS.register("magic_tome", () -> new StaffItem(StaffType.BOOK, 0x8b4513, 0x1e1b1b, true));
public static final RegistrySupplier<Item> MAGE_PISTOL = ITEMS.register("mage_pistol", () -> new StaffItem(StaffType.GUN, 0xffffff, 0xffffff, true));

public static final RegistrySupplier<Item> WIZARD_HAT = ITEMS.register("wizard_hat", () -> new WizardArmorItem(ArcanusArmourMaterials.WIZARD, ArmorItem.ArmorSlot.HELMET, 1.5, 0.15, 0.2));
public static final RegistrySupplier<Item> WIZARD_ROBES = ITEMS.register("wizard_robes", () -> new WizardArmorItem(ArcanusArmourMaterials.WIZARD, ArmorItem.ArmorSlot.CHESTPLATE, 1.5, 0.15, 0.4));
public static final RegistrySupplier<Item> WIZARD_PANTS = ITEMS.register("wizard_pants", () -> new WizardArmorItem(ArcanusArmourMaterials.WIZARD, ArmorItem.ArmorSlot.LEGGINGS, 1.5, 0.15, 0.3));
public static final RegistrySupplier<Item> WIZARD_BOOTS = ITEMS.register("wizard_boots", () -> new WizardArmorItem(ArcanusArmourMaterials.WIZARD, ArmorItem.ArmorSlot.BOOTS, 1.5, 0.15, 0.1));
// public static final RegistrySupplier<Item> 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<Item> 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<Item> 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<Item> 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<Item> WIZARD_HAT = ITEMS.register("wizard_hat", () -> new WizardArmorItem(ArcanusArmourMaterials.WIZARD, ArmorItem.ArmorSlot.HELMET, 1.5, 0.15, 0, -0.1));
public static final RegistrySupplier<Item> WIZARD_ROBES = ITEMS.register("wizard_robes", () -> new WizardArmorItem(ArcanusArmourMaterials.WIZARD, ArmorItem.ArmorSlot.CHESTPLATE, 1.5, 0.15, 0, -0.2));
public static final RegistrySupplier<Item> WIZARD_PANTS = ITEMS.register("wizard_pants", () -> new WizardArmorItem(ArcanusArmourMaterials.WIZARD, ArmorItem.ArmorSlot.LEGGINGS, 1.5, 0.15, 0, -0.15));
public static final RegistrySupplier<Item> WIZARD_BOOTS = ITEMS.register("wizard_boots", () -> new WizardArmorItem(ArcanusArmourMaterials.WIZARD, ArmorItem.ArmorSlot.BOOTS, 1.5, 0.15, 0, -0.05));
// public static final RegistrySupplier<Item> 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<Item> 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<Item> 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<Item> 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<Item> BATTLE_MAGE_UPGRADE_SMITHING_TEMPLATE = ITEMS.register("battle_mage_upgrade_smithing_template", ArcanusItems::getBattleMageUpgrade);
public static final RegistrySupplier<Item> SPELL_BOOK = ITEMS.register("spell_book", SpellBookItem::new);
Expand Down
Original file line number Diff line number Diff line change
@@ -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<List<Text>> cir, List list, MutableText mutableText, int i, EquipmentSlot[] var6, int var7, int var8, EquipmentSlot equipmentSlot, Multimap multimap, Iterator var11, Map.Entry<EntityAttribute, EntityAttributeModifier> entry, @Share("entry") LocalRef<Map.Entry<EntityAttribute, EntityAttributeModifier>> 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<Map.Entry<EntityAttribute, EntityAttributeModifier>> ref) {
return ref.get().getKey() == ArcanusEntityAttributes.MANA_COST_MULT.get() ? (formatting == Formatting.BLUE ? Formatting.RED : Formatting.BLUE) : formatting;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/arcanuscontinuum.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"common.FallingBlockMixin",
"common.HungerManagerMixin",
"common.ItemEntityMixin",
"common.ItemStackMixin",
"common.LecternBlockEntityMixin",
"common.LivingEntityMixin",
"common.MilkBucketItemMixin",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/arcanuscontinuum/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit b060435

Please sign in to comment.