Skip to content

Commit

Permalink
Apply yaw/pitch correction in fight-handling directly.
Browse files Browse the repository at this point in the history
Might later do without having this done after moving all the time.
  • Loading branch information
asofold committed Apr 23, 2014
1 parent 146936b commit b4f9c5d
Showing 1 changed file with 15 additions and 0 deletions.
Expand Up @@ -2,6 +2,8 @@

import java.util.Iterator;

import javax.management.MXBean;

import org.bukkit.Location;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity;
Expand Down Expand Up @@ -29,13 +31,15 @@
import fr.neatmonster.nocheatplus.checks.inventory.Items;
import fr.neatmonster.nocheatplus.checks.moving.LocationTrace;
import fr.neatmonster.nocheatplus.checks.moving.LocationTrace.TraceEntry;
import fr.neatmonster.nocheatplus.checks.moving.LocUtil;
import fr.neatmonster.nocheatplus.checks.moving.MediumLiftOff;
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
import fr.neatmonster.nocheatplus.checks.moving.MovingListener;
import fr.neatmonster.nocheatplus.compat.BridgeHealth;
import fr.neatmonster.nocheatplus.components.JoinLeaveListener;
import fr.neatmonster.nocheatplus.permissions.Permissions;
import fr.neatmonster.nocheatplus.players.DataManager;
import fr.neatmonster.nocheatplus.utilities.TickTask;
import fr.neatmonster.nocheatplus.utilities.TrigUtil;
import fr.neatmonster.nocheatplus.utilities.build.BuildParameters;
Expand Down Expand Up @@ -111,6 +115,11 @@ private boolean handleNormalDamage(final Player player, final Entity damaged, fi
final boolean worldChanged = !worldName.equals(data.lastWorld);

final Location loc = player.getLocation(useLoc1);
// Bad pitch/yaw, just in case.
if (LocUtil.needsDirectionCorrection(useLoc1.getYaw(), useLoc1.getPitch())) {
mcAccess.correctDirection(player);
player.getLocation(useLoc1);
}
final Location damagedLoc = damaged.getLocation(useLoc2);
// final double targetDist = CheckUtils.distance(loc, targetLoc); // TODO: Calculate distance as is done in fight.reach !
final double targetMove;
Expand Down Expand Up @@ -141,6 +150,12 @@ private boolean handleNormalDamage(final Player player, final Entity damaged, fi
final Player damagedPlayer;
if (damaged instanceof Player){
damagedPlayer = (Player) damaged;
// Bad pitch/yaw, just in case.
if (LocUtil.needsDirectionCorrection(useLoc2.getYaw(), useLoc2.getPitch())) {
mcAccess.correctDirection(damagedPlayer);
damagedPlayer.getLocation(useLoc2);
}
// Log.
if (cc.debug && damagedPlayer.hasPermission(Permissions.ADMINISTRATION_DEBUG)){
damagedPlayer.sendMessage("Attacked by " + player.getName() + ": inv=" + mcAccess.getInvulnerableTicks(damagedPlayer) + " ndt=" + damagedPlayer.getNoDamageTicks());
}
Expand Down

0 comments on commit b4f9c5d

Please sign in to comment.