Use another special flag for ascension while gliding. Do/fix locking.

This commit is contained in:
asofold 2017-05-07 21:38:17 +02:00
parent 87374fe396
commit 9505c0747d
3 changed files with 24 additions and 6 deletions

View File

@ -259,16 +259,17 @@ public class MovingConfig extends ACheckConfig {
creativeFlyCheck = config.getBoolean(ConfPaths.MOVING_CREATIVEFLY_CHECK);
final ModelFlying defaultModel = new ModelFlying("gamemode.creative", config,
ConfPaths.MOVING_CREATIVEFLY_MODEL + "creative.", new ModelFlying());
ConfPaths.MOVING_CREATIVEFLY_MODEL + "creative.", new ModelFlying().lock());
for (final GameMode gameMode : GameMode.values()) {
flyingModelGameMode.put(gameMode, new ModelFlying("gamemode." + gameMode.name().toLowerCase(), config,
ConfPaths.MOVING_CREATIVEFLY_MODEL + (gameMode.name().toLowerCase()) + ".", defaultModel));
ConfPaths.MOVING_CREATIVEFLY_MODEL + (gameMode.name().toLowerCase()) + ".", defaultModel).lock());
}
flyingModelLevitation = new ModelFlying(ID_POTION_LEVITATION, config,
ConfPaths.MOVING_CREATIVEFLY_MODEL + "levitation.",
new ModelFlying(null, defaultModel).scaleLevitationEffect(true));
new ModelFlying(null, defaultModel).scaleLevitationEffect(true).lock());
flyingModelElytra = new ModelFlying(ID_JETPACK_ELYTRA, config,
ConfPaths.MOVING_CREATIVEFLY_MODEL + "elytra.", defaultModel);
ConfPaths.MOVING_CREATIVEFLY_MODEL + "elytra.",
new ModelFlying(null, defaultModel).verticalAscendGliding(true).lock());
creativeFlyActions = config.getOptimizedActionList(ConfPaths.MOVING_CREATIVEFLY_ACTIONS,
Permissions.MOVING_CREATIVEFLY);

View File

@ -44,6 +44,11 @@ public class ModelFlying {
private double horizontalModSprint = 1.92;
/** Modifier for vertical flying speed in per cent, for ascending. */
private double verticalAscendModSpeed = 100.0;
/**
* Apply special mechanics for allowing some vertical ascension with
* gliding.
*/
private boolean verticalAscendGliding = false;
/** Maximum flying height above the maximum building height of the map. */
private double maxHeight = 128;
/** Apply modifiers like sprint, flyspeed, walkspeed, potions. */
@ -93,6 +98,7 @@ public class ModelFlying {
horizontalModSpeed(config.getDouble(prefix + ConfPaths.SUB_HORIZONTAL_SPEED, defaults.getHorizontalModSpeed()));
horizontalModSprint(config.getDouble(prefix + ConfPaths.SUB_HORIZONTAL_MODSPRINT, defaults.getHorizontalModSprint()));
verticalAscendModSpeed(config.getDouble(prefix + ConfPaths.SUB_VERTICAL_ASCEND_SPEED, defaults.getVerticalAscendModSpeed()));
// TODO: verticalAscendGliding.
maxHeight(config.getDouble(prefix + ConfPaths.SUB_VERTICAL_MAXHEIGHT, defaults.getMaxHeight()));
applyModifiers(config.getBoolean(prefix + ConfPaths.SUB_MODIFIERS, defaults.getApplyModifiers()));
gravity(config.getBoolean(prefix + ConfPaths.SUB_VERTICAL_GRAVITY, defaults.getGravity()));
@ -112,6 +118,7 @@ public class ModelFlying {
horizontalModSpeed(defaults.getHorizontalModSpeed());
horizontalModSprint(defaults.getHorizontalModSprint());
verticalAscendModSpeed(defaults.getVerticalAscendModSpeed());
verticalAscendGliding(defaults.getVerticalAscendGliding());
maxHeight(defaults.getMaxHeight());
applyModifiers(defaults.getApplyModifiers());
gravity(defaults.getGravity());
@ -161,6 +168,10 @@ public class ModelFlying {
return verticalAscendModSpeed;
}
public boolean getVerticalAscendGliding() {
return verticalAscendGliding;
}
public double getMaxHeight() {
return maxHeight;
}
@ -188,8 +199,8 @@ public class ModelFlying {
}
public ModelFlying horizontalModSprint(double horizontalModSprint) {
this.horizontalModSprint = horizontalModSprint;
checkLocked();
this.horizontalModSprint = horizontalModSprint;
return this;
}
@ -199,6 +210,12 @@ public class ModelFlying {
return this;
}
public ModelFlying verticalAscendGliding(boolean verticalAscendGliding) {
checkLocked();
this.verticalAscendGliding = verticalAscendGliding;
return this;
}
public ModelFlying maxHeight(double maxHeight) {
checkLocked();
this.maxHeight = maxHeight;

View File

@ -375,7 +375,7 @@ public class CreativeFly extends Check {
}
// Related to elytra.
if (limitV == 0.0 && Bridge1_9.isGlidingWithElytra(from.getPlayer())) {
if (limitV == 0.0 && model.getVerticalAscendGliding()) {
// TODO: Better detection of an elytra model (extra flags?).
limitV = hackLytra(yDistance, limitV, thisMove, lastMove, data);
}