From b4f9c5d8a6c8449b06d02a75f7f23c76f405d755 Mon Sep 17 00:00:00 2001 From: asofold Date: Wed, 23 Apr 2014 20:52:59 +0200 Subject: [PATCH] Apply yaw/pitch correction in fight-handling directly. Might later do without having this done after moving all the time. --- .../nocheatplus/checks/fight/FightListener.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/fight/FightListener.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/fight/FightListener.java index 6d3ae462..6c16e0d0 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/fight/FightListener.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/fight/FightListener.java @@ -2,6 +2,8 @@ package fr.neatmonster.nocheatplus.checks.fight; import java.util.Iterator; +import javax.management.MXBean; + import org.bukkit.Location; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Entity; @@ -29,6 +31,7 @@ import fr.neatmonster.nocheatplus.checks.combined.Improbable; 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; @@ -36,6 +39,7 @@ 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; @@ -111,6 +115,11 @@ public class FightListener extends CheckListener implements JoinLeaveListener{ 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; @@ -141,6 +150,12 @@ public class FightListener extends CheckListener implements JoinLeaveListener{ 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()); }