Replaced broken reach check, continued work on movement check update

This commit is contained in:
Rammelkast committed 2020-06-13 14:49:35 +02:00
1 parent 636f94b408
commit 20635a2acb
15 files changed
+295 -203

No files matched your search

@@ -29,20 +29,37 @@ public class MovementManager {
public int groundTicks = 0;
// Ticks on ice
public int iceTicks = 0;
// Ticks on slime
public int slimeTicks = 0;
// Ticks in air before last grounded moment
public int airTicksBeforeGrounded = 0;
// Ticks influenced by ice
public int iceInfluenceTicks = 0;
// Ticks influenced by slime
public int slimeInfluenceTicks = 0;
// Ticks influenced by sign
public int signInfluenceTicks = 0;
// Last Y motion
public double motionY;
// If the player touched the ground again this tick
public boolean touchedGroundThisTick = false;
// Last recorded distance
public Distance lastDistance = new Distance();
// Movement acceleration
public double acceleration;
// Is the block above solid
public boolean topSolid;
// Is the block below solid
public boolean bottomSolid;
// If the current movement is up a slab or stair
public boolean halfMovement;
// Ticks counter for last halfMovement
public int halfMovementHistoryCounter = 0;
public void handle(Player player, Location from, Location to, Distance distance) {
boolean serverOnGround = !Utilities.cantStandAtExp(to) || Utilities.couldBeOnBoat(player);
this.touchedGroundThisTick = false;
this.halfMovement = false;
if (!serverOnGround) {
this.groundTicks = 0;
this.airTicks++;
@@ -53,21 +70,53 @@ public class MovementManager {
this.airTicks = 0;
this.groundTicks++;
}
if (to.getBlock().getType().name().endsWith("SIGN") || to.getBlock().getType().name().endsWith("POST")
|| from.getBlock().getType().name().endsWith("SIGN")
|| from.getBlock().getType().name().endsWith("POST"))
this.signInfluenceTicks = 3;
else
if (this.signInfluenceTicks > 0)
this.signInfluenceTicks--;
if (Utilities.couldBeOnIce(to)) {
this.iceTicks++;
this.iceInfluenceTicks = 14;
this.iceInfluenceTicks = 60;
} else {
this.iceTicks = 0;
if (this.iceInfluenceTicks > 0)
this.iceInfluenceTicks--;
}
if (Utilities.couldBeOnSlime(to)) {
this.slimeTicks++;
this.slimeInfluenceTicks = 40;
} else {
this.slimeTicks = 0;
if (this.slimeInfluenceTicks > 0)
this.slimeInfluenceTicks--;
}
double lastDistanceSq = Math.sqrt(this.lastDistance.getXDifference() * this.lastDistance.getXDifference()
+ this.lastDistance.getZDifference() * this.lastDistance.getZDifference());
double currentDistanceSq = Math.sqrt(distance.getXDifference() * distance.getXDifference()
+ distance.getZDifference() * distance.getZDifference());
this.acceleration = currentDistanceSq - lastDistanceSq;
this.motionY = to.getY() - from.getY();
Location top = to.clone().add(0, 2, 0);
this.topSolid = top.getBlock().getType().isSolid();
Location bottom = to.clone().add(0, -1, 0);
this.bottomSolid = bottom.getBlock().getType().isSolid();
if ((this.motionY > 0.464D && this.motionY <= 0.5625D) && (Utilities.couldBeOnHalfblock(to) || Utilities.isNearBed(to))) {
this.halfMovement = true;
this.halfMovementHistoryCounter = 30;
} else {
if (this.halfMovementHistoryCounter > 0)
this.halfMovementHistoryCounter--;
}
}
}