This commit is contained in:
2026-11-22 13:21:27 -03:00
parent e751d22c6e
commit ac791b886e
23 changed files with 494 additions and 91 deletions
+10 -2
View File
@@ -196,20 +196,28 @@ export class MultiPlayerGameMode {
this.client.player.last_attack = performance.now();
}
// right click on an entity or another player, for mods' entity_interact. the server uses the held item when none
// of them stops it
interact(entity: Entity) {
this.client.player.send_position_now();
this.client.connection.send({ type: "interact_entity", id: entity.id });
}
// right click on nothing
use_item() {
this.client.connection.send({ type: "use_item" });
}
// whether a mob's or player's collision box overlaps the block, the server doesn't let solid blocks go there. mobs
// are the mod entities that aren't scripted, players are this one and the others
// are the mod entities that aren't scripted or objects, players are this one and the others
#occupied(x: number, y: number, z: number, block: BlockRegistry, value: number) {
const shape = collision_shape_at(block, value);
for (const entity of this.client.level.entities.values()) {
const json = entity instanceof RemoteEntity
? EverythingRegistry.get<EntityJson>("entities", entity.type)
: undefined;
const blocks = entity instanceof Player || (json !== undefined && json.behavior !== "scripted");
const blocks = entity instanceof Player ||
(json !== undefined && json.behavior !== "scripted" && json.behavior !== "object");
if (blocks && box_overlaps_block(entity, x, y, z, shape)) return true;
}
return false;