This commit is contained in:
asofold 2014-08-23 23:12:41 +02:00
parent 32a11f021a
commit e861b97538
4 changed files with 2907 additions and 2907 deletions

View File

@ -46,7 +46,7 @@ public class CreativeFly extends Check {
// If we have no setback, define one now. // If we have no setback, define one now.
if (!data.hasSetBack()) if (!data.hasSetBack())
data.setSetBack(from); data.setSetBack(from);
// Before doing anything, do a basic height check to determine if players are flying too high. // Before doing anything, do a basic height check to determine if players are flying too high.
final int maximumHeight = cc.creativeFlyMaxHeight + player.getWorld().getMaxHeight(); final int maximumHeight = cc.creativeFlyMaxHeight + player.getWorld().getMaxHeight();
@ -63,48 +63,48 @@ public class CreativeFly extends Check {
final double hDistance = Math.sqrt(xDistance * xDistance + zDistance * zDistance); final double hDistance = Math.sqrt(xDistance * xDistance + zDistance * zDistance);
// If the player is affected by potion of swiftness. // If the player is affected by potion of swiftness.
final double speedModifier = mcAccess.getFasterMovementAmplifier(player); final double speedModifier = mcAccess.getFasterMovementAmplifier(player);
double fSpeed; double fSpeed;
// TODO: Make this configurable ! [Speed effect should not affect flying if not on ground.] // TODO: Make this configurable ! [Speed effect should not affect flying if not on ground.]
if (speedModifier == Double.NEGATIVE_INFINITY) fSpeed = 1D; if (speedModifier == Double.NEGATIVE_INFINITY) fSpeed = 1D;
else fSpeed = 1D + 0.2D * (speedModifier + 1D); else fSpeed = 1D + 0.2D * (speedModifier + 1D);
if (player.isFlying()){ if (player.isFlying()){
fSpeed *= data.flySpeed / 0.1; fSpeed *= data.flySpeed / 0.1;
} }
else { else {
fSpeed *= data.walkSpeed / 0.2; fSpeed *= data.walkSpeed / 0.2;
} }
final double limitH = cc.creativeFlyHorizontalSpeed / 100D * HORIZONTAL_SPEED * fSpeed; final double limitH = cc.creativeFlyHorizontalSpeed / 100D * HORIZONTAL_SPEED * fSpeed;
// Finally, determine how far the player went beyond the set limits. // Finally, determine how far the player went beyond the set limits.
// double resultH = Math.max(0.0D, hDistance - data.horizontalFreedom - limitH); // double resultH = Math.max(0.0D, hDistance - data.horizontalFreedom - limitH);
double resultH = Math.max(0.0D, hDistance - limitH); double resultH = Math.max(0.0D, hDistance - limitH);
// Check velocity. // Check velocity.
if (resultH > 0){ if (resultH > 0){
double hFreedom = data.getHorizontalFreedom(); double hFreedom = data.getHorizontalFreedom();
if (hFreedom < resultH){ if (hFreedom < resultH){
// Use queued velocity if possible. // Use queued velocity if possible.
hFreedom += data.useHorizontalVelocity(resultH - hFreedom); hFreedom += data.useHorizontalVelocity(resultH - hFreedom);
} }
if (hFreedom > 0.0){ if (hFreedom > 0.0){
resultH = Math.max(0.0, resultH - hFreedom); resultH = Math.max(0.0, resultH - hFreedom);
} }
} }
else{ else{
data.clearActiveHVel(); // TODO: test/check ! data.clearActiveHVel(); // TODO: test/check !
} }
final boolean sprinting = time <= data.timeSprinting + cc.sprintingGrace; final boolean sprinting = time <= data.timeSprinting + cc.sprintingGrace;
data.bunnyhopDelay--; data.bunnyhopDelay--;
if (resultH > 0 && sprinting){ if (resultH > 0 && sprinting){
// TODO: Flying and bunnyhop ? <- 8 blocks per second - could be a case. // TODO: Flying and bunnyhop ? <- 8 blocks per second - could be a case.
// Try to treat it as a the "bunnyhop" problem. The bunnyhop problem is that landing and immediately jumping // Try to treat it as a the "bunnyhop" problem. The bunnyhop problem is that landing and immediately jumping
// again leads to a player moving almost twice as far in that step. // again leads to a player moving almost twice as far in that step.
if (data.bunnyhopDelay <= 0 && resultH < 0.4D) { if (data.bunnyhopDelay <= 0 && resultH < 0.4D) {
@ -125,7 +125,7 @@ public class CreativeFly extends Check {
// The player went to far, either horizontal or vertical. // The player went to far, either horizontal or vertical.
if (result > 0D) { if (result > 0D) {
// TODO: Get rid of creativeFlyPreviousRefused. // TODO: Get rid of creativeFlyPreviousRefused.
if (data.creativeFlyPreviousRefused) { if (data.creativeFlyPreviousRefused) {
// Increment violation level. // Increment violation level.
data.creativeFlyVL += result; data.creativeFlyVL += result;