Bunny fix and bumping the head into the ceiling, various adjustments.

* Don't x > 1.314 * x.
* Add height, eyeHeight, isHeadObstructed to PlayerLocation.
* lowjump detection: from is higher than to, test both locations.
* Remove bunny reset within lowjump detection (defeated flying bunny).
* Check isHeadObstructed directly in the bunnyHop method.

Issues remaining:
* Moderate acceleration ground to ground, after having landed (+1st).
* Possibly transitions between 2-high and other.
* More edge cases with slowness potion.
This commit is contained in:
asofold 2015-08-01 13:25:07 +02:00
parent bcd933948b
commit c5574b5978
2 changed files with 37 additions and 18 deletions

View File

@ -894,7 +894,7 @@ public class SurvivalFly extends Check {
// Detect low jumping.
// TODO: sfDirty: Account for actual velocity (demands consuming queued for dir-change(!))!
if (!data.sfNoLowJump && data.mediumLiftOff == MediumLiftOff.GROUND && !data.isVelocityJumpPhase()) {
final double setBackYDistance = to.getY() - data.getSetBackY();
final double setBackYDistance = from.getY() - data.getSetBackY();
if (setBackYDistance > 0.0) {
// Only count it if the player has actually been jumping (higher than setback).
final Player player = from.getPlayer();
@ -906,17 +906,9 @@ public class SurvivalFly extends Check {
}
if (setBackYDistance < estimate) {
// Low jump, further check if there might have been a reason for low jumping.
// TODO: Might provide access methods in PlayerLoction instead.
final double width = Math.round(from.getWidth() * 500.0) / 1000.0;
final double eyeHeight = player.getEyeHeight();
final long aboveFlags = BlockProperties.collectFlagsSimple(from.getBlockCache(), from.getX() - width, from.getY() + eyeHeight, from.getZ() - width, from.getX() + width, from.getY() + eyeHeight + 0.25, from.getZ() + width);
if ((aboveFlags & (BlockProperties.F_GROUND | BlockProperties.F_SOLID)) == 0) {
if (!from.isHeadObstructed(0.25) && !to.isHeadObstructed(0.25)) {
tags.add("lowjump");
data.sfLowJump = true;
} else if (setBackYDistance < 0.36) {
// TODO: "Exact" parameters.
data.bunnyhopDelay = 0;
tags.add("resetbunny_lowjump");
}
}
}
@ -1033,9 +1025,10 @@ public class SurvivalFly extends Check {
}
}
// Not sure :p.
if (data.bunnyhopDelay <= 6 && (from.isOnGround() || data.noFallAssumeGround)) {
// TODO: Effectively reduces the delay (...).
// Allow hop for special cases.
if (!allowHop && !data.sfLowJump && (from.isOnGround() || data.noFallAssumeGround) &&
(data.bunnyhopDelay <= 6 || from.isHeadObstructed(0.25) || to.isHeadObstructed(0.25))) {
// TODO: headObstructed: check always and set a flag in data + consider regain buffer?
tags.add("ediblebunny");
allowHop = true;
}
@ -1085,7 +1078,7 @@ public class SurvivalFly extends Check {
// Check hop (singular peak up to roughly two times the allowed distance).
if (allowHop && hDistance >= walkSpeed &&
hDistance > 1.314 * hAllowedDistance && hDistance < 2.15 * hAllowedDistance ||
data.sfLastHDist != Double.MAX_VALUE && data.sfLastHDist > 1.314 * data.sfLastHDist && hDistance < 2.15 * data.sfLastHDist
data.sfLastHDist != Double.MAX_VALUE && hDistance > 1.314 * data.sfLastHDist && hDistance < 2.15 * data.sfLastHDist
) { // if (sprinting) {
// TODO: Test bunny spike over all sorts of speeds + attributes.
// TODO: Allow slightly higher speed on lost ground?

View File

@ -32,6 +32,10 @@ public class PlayerLocation {
private double width;
private double height;
private double eyeHeight;
/** Bounding box of the player. */
private double minX, maxX, minY, maxY, minZ, maxZ;
@ -179,6 +183,14 @@ public class PlayerLocation {
return width;
}
public double getHeight() {
return height;
}
public double getEyeHeight() {
return eyeHeight;
}
public int getBlockX() {
return blockX;
}
@ -413,7 +425,7 @@ public class PlayerLocation {
return true;
}
// Check the block at head height.
final int headY = Location.locToBlock(y + player.getEyeHeight());
final int headY = Location.locToBlock(y + eyeHeight);
if (headY > blockY) {
for (int cy = blockY + 1; cy <= headY; cy ++) {
if (BlockProperties.canClimbUp(blockCache, blockX, cy, blockZ)) {
@ -641,6 +653,18 @@ public class PlayerLocation {
return isInLiquid() || isOnClimbable() || isInWeb();
}
/**
* Test if something solid/ground-like collides within the given margin
* above the height of the player.
*
* @param marginAboveHeight
* @return
*/
public boolean isHeadObstructed(double marginAboveHeight) {
// TODO: Use collides instead (rather relevant with half slabs placed on the top side)?
return BlockProperties.hasAnyFlags(blockCache, x - width, y + eyeHeight, z - width, x + width, y + eyeHeight + marginAboveHeight, z + width, BlockProperties.F_GROUND | BlockProperties.F_SOLID);
}
/**
* Convenience method for testing for either.
* @return
@ -784,12 +808,14 @@ public class PlayerLocation {
// Set bounding box.
this.width = mcAccess.getWidth(player);
this.height = mcAccess.getHeight(player);
this.eyeHeight = player.getEyeHeight();
final double dxz = Math.round(this.width * 500.0) / 1000.0; // this.width / 2; // 0.3;
minX = x - dxz;
minY = y;
minZ = z - dxz;
maxX = x + dxz;
maxY = y + player.getEyeHeight();
maxY = y + eyeHeight;
maxZ = z + dxz;
// TODO: With current bounding box the stance is never checked.
@ -852,10 +878,10 @@ public class PlayerLocation {
}
/**
* Attempt to check for some exploits (!).
* Check absolute coordinates and stance for (typical) exploits.
*
* @return
* @deprecated Legacy method.
* @deprecated Not used anymore (hasIllegalCoords and hasIllegalStance are used individually instead).
*/
public boolean isIllegal() {
if (hasIllegalCoords()) {