I am trying to update some code that adds reach distance to my mod and i have been stuck for hours trying to fix this issue. I have fixed it with other items in the mod by swapping the DamageSource to this.damageSources() but for some reason that will not work for this. It tells me it can not resolve the method. any help would be appreciated thanks.
CODE:
if (result == null || !(result.getEntity() instanceof LivingEntity target)) return false;
double distanceToTargetSqr = entity.distanceToSqr(target);
boolean hitResult = (result != null ? target : null) != null;
if (hitResult) {
if (entity instanceof Player) {
if (reachSqr >= distanceToTargetSqr) {
target.hurt(this.damageSources().playerAttack((Player) entity), getDamage());
}
}
}
//PROBLEM IS AT damageSources().playerAttack. (Also i know theres a way to insert code onto here but idk how to).