Skip to content

Commit

Permalink
1.8 Players
Browse files Browse the repository at this point in the history
  • Loading branch information
Axionize committed Sep 25, 2024
1 parent ee6183d commit f724d6d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 24 deletions.
25 changes: 16 additions & 9 deletions src/main/java/ac/grim/grimac/player/GrimPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -572,15 +572,22 @@ public CompensatedInventory getInventory() {
}

public double[] getPossibleEyeHeights() { // We don't return sleeping eye height
switch (pose) {
case SWIMMING: // Swimming (includes crawling in 1.14+)
case FALL_FLYING: // Elytra gliding
case SPIN_ATTACK: // Riptide trident
return this.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9) ? possibleEyeHeights[2] : this.isSneaking ? possibleEyeHeights[1] : possibleEyeHeights[0];
case CROUCHING:
return possibleEyeHeights[1];
default:
return possibleEyeHeights[0];
// 1.8 Players once again ruin my clean switch-case
if (this.getClientVersion().isOlderThan(ClientVersion.V_1_9)) {
return this.isSneaking ? this.possibleEyeHeights[1] : this.possibleEyeHeights[0];
} else {
// 1.8 players just have their pose set to standing all the time
switch (pose) {
case FALL_FLYING: // Elytra gliding
case SPIN_ATTACK: // Riptide trident
case SWIMMING: // Swimming (includes crawling in 1.14+)
return this.possibleEyeHeights[2];
case NINE_CROUCHING:
case CROUCHING:
return this.possibleEyeHeights[1];
default:
return this.possibleEyeHeights[0];
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,23 @@ protected void initAttributes(GrimPlayer player) {
return getAttribute(Attributes.GENERIC_SCALE).get().getDefaultValue();
} else if ((newValue).equals(oldValue)) {
return oldValue;
} else {
// Elytra, standing, sneaking (1.14)
player.possibleEyeHeights[2][0] = 0.4 * newValue;
player.possibleEyeHeights[2][1] = 1.62 * newValue;
player.possibleEyeHeights[2][2] = 1.27 * newValue;

// sneaking (1.14), standing, Elytra
player.possibleEyeHeights[1][0] = 1.27 * newValue;
player.possibleEyeHeights[1][1] = 1.62 * newValue;
player.possibleEyeHeights[1][2] = 0.4 * newValue;

// standing, sneaking (1.14), Elytra
player.possibleEyeHeights[0][0] = 1.62 * newValue;
player.possibleEyeHeights[0][1] = 1.27 * newValue;
player.possibleEyeHeights[0][2] = 0.4 * newValue;
return newValue;
}
// Elytra, standing, sneaking (1.14)
player.possibleEyeHeights[2][0] = 0.4 * newValue;
player.possibleEyeHeights[2][1] = 1.62 * newValue;
player.possibleEyeHeights[2][2] = 1.27 * newValue;

// sneaking (1.14), standing, Elytra
player.possibleEyeHeights[1][0] = 1.27 * newValue;
player.possibleEyeHeights[1][1] = 1.62 * newValue;
player.possibleEyeHeights[1][2] = 0.4 * newValue;

// standing, sneaking (1.14), Elytra
player.possibleEyeHeights[0][0] = 1.62 * newValue;
player.possibleEyeHeights[0][1] = 1.27 * newValue;
player.possibleEyeHeights[0][2] = 0.4 * newValue;
return newValue;
});

final ValuedAttribute movementSpeed = ValuedAttribute.ranged(Attributes.GENERIC_MOVEMENT_SPEED, 0.1f, 0, 1024);
Expand Down

0 comments on commit f724d6d

Please sign in to comment.