Add method for reset condition to PlayerLocation.

This commit is contained in:
asofold 2012-11-08 18:33:28 +01:00
parent fdd5bf3b58
commit b531091e7f
3 changed files with 13 additions and 4 deletions

View File

@ -99,9 +99,9 @@ public class NoFall extends Check {
// TODO: Distinguish water depth vs. fall distance! // TODO: Distinguish water depth vs. fall distance!
final boolean fromOnGround = from.isOnGround(); final boolean fromOnGround = from.isOnGround();
final boolean fromReset = from.isInLiquid() || from.isInWeb() || from.isOnLadder(); final boolean fromReset = from.isResetCond();
final boolean toOnGround = to.isOnGround(); final boolean toOnGround = to.isOnGround();
final boolean toReset = to.isInLiquid() || to.isInWeb() || to.isOnLadder(); final boolean toReset = to.isResetCond();
final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle(); final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();

View File

@ -122,7 +122,7 @@ public class SurvivalFly extends Check {
final boolean resetFrom; final boolean resetFrom;
// "Lost ground" workaround. // "Lost ground" workaround.
if (fromOnGround || from.isInLiquid() || from.isOnLadder() || from.isInWeb()) resetFrom = true; if (fromOnGround || from.isResetCond()) resetFrom = true;
else if (lostGround(player, mcPlayer, from, to, yDistance, data, cc)){ else if (lostGround(player, mcPlayer, from, to, yDistance, data, cc)){
resetFrom = true; resetFrom = true;
// TODO: Consider && !resetTo ? // TODO: Consider && !resetTo ?
@ -189,7 +189,7 @@ public class SurvivalFly extends Check {
} }
final boolean resetTo = toOnGround || to.isInLiquid() || to.isOnLadder() || to.isInWeb(); final boolean resetTo = toOnGround || to.isResetCond();
if (cc.survivalFlyAccountingH && !resetFrom && !resetTo) { if (cc.survivalFlyAccountingH && !resetFrom && !resetTo) {
// Currently only for "air" phases. // Currently only for "air" phases.

View File

@ -359,6 +359,15 @@ public class PlayerLocation {
return onGround; return onGround;
} }
/**
* Reset condition for flying checks (sf + nofall): fluids, web, ladder (not on-ground, though).
* @return
*/
public boolean isResetCond(){
// NOTE: if optimizing, setYOnGround has to be kept in mind.
return isInLiquid() || isOnLadder() || isInWeb();
}
public double getyOnGround() { public double getyOnGround() {
return yOnGround; return yOnGround;
} }