Server authority
This commit is contained in:
+9
-5
@@ -2,14 +2,14 @@ import { Position } from "$/common/components/position.ts";
|
||||
import { Velocity } from "$/common/components/velocity.ts";
|
||||
import { Component, Entity } from "$/common/ecs/mod.ts";
|
||||
import { Camera } from "$/client/components/camera.ts";
|
||||
import { PlayerInventory } from "./inventory.ts";
|
||||
import { ClientInventories } from "./inventory.ts";
|
||||
import { PlayerControls } from "$/client/components/player_controls.ts";
|
||||
import { ClientWorld } from "./client_world.ts";
|
||||
import { GuiScreen } from "./gui/gui_screen.ts";
|
||||
import { CollisionCuboid } from "./components/collision.ts";
|
||||
|
||||
export class PlayerComponent extends Component {
|
||||
player_inventory = new PlayerInventory("");
|
||||
inventories = new ClientInventories();
|
||||
screens: GuiScreen[] = [];
|
||||
render_distance = 6;
|
||||
|
||||
@@ -27,12 +27,16 @@ export class PlayerComponent extends Component {
|
||||
|
||||
export function create_player(world: ClientWorld) {
|
||||
const player = new Entity("player");
|
||||
player.add(new Position(0, 100, 0));
|
||||
const spawn = world.connection.spawn;
|
||||
player.add(new Position(spawn.x, spawn.y, spawn.z));
|
||||
player.add(new Velocity(0, 0, 0));
|
||||
player.add(new PlayerControls());
|
||||
|
||||
player.add(new PlayerComponent());
|
||||
player.add(new Camera());
|
||||
const player_component = player.add(new PlayerComponent());
|
||||
player_component.inventories.hotbar_selected = world.connection.selected_slot;
|
||||
const camera = player.add(new Camera());
|
||||
camera.yaw = spawn.yaw;
|
||||
camera.pitch = spawn.pitch;
|
||||
player.add(new CollisionCuboid(0.55, 1.79, 0.55));
|
||||
|
||||
world.add_entity(player);
|
||||
|
||||
Reference in New Issue
Block a user