Make players mobs too !

This commit is contained in:
2026-09-30 10:42:52 -03:00
parent 65f27d6099
commit 4fbcca6851
23 changed files with 314 additions and 132 deletions
+3 -2
View File
@@ -8,6 +8,7 @@ import { box_overlaps_block, can_place, placement_target } from "$/common/utils.
import type { EntityJson } from "$/common/mod_data.ts";
import { RemoteEntity } from "./entity/remote_entity.ts";
import { Player } from "./entity/player.ts";
import type { Entity } from "./entity/entity.ts";
// breaking and using blocks against a server, like minecraft's MultiPlayerGameMode. the client times breaking
// and guesses the results so they feel instant, the server decides what really happens
@@ -95,8 +96,8 @@ export class MultiPlayerGameMode {
container.set_item(index, item.amount > 0 ? item : undefined);
}
// left click on an entity, the server decides whether it's hurt
attack(entity: RemoteEntity) {
// left click on an entity or another player, the server decides whether it's hurt
attack(entity: Entity) {
this.client.player.send_position_now();
this.client.connection.send({ type: "attack_entity", id: entity.id });
}