Swimming
This commit is contained in:
+17
-1
@@ -1,4 +1,10 @@
|
||||
import { PLAYER_EYE_HEIGHT, PLAYER_HEIGHT, PLAYER_WIDTH } from "$/common/constants.ts";
|
||||
import {
|
||||
PLAYER_EYE_HEIGHT,
|
||||
PLAYER_HEIGHT,
|
||||
PLAYER_SWIM_EYE_HEIGHT,
|
||||
PLAYER_SWIM_HEIGHT,
|
||||
PLAYER_WIDTH,
|
||||
} from "$/common/constants.ts";
|
||||
import { EverythingRegistry, type ItemRegistry } from "$/common/everything_registry.ts";
|
||||
import { Container, Cursor, ItemData, ItemStack } from "$/common/inventory.ts";
|
||||
import type { GridRecipe } from "$/common/mod_data.ts";
|
||||
@@ -45,6 +51,8 @@ export class ServerPlayer extends LivingEntity {
|
||||
override width = PLAYER_WIDTH;
|
||||
override height = PLAYER_HEIGHT;
|
||||
override eye_height = PLAYER_EYE_HEIGHT;
|
||||
// lying flat in the short box, as their client says. their client decides, like where they are
|
||||
swimming = false;
|
||||
|
||||
inventory = new Container(INVENTORY_SIZE);
|
||||
// hunger and saturation, health is the entity's
|
||||
@@ -180,6 +188,13 @@ export class ServerPlayer extends LivingEntity {
|
||||
return this.inventory.get_item(this.selected_slot);
|
||||
}
|
||||
|
||||
// the short box and low eyes while swimming, so drowning, reach and what they're in the way of match
|
||||
set_swimming(swimming: boolean) {
|
||||
this.swimming = swimming;
|
||||
this.height = swimming ? PLAYER_SWIM_HEIGHT : PLAYER_HEIGHT;
|
||||
this.eye_height = swimming ? PLAYER_SWIM_EYE_HEIGHT : PLAYER_EYE_HEIGHT;
|
||||
}
|
||||
|
||||
player_info(): PlayerInfo {
|
||||
return {
|
||||
id: this.id,
|
||||
@@ -192,6 +207,7 @@ export class ServerPlayer extends LivingEntity {
|
||||
skin: this.skin,
|
||||
slim: this.slim || undefined,
|
||||
...(this.worn_list().length ? { worn: this.worn_list() } : {}),
|
||||
...(this.swimming && { swimming: true }),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user