From d6109bc15075a538e1a8335734c1370c594cc2b7 Mon Sep 17 00:00:00 2001 From: asofold Date: Thu, 15 Nov 2012 20:51:31 +0100 Subject: [PATCH] Renaming (isOnLadder -> isOnClimbable). Add commented out debug garbage about vertical speeds in water and on climbables. Adaptions take too long now, probably a different concept is needed, such as keeping track of phases within one medium. --- .../nocheatplus/checks/fight/Critical.java | 2 +- .../checks/moving/SurvivalFly.java | 48 ++++++++++++++++++- .../utilities/BlockProperties.java | 14 ++++-- .../nocheatplus/utilities/PlayerLocation.java | 19 ++++---- 4 files changed, 69 insertions(+), 14 deletions(-) diff --git a/src/fr/neatmonster/nocheatplus/checks/fight/Critical.java b/src/fr/neatmonster/nocheatplus/checks/fight/Critical.java index decc3d77..89cd5df2 100644 --- a/src/fr/neatmonster/nocheatplus/checks/fight/Critical.java +++ b/src/fr/neatmonster/nocheatplus/checks/fight/Critical.java @@ -54,7 +54,7 @@ public class Critical extends Check { // Check if the hit was a critical hit (positive fall distance, entity in the air, not on ladder, not in liquid // and without blindness effect). - if (player.getFallDistance() > 0f && !location.isOnGround() && !location.isOnLadder() && !location.isInLiquid() + if (player.getFallDistance() > 0f && !location.isOnGround() && !location.isOnClimbable() && !location.isInLiquid() && !player.hasPotionEffect(PotionEffectType.BLINDNESS)){ // It was a critical hit, now check if the player has jumped or has sent a packet to mislead the server. if (player.getFallDistance() < cc.criticalFallDistance diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java b/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java index 34e26b94..48f8d8a5 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java @@ -45,6 +45,8 @@ public class SurvivalFly extends Check { public static final double swimmingSpeed = 0.11D; public static final double webSpeed = 0.105D; // TODO: walkingSpeed * 0.15D; <- does not work +// public static final double climbSpeed = sprintingSpeed; // TODO. + public static final double modIce = 2.5D; /** Faster moving down stream (water mainly). */ @@ -248,8 +250,50 @@ public class SurvivalFly extends Check { } if (vDistanceAboveLimit > 0) tags.add("vweb"); } - // else if (verticalFreedom <= 0.001 && from.isOnLadder) .... - // else if (verticalFreedom <= 0.001 (?) & from.isInFluid +// else if (data.verticalFreedom <= 0.001 && from.isOnClimbable()){ +// // Ladder types. +// // TODO: make these extra checks to the jumpphase thing ? +// if (fromOnGround) vAllowedDistance = climbSpeed + 0.3; +// else vAllowedDistance = climbSpeed; +// vDistanceAboveLimit = Math.abs(yDistance) - vAllowedDistance; +// if (vDistanceAboveLimit > 0) tags.add("vclimb"); +// } +// else if (data.verticalFreedom <= 0.001 && from.isInLiquid()){ +// // Swimming... +// // TODO: This is more complex, depends on speed of diving into it. +// if (yDistance >= 0){ +// // TODO: This is more simple to test. +// if (!to.isInLiquid()){ +// vAllowedDistance = swimmingSpeed + 0.3; +// } +// else{ +// vAllowedDistance = swimmingSpeed; +// +// } +// vDistanceAboveLimit = yDistance - vAllowedDistance; +// if (vDistanceAboveLimit > 0) tags.add("swimup"); +// } +// else{ +// // TODO +// if (-yDistance > swimmingSpeed * modDownStream){ +// if (data.sfLastYDist != Double.MAX_VALUE && yDistance - swimmingSpeed <= data.sfLastYDist){ +// // Expect to get less as much as swimming speed (heuristic). +// vAllowedDistance = Math.abs(data.sfLastYDist) - swimmingSpeed; // Just for reference. +// vDistanceAboveLimit = -yDistance - swimmingSpeed; // TODO +// if (vDistanceAboveLimit > 0) tags.add("swimdown"); +// } +// else{ +// // Ignore. +// vDistanceAboveLimit = 0; +// vAllowedDistance = Math.abs(yDistance); +// } +// } else{ +// // Ignore. +// vDistanceAboveLimit = 0; +// vAllowedDistance = Math.abs(yDistance); +// } +// } +// } else{ // Check traveled y-distance, orientation is air + jumping + velocity (as far as it gets). vAllowedDistance = (!(fromOnGround || data.noFallAssumeGround) && !toOnGround ? 1.45D : 1.35D) + data.verticalFreedom; diff --git a/src/fr/neatmonster/nocheatplus/utilities/BlockProperties.java b/src/fr/neatmonster/nocheatplus/utilities/BlockProperties.java index 01c8225d..8d755a2e 100644 --- a/src/fr/neatmonster/nocheatplus/utilities/BlockProperties.java +++ b/src/fr/neatmonster/nocheatplus/utilities/BlockProperties.java @@ -269,6 +269,8 @@ public class BlockProperties { * NOTE: This should later be ignored by passable, rather. */ public static final int F_HEIGHT100 = 0x100; + /** Climbable like ladder and vine (allow to land on without taking damage). */ + public static final int F_CLIMBABLE = 0x200; static{ init(); @@ -361,6 +363,12 @@ public class BlockProperties { }){ blockFlags[mat.getId()] |= F_HEIGHT150; } + // Climbable + for (final Material mat : new Material[]{ + Material.VINE, Material.LADDER, + }){ + blockFlags[mat.getId()] |= F_CLIMBABLE; + } // Workarounds. for (final Material mat : new Material[]{ Material.WATER_LILY, Material.LADDER, @@ -1023,7 +1031,7 @@ public class BlockProperties { } /** - * + * Test if the bounding box overlaps with a block of given flags (does not check the blocks bounding box). * @param box * @param flags Block flags (@see fr.neatmonster.nocheatplus.utilities.BlockProperties). * @return If any block has the flags. @@ -1033,7 +1041,7 @@ public class BlockProperties { } /** - * + * Test if the bounding box overlaps with a block of given flags (does not check the blocks bounding box). * @param minX * @param minY * @param minZ @@ -1049,7 +1057,7 @@ public class BlockProperties { /** - * + * Test if the bounding box overlaps with a block of given flags (does not check the blocks bounding box). * @param minX * @param minY * @param minZ diff --git a/src/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java b/src/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java index 1bfcb2f4..3aab2506 100644 --- a/src/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java +++ b/src/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java @@ -72,7 +72,7 @@ public class PlayerLocation { private Boolean onIce; /** Is the player on ladder? */ - private Boolean onLadder; + private Boolean onClimbable; /** Simple test if the exact position is passable. */ private Boolean passable; @@ -285,12 +285,15 @@ public class PlayerLocation { * * @return If so. */ - public boolean isOnLadder() { - if (onLadder == null) { - final int typeId = getTypeId(); - onLadder = typeId == Material.LADDER.getId() || typeId == Material.VINE.getId(); + public boolean isOnClimbable() { + if (onClimbable == null) { + // Climbable blocks. + onClimbable = typeId == Material.LADDER.getId() || typeId == Material.VINE.getId(); + // TODO: maybe use specialized bounding box. +// final double d = 0.1d; +// onClimbable = BlockProperties.collides(getBlockAccess(), minX - d, minY - d, minZ - d, maxX + d, minY + 1.0, maxZ + d, BlockProperties.F_CLIMBABLE); } - return onLadder; + return onClimbable; } /** @@ -357,7 +360,7 @@ public class PlayerLocation { */ public boolean isResetCond(){ // NOTE: if optimizing, setYOnGround has to be kept in mind. - return isInLiquid() || isOnLadder() || isInWeb(); + return isInLiquid() || isOnClimbable() || isInWeb(); } public double getyOnGround() { @@ -516,7 +519,7 @@ public class PlayerLocation { // Reset cached values. typeId = typeIdBelow = data = null; - aboveStairs = inLava = inWater = inWeb = onGround = onIce = onLadder = passable = null; + aboveStairs = inLava = inWater = inWeb = onGround = onIce = onClimbable = passable = null; // TODO: Consider blockCache.setAccess? <- currently rather not, because // it might be anything.