Buggy code:
public class KinematicCharacterMover implements CharacterMover { public static final float GRAVITY = 28.0F ; public static final float TERMINAL_VELOCITY = 64.0F ; private static final float HORIZONTAL_PENETRATION = 0.03F ; private static final float HORIZONTAL_PENETRATION_LEEWAY = 0.04F ; private static final float VERTICAL_PENETRATION = 0.04F ; private static final float VERTICAL_PENETRATION_LEEWAY = 0.05F ; private static final float CHECK_FORWARD_DIST = 0.05F ; private final Logger logger = LoggerFactory . getLogger ( KinematicCharacterMover . class ) ; private boolean stepped ; private float steppedUpDist ; private WorldProvider worldProvider ; private PhysicsEngine physics ; public KinematicCharacterMover ( WorldProvider wp , PhysicsEngine physicsEngine ) { } @ Override public CharacterStateEvent step ( CharacterStateEvent initial , CharacterMoveInputEvent input , EntityRef entity ) { } private float getMaxSpeed ( EntityRef character , CharacterMovementComponent characterMovement ) { } private void checkBlockEntry ( EntityRef entity , Vector3i oldPosition , Vector3i newPosition , float characterHeight ) { } private void checkMode ( final CharacterMovementComponent movementComp , final CharacterStateEvent state , final CharacterStateEvent oldState , EntityRef entity , boolean firstRun ) { if ( ! ( state . getMode ( ) . respondToEnvironment ) ) { return ; } Vector3f worldPos = state . getPosition ( ) ; Vector3f top = new Vector3f ( worldPos ) ; Vector3f bottom = new Vector3f ( worldPos ) ; top . y += 0.25F * ( movementComp . height ) ; bottom . y -= 0.25F * ( movementComp . height ) ; final boolean topUnderwater = worldProvider . getBlock ( top ) . isLiquid ( ) ; final boolean bottomUnderwater = worldProvider . getBlock ( bottom ) . isLiquid ( ) ; final boolean newSwimming = topUnderwater && bottomUnderwater ; boolean newClimbing = false ; if ( ! newSwimming ) { Vector3f [ ] sides = new Vector3f [ ] { new Vector3f ( worldPos ) , new Vector3f ( worldPos ) , new Vector3f ( worldPos ) , new Vector3f ( worldPos ) , new Vector3f ( worldPos ) } ; float factor = 1.0F ; sides [ 0 ] . x += factor * ( movementComp . radius ) ; sides [ 1 ] . x -= factor * ( movementComp . radius ) ; sides [ 2 ] . z += factor * ( movementComp . radius ) ; sides [ 3 ] . z -= factor * ( movementComp . radius ) ; sides [ 4 ] . y -= movementComp . height ; float distance = 100.0F ; for ( Vector3f side : sides ) { Block block = worldProvider . getBlock ( side ) ; if ( block . isClimbable ( ) ) { Vector3i myPos = new Vector3i ( worldPos , 0.5F ) ; Vector3i climbBlockPos = new Vector3i ( side , 0.5F ) ; <START_BUG> Vector3i dir = block . getDirection ( ) . getVector3i ( ) . clone ( ) ; <END_BUG> float currentDistance = 10.0F ; if ( ( ( dir . x ) != 0 ) && ( ( Math . abs ( ( ( ( worldPos . x ) - ( ( float ) ( climbBlockPos . x ) ) ) + ( ( ( float ) ( dir . x ) ) * 0.5F ) ) ) ) < ( ( movementComp . radius ) + 0.1F ) ) ) { newClimbing = true ; if ( ( myPos . x ) < ( climbBlockPos . x ) ) { dir . x = - ( dir . x ) ; } currentDistance = Math . abs ( ( ( climbBlockPos . z ) - ( worldPos . z ) ) ) ; } else if ( ( ( dir . z ) != 0 ) && ( ( Math . abs ( ( ( ( worldPos . z ) - ( ( float ) ( climbBlockPos . z ) ) ) + ( ( ( float ) ( dir . z ) ) * 0.5F ) ) ) ) < ( ( movementComp . radius ) + 0.1F ) ) ) { newClimbing = true ; if ( ( myPos . z ) < ( climbBlockPos . z ) ) { dir . z = - ( dir . z ) ; } currentDistance = Math . abs ( ( ( climbBlockPos . z ) - ( worldPos . z ) ) ) ; } if ( currentDistance < distance ) { distance = currentDistance ; state . setClimbDirection ( dir ) ; } } } } if ( newSwimming ) { if ( ( state . getMode ( ) ) != ( MovementMode . SWIMMING ) ) { state . setMode ( SWIMMING ) ; } } else if ( ( state . getMode ( ) ) == ( MovementMode . SWIMMING ) ) { if ( newClimbing ) { state . setMode ( CLIMBING ) ; state . getVelocity ( ) . y = 0 ; } else { if ( ( state . getVelocity ( ) . y ) > 0 ) { state . getVelocity ( ) . y += 8 ; } state . setMode ( WALKING ) ; } } else if ( newClimbing != ( ( state . getMode ( ) ) == ( MovementMode . CLIMBING ) ) ) { state . getVelocity ( ) . y = 0 ; state . setMode ( ( newClimbing ? MovementMode . CLIMBING : MovementMode . WALKING ) ) ; } } private boolean checkStep ( CharacterCollider collider , Vector3f position , Vector3f direction , SweepCallback callback , float slopeFactor , float stepHeight ) { } private Vector3f extractResidualMovement ( Vector3f hitNormal , Vector3f direction ) { } private Vector3f extractResidualMovement ( Vector3f hitNormal , Vector3f direction , float normalMag ) { } private void followToParent ( final CharacterStateEvent state , EntityRef entity ) { }

Fix:
Vector3i dir = new Vector3i ( block . getDirection ( ) . getVector3i ( ) ) ;