[BLEEDING] Adjust the set-back y-coordinate to block bottom for some

cases.
This commit is contained in:
asofold 2013-03-09 03:53:51 +01:00
parent 8d9e2fdadc
commit 434a83c398

View File

@ -13,6 +13,7 @@ import fr.neatmonster.nocheatplus.checks.access.ACheckData;
import fr.neatmonster.nocheatplus.checks.access.CheckDataFactory; import fr.neatmonster.nocheatplus.checks.access.CheckDataFactory;
import fr.neatmonster.nocheatplus.checks.access.ICheckData; import fr.neatmonster.nocheatplus.checks.access.ICheckData;
import fr.neatmonster.nocheatplus.utilities.ActionAccumulator; import fr.neatmonster.nocheatplus.utilities.ActionAccumulator;
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
import fr.neatmonster.nocheatplus.utilities.PlayerLocation; import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
/* /*
@ -29,6 +30,8 @@ import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
* Player specific data for the moving checks. * Player specific data for the moving checks.
*/ */
public class MovingData extends ACheckData { public class MovingData extends ACheckData {
private static final long IGNORE_SETBACK_Y = BlockProperties.F_SOLID | BlockProperties.F_GROUND | BlockProperties.F_CLIMBABLE | BlockProperties.F_LIQUID;
/** The factory creating data. */ /** The factory creating data. */
public static final CheckDataFactory factory = new CheckDataFactory() { public static final CheckDataFactory factory = new CheckDataFactory() {
@ -281,7 +284,7 @@ public class MovingData extends ACheckData {
} }
/** /**
* Convenience method. * Set the set-back location, this will also adjust the y-coordinate for some block types (at least air).
* @param loc * @param loc
*/ */
public void setSetBack(final PlayerLocation loc){ public void setSetBack(final PlayerLocation loc){
@ -291,6 +294,23 @@ public class MovingData extends ACheckData {
else{ else{
LocUtil.set(setBack, loc); LocUtil.set(setBack, loc);
} }
final int id = loc.getTypeId();
if (id == 0){
// Shortcut.
}
else{
// Check some block flags.
// TODO: This might be a problem with workarounds [check which can be removed.].
final long flags = BlockProperties.getBlockFlags(id);
if ((flags & IGNORE_SETBACK_Y) != 0){
// Ignore these.
return;
}
else{
// Set set-back-y to block coordinate.
setBack.setY(loc.getBlockY());
}
}
} }
/** /**