com.magistuarmory.util.CombatHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of 1.20.2-epic-knights-common Show documentation
Show all versions of 1.20.2-epic-knights-common Show documentation
mod that adds medieval stuff to the game
package com.magistuarmory.util;
import com.magistuarmory.item.MedievalWeaponItem;
import com.magistuarmory.item.ModItemTier;
import com.magistuarmory.item.WeaponType;
import net.minecraft.class_1297;
import net.minecraft.class_1309;
import net.minecraft.class_1657;
public class CombatHelper
{
public static float getAttackReach(class_1657 player, MedievalWeaponItem weapon)
{
return weapon.getAttackReach(getBaseAttackReach(player));
}
public static float getBaseAttackReach(class_1657 player)
{
return player.method_7337() ? 5.0f : 4.5f;
}
public static float getBaseAttackDamage(ModItemTier material, WeaponType type)
{
return type.getBaseAttackDamage() + 1.6f * material.method_8028() / type.getAttackSpeed(material);
}
public static float getBaseAttackSpeed(ModItemTier material, WeaponType type)
{
return type.getAttackSpeed(material) - 4;
}
public static float getDecreasedAttackDamage(float baseattackdamage, WeaponType type)
{
return type.getTwoHanded() > 1 ? 14.0f * baseattackdamage / (3.0f * type.getTwoHanded() + 12.0f) : baseattackdamage;
}
public static float getDecreasedAttackSpeed(float baseattackspeed, WeaponType type)
{
return 14.0f * (baseattackspeed + 4.0f) / (5.0f * type.getTwoHanded() + 10.0f) - 4.0f;
}
public static float getSilverAttackDamage(ModItemTier material, WeaponType type)
{
return Math.round(6.0F / type.getAttackSpeed(material) * 100.0f) / 100.0f;
}
public static float getArmorPiercingFactor(class_1297 attacker)
{
float f = 1.0f;
if (attacker instanceof class_1309 livingentity)
{
if (livingentity.method_6047().method_7909() instanceof MedievalWeaponItem weapon)
{
float f2 = ((float) weapon.type.getArmorPiercing()) / 100.0f;
f = f2 / (1.0f - f2);
}
}
return f;
}
}