From 4025cd3e55dc7936b2845a80706c1a9e694830fb Mon Sep 17 00:00:00 2001 From: asofold Date: Mon, 8 Oct 2012 06:40:08 +0200 Subject: [PATCH] Use Location.locToBlock instead of Math.floor. --- .../checks/moving/SurvivalFly.java | 4 ++-- .../nocheatplus/utilities/PlayerLocation.java | 20 ++++--------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java b/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java index db395013..8adee862 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java @@ -123,7 +123,7 @@ public class SurvivalFly extends Check { // Maybe don't adapt the setback (unless null)! data.setBack = from.getLocation(); - data.setBack.setY(Math.floor(data.setBack.getY())); + data.setBack.setY(Location.locToBlock(data.setBack.getY())); // data.ground ? data.survivalFlyJumpPhase = 0; data.clearAccounting(); @@ -354,7 +354,7 @@ public class SurvivalFly extends Check { // data.setBack.setY(Math.ceil(data.setBack.getY())); // data.survivalFlyJumpPhase = 0; // data.clearAccounting(); -// } else if (resetTo && (from.getY() >= to.getY() || data.setBack.getY() <= Math.floor(to.getY()))) { +// } else if (resetTo && (from.getY() >= to.getY() || data.setBack.getY() <= Location.locToBlock(to.getY()))) { // // Set set back and jump phase, if: // // 1. Moving onto ladder/vine. // /* diff --git a/src/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java b/src/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java index 8bb14ae6..12c337e8 100644 --- a/src/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java +++ b/src/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java @@ -211,12 +211,9 @@ public class PlayerLocation { */ public boolean isInWeb() { if (inWeb == null) { - for (int blockX = (int) Math.floor(boundingBox.a + 0.001D); blockX <= (int) Math - .floor(boundingBox.d - 0.001D); blockX++) - for (int blockY = (int) Math.floor(boundingBox.b + 0.001D); blockY <= (int) Math - .floor(boundingBox.e - 0.001D); blockY++) - for (int blockZ = (int) Math.floor(boundingBox.c + 0.001D); blockZ <= (int) Math - .floor(boundingBox.f - 0.001D); blockZ++) + for (int blockX = Location.locToBlock(boundingBox.a + 0.001D); blockX <= Location.locToBlock(boundingBox.d - 0.001D); blockX++) + for (int blockY = Location.locToBlock(boundingBox.b + 0.001D); blockY <= Location.locToBlock(boundingBox.e - 0.001D); blockY++) + for (int blockZ = Location.locToBlock(boundingBox.c + 0.001D); blockZ <= Location.locToBlock(boundingBox.f - 0.001D); blockZ++) if (getTypeId(blockX, blockY, blockZ) == Material.WEB.getId()) inWeb = true; if (inWeb == null) @@ -236,15 +233,6 @@ public class PlayerLocation { boundingBoxGround = boundingBoxGround.d(0D, -getyOnGround(), 0D); onGround = worldServer.getCubes(entity, boundingBoxGround).size() > 0; } -// if (!onGround){ -// double y = this.getY() - this.blockY; -// // TODO: maybe make an auxiliary method in BlockProperties (can stand on ? id, boundY) -// if (y < 0) y += 1D; -// final int id = getTypeId(); -// final int idBelow = getTypeIdBelow(); -// if (y >= 0.5 && BlockProperties.isStairs(id)) onGround = true; -// else if (y <= 0.002 && BlockProperties.isStairs(idBelow)) onGround = true; -// } return onGround; } @@ -256,7 +244,7 @@ public class PlayerLocation { public boolean isOnIce() { if (onIce == null) if (entity.getBukkitEntity().isSneaking() || entity.getBukkitEntity().isBlocking()) - onIce = getTypeId(blockX, (int) Math.floor(boundingBox.b - 0.1D), blockZ) == Material.ICE.getId(); + onIce = getTypeId(blockX, Location.locToBlock(boundingBox.b - 0.1D), blockZ) == Material.ICE.getId(); else onIce = getTypeIdBelow() == Material.ICE.getId(); return onIce;