Skip to content

Commit 05373e9

Browse files
authored
fix(Movement): water super jump bug (#5252)
Changed KinematicCharacterMover so that water super jump bug is stopped. Closes #5198
1 parent 9b498fa commit 05373e9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

engine/src/main/java/org/terasology/engine/logic/characters/KinematicCharacterMover.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,13 @@ private void checkMode(final CharacterMovementComponent movementComp, final Char
162162
Vector3f top = new Vector3f(worldPos);
163163
Vector3f bottom = new Vector3f(worldPos);
164164
top.y += 0.5f * movementComp.height;
165-
bottom.y -= 0.5f * movementComp.height;
165+
bottom.y -= 0.25f * movementComp.height;
166166

167167
final boolean topUnderwater = worldProvider.getBlock(top).isLiquid();
168168
final boolean bottomUnderwater = worldProvider.getBlock(bottom).isLiquid();
169169

170-
final boolean newSwimming = !topUnderwater && bottomUnderwater;
170+
//We check if either a single point is in water (SWIMMING) or if both points are in water (DIVING).
171+
final boolean newSwimming = !topUnderwater && bottomUnderwater || topUnderwater && !bottomUnderwater;
171172
final boolean newDiving = topUnderwater && bottomUnderwater;
172173
boolean newClimbing = false;
173174

@@ -650,7 +651,7 @@ private void walk(final CharacterMovementComponent movementComp, final Character
650651
endVelocity.y = 0;
651652

652653
// Jumping is only possible, if the entity is standing on ground
653-
if (input.isJumping()) {
654+
if (input.isJumping() && state.isGrounded()) {
654655

655656
state.setGrounded(false);
656657

0 commit comments

Comments
 (0)