Skip to content

Commit

Permalink
fix: The potency of Runeword spells now scales with spell blade tier
Browse files Browse the repository at this point in the history
  • Loading branch information
WinDanesz committed Apr 5, 2024
1 parent 05762d4 commit d2a0ceb
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -474,6 +475,10 @@ public void addInformation(ItemStack stack, World world, List<String> 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);
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,6 @@ public void addInformation(ItemStack stack, World world, List<String> 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",
Expand Down

0 comments on commit d2a0ceb

Please sign in to comment.