From d2a0ceb8074eff8e9762d6c0adb8070e7d9b1d2c Mon Sep 17 00:00:00 2001 From: WinDanesz <31292708+windanesz@users.noreply.github.com> Date: Fri, 5 Apr 2024 02:50:20 +0200 Subject: [PATCH] fix: The potency of Runeword spells now scales with spell blade tier --- .../entity/living/EntityEvilClassWizard.java | 38 +++++++++++++++++++ .../item/ItemBattlemageSword.java | 24 +++++------- .../item/ItemWarlockOrb.java | 4 -- 3 files changed, 48 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/windanesz/ancientspellcraft/entity/living/EntityEvilClassWizard.java b/src/main/java/com/windanesz/ancientspellcraft/entity/living/EntityEvilClassWizard.java index cbfa4363..430a13a5 100644 --- a/src/main/java/com/windanesz/ancientspellcraft/entity/living/EntityEvilClassWizard.java +++ b/src/main/java/com/windanesz/ancientspellcraft/entity/living/EntityEvilClassWizard.java @@ -22,8 +22,11 @@ import electroblob.wizardry.util.NBTExtras; import electroblob.wizardry.util.SpellModifiers; import electroblob.wizardry.util.WandHelper; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.IEntityLivingData; import net.minecraft.entity.ai.EntityAIWander; +import net.minecraft.init.SoundEvents; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -34,6 +37,7 @@ import net.minecraft.scoreboard.ScorePlayerTeam; import net.minecraft.util.EnumHand; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.MathHelper; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentTranslation; @@ -344,4 +348,38 @@ public void decrementShieldDisabledTick() { dataManager.set(SHIELD_DISABLED_TICK, (dataManager.get(SHIELD_DISABLED_TICK)) - 1); } + + @Override + protected void blockUsingShield(EntityLivingBase attacker) { + attacker.knockBack(this, 0.1F, posX - attacker.posX, posZ - attacker.posZ); + + if (attacker.getHeldItemMainhand().getItem().canDisableShield(attacker.getHeldItemMainhand(), getActiveItemStack(), this, attacker)) { + disableShield(); + } + } + + private void disableShield() { + float f = 1F + (float) EnchantmentHelper.getEfficiencyModifier(this) * 0.05F; + + if (rand.nextFloat() < f) { + setShieldDisabledTick(80); + resetActiveHand(); + world.setEntityState(this, (byte) 30); + } + } + + @Override + protected void damageShield(float damage) { + if (damage >= 3.0F && activeItemStack.getItem().isShield(activeItemStack, this)) { + int i = 1 + MathHelper.floor(damage); + getShieldStack().damageItem(i, this); + setActiveHand(EnumHand.OFF_HAND); + + if (getShieldStack().isEmpty()) { //shield breaks + setShieldStack(ItemStack.EMPTY); + playSound(SoundEvents.ITEM_SHIELD_BREAK, 0.8F, 0.8F + world.rand.nextFloat() * 0.4F); + } + } + } + } diff --git a/src/main/java/com/windanesz/ancientspellcraft/item/ItemBattlemageSword.java b/src/main/java/com/windanesz/ancientspellcraft/item/ItemBattlemageSword.java index 305eb1bb..6b36b721 100644 --- a/src/main/java/com/windanesz/ancientspellcraft/item/ItemBattlemageSword.java +++ b/src/main/java/com/windanesz/ancientspellcraft/item/ItemBattlemageSword.java @@ -9,6 +9,7 @@ import com.windanesz.ancientspellcraft.registry.ASItems; import com.windanesz.ancientspellcraft.registry.ASSpells; import com.windanesz.ancientspellcraft.registry.ASTabs; +import com.windanesz.ancientspellcraft.spell.IClassSpell; import com.windanesz.ancientspellcraft.spell.RunesmithingSpellBase; import com.windanesz.ancientspellcraft.spell.Runeword; import com.windanesz.ancientspellcraft.spell.RunewordFury; @@ -474,6 +475,10 @@ public void addInformation(ItemStack stack, World world, List text, net. } Spell spell = WandHelper.getCurrentSpell(stack); + // +0.5f is necessary due to the error in the way floats are calculated. + text.add(Wizardry.proxy.translate("item." + AncientSpellcraft.MODID + ":battlemage_sword.buff", + new Style().setColor(TextFormatting.DARK_GRAY), + (int) ((tier.level + 1) * (Constants.POTENCY_INCREASE_PER_TIER) * 100 + 0.5f))); boolean discovered = !Wizardry.settings.discoveryMode || player.isCreative() || WizardData.get(player) == null || WizardData.get(player).hasSpellBeenDiscovered(spell); @@ -1144,21 +1149,12 @@ public SpellModifiers calculateModifiers(ItemStack stack, EntityPlayer player, S modifiers.set(SpellModifiers.POTENCY, 1.0f + (this.tier.level + 1) * Constants.POTENCY_INCREASE_PER_TIER, true); // progressionModifier *= ELEMENTAL_PROGRESSION_MODIFIER; } - // - // if (WizardData.get(player) != null) { - // - // if (!WizardData.get(player).hasSpellBeenDiscovered(spell)) { - // // Casting an undiscovered spell now grants 5x progression - // progressionModifier *= DISCOVERY_PROGRESSION_MODIFIER; - // } - // - // if (!WizardData.get(player).hasReachedTier(this.tier.next())) { - // // 1.5x progression for tiers that have already been reached - // progressionModifier *= SECOND_TIME_PROGRESSION_MODIFIER; - // } - // } - // modifiers.set(SpellModifiers.PROGRESSION, progressionModifier, false); + if (spell instanceof IClassSpell && ((IClassSpell) spell).getArmourClass() == ItemWizardArmour.ArmourClass.BATTLEMAGE) { + modifiers.set(SpellModifiers.POTENCY, 1.0f + (this.tier.level + 1) * Constants.POTENCY_INCREASE_PER_TIER, true); + } else if (element != spell.getElement() && WandHelper.getUpgradeLevel(stack, ASItems.empowerment_upgrade) > 0) { + modifiers.set(SpellModifiers.POTENCY, 1.0f + WandHelper.getUpgradeLevel(stack, ASItems.empowerment_upgrade) * (float) Settings.generalSettings.empowerment_upgrade_potency_gain, true); + } return modifiers; } diff --git a/src/main/java/com/windanesz/ancientspellcraft/item/ItemWarlockOrb.java b/src/main/java/com/windanesz/ancientspellcraft/item/ItemWarlockOrb.java index 1018b598..3e335b18 100644 --- a/src/main/java/com/windanesz/ancientspellcraft/item/ItemWarlockOrb.java +++ b/src/main/java/com/windanesz/ancientspellcraft/item/ItemWarlockOrb.java @@ -201,10 +201,6 @@ public void addInformation(ItemStack stack, World world, List text, net. EntityPlayer player = net.minecraft.client.Minecraft.getMinecraft().player; if (player == null) { return; } - //text.add(Wizardry.proxy.translate("item.ancientspellcraft:battlemage_sword_armour_requirements_tooltip")); - - //Element element = WizardArmourUtils.getFullSetElementForClass(player, ItemWizardArmour.ArmourClass.BATTLEMAGE); - if (element != null && element != Element.MAGIC) { // +0.5f is necessary due to the error in the way floats are calculated. text.add(Wizardry.proxy.translate("item." + Wizardry.MODID + ":wand.buff",