Skip to content

Commit

Permalink
Fix combat behaviour and damage to be in line with 1.9 #2004
Browse files Browse the repository at this point in the history
Adjust to Mojang fixing the 1 bonus damage swords had.
  • Loading branch information
bonii-xx committed Apr 8, 2016
1 parent 469dec9 commit 204de93
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -531,15 +531,14 @@ public static boolean attackEntity(ItemStack stack, ToolCore tool, EntityLivingB
}
}

// players base damage
// players base damage (includes tools damage stat)
float baseDamage = (float)attacker.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();

// missing because not supported by tcon tools: vanilla damage enchantments, we have our own modifiers
// missing because not supported by tcon tools: vanilla knockback enchantments, we have our own modifiers
float baseKnockback = attacker.isSprinting() ? 1 : 0;

// tool damage
baseDamage += ToolHelper.getAttackStat(stack);
baseDamage *= tool.damagePotential();

// calculate if it's a critical hit
Expand Down Expand Up @@ -577,6 +576,11 @@ public static boolean attackEntity(ItemStack stack, ToolCore tool, EntityLivingB
double oldVelY = target.motionY;
double oldVelZ = target.motionZ;

// apply cooldown damage decrease
if(player != null) {
float f2 = player.getCooledAttackStrength(0.5F);
damage *= (0.2F + f2 * f2 * 0.8F);
}

int hurtResistantTime = target.hurtResistantTime;
// deal the damage
Expand Down Expand Up @@ -666,6 +670,7 @@ public static boolean attackEntity(ItemStack stack, ToolCore tool, EntityLivingB
int k = (int)(damageDealt * 0.5);
((WorldServer)player.worldObj).spawnParticle(EnumParticleTypes.DAMAGE_INDICATOR, targetEntity.posX, targetEntity.posY + (double)(targetEntity.height * 0.5F), targetEntity.posZ, k, 0.1D, 0.0D, 0.1D, 0.2D);
}
player.resetCooldown();
}
else {
tool.reduceDurabilityOnHit(stack, null, damage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public boolean dealDamage(ItemStack stack, EntityLivingBase player, EntityLiving
public NBTTagCompound buildTag(List<Material> materials) {
ToolNBT data = buildDefaultTag(materials);
// 2 base damage, like vanilla swords
data.attack += 2f;
data.attack += 1f;
return data.get();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase
public NBTTagCompound buildTag(List<Material> materials) {
ToolNBT data = buildDefaultTag(materials);
// a bit less base damage, but it has better scaling
data.attack += 1f;
data.attack = Math.max(1f, data.attack);
return data.get();
}
}

0 comments on commit 204de93

Please sign in to comment.