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.
This commit is contained in:
asofold 2012-11-15 20:51:31 +01:00
parent 34d6f2ff31
commit d6109bc150
4 changed files with 69 additions and 14 deletions

View File

@ -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 // 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). // 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)){ && !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. // 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 if (player.getFallDistance() < cc.criticalFallDistance

View File

@ -45,6 +45,8 @@ public class SurvivalFly extends Check {
public static final double swimmingSpeed = 0.11D; 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 webSpeed = 0.105D; // TODO: walkingSpeed * 0.15D; <- does not work
// public static final double climbSpeed = sprintingSpeed; // TODO.
public static final double modIce = 2.5D; public static final double modIce = 2.5D;
/** Faster moving down stream (water mainly). */ /** Faster moving down stream (water mainly). */
@ -248,8 +250,50 @@ public class SurvivalFly extends Check {
} }
if (vDistanceAboveLimit > 0) tags.add("vweb"); if (vDistanceAboveLimit > 0) tags.add("vweb");
} }
// else if (verticalFreedom <= 0.001 && from.isOnLadder) .... // else if (data.verticalFreedom <= 0.001 && from.isOnClimbable()){
// else if (verticalFreedom <= 0.001 (?) & from.isInFluid // // 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{ else{
// Check traveled y-distance, orientation is air + jumping + velocity (as far as it gets). // 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; vAllowedDistance = (!(fromOnGround || data.noFallAssumeGround) && !toOnGround ? 1.45D : 1.35D) + data.verticalFreedom;

View File

@ -269,6 +269,8 @@ public class BlockProperties {
* NOTE: This should later be ignored by passable, rather. * NOTE: This should later be ignored by passable, rather.
*/ */
public static final int F_HEIGHT100 = 0x100; 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{ static{
init(); init();
@ -361,6 +363,12 @@ public class BlockProperties {
}){ }){
blockFlags[mat.getId()] |= F_HEIGHT150; blockFlags[mat.getId()] |= F_HEIGHT150;
} }
// Climbable
for (final Material mat : new Material[]{
Material.VINE, Material.LADDER,
}){
blockFlags[mat.getId()] |= F_CLIMBABLE;
}
// Workarounds. // Workarounds.
for (final Material mat : new Material[]{ for (final Material mat : new Material[]{
Material.WATER_LILY, Material.LADDER, 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 box
* @param flags Block flags (@see fr.neatmonster.nocheatplus.utilities.BlockProperties). * @param flags Block flags (@see fr.neatmonster.nocheatplus.utilities.BlockProperties).
* @return If any block has the flags. * @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 minX
* @param minY * @param minY
* @param minZ * @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 minX
* @param minY * @param minY
* @param minZ * @param minZ

View File

@ -72,7 +72,7 @@ public class PlayerLocation {
private Boolean onIce; private Boolean onIce;
/** Is the player on ladder? */ /** Is the player on ladder? */
private Boolean onLadder; private Boolean onClimbable;
/** Simple test if the exact position is passable. */ /** Simple test if the exact position is passable. */
private Boolean passable; private Boolean passable;
@ -285,12 +285,15 @@ public class PlayerLocation {
* *
* @return If so. * @return If so.
*/ */
public boolean isOnLadder() { public boolean isOnClimbable() {
if (onLadder == null) { if (onClimbable == null) {
final int typeId = getTypeId(); // Climbable blocks.
onLadder = typeId == Material.LADDER.getId() || typeId == Material.VINE.getId(); 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(){ public boolean isResetCond(){
// NOTE: if optimizing, setYOnGround has to be kept in mind. // NOTE: if optimizing, setYOnGround has to be kept in mind.
return isInLiquid() || isOnLadder() || isInWeb(); return isInLiquid() || isOnClimbable() || isInWeb();
} }
public double getyOnGround() { public double getyOnGround() {
@ -516,7 +519,7 @@ public class PlayerLocation {
// Reset cached values. // Reset cached values.
typeId = typeIdBelow = data = null; 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 // TODO: Consider blockCache.setAccess? <- currently rather not, because
// it might be anything. // it might be anything.