Death
This commit is contained in:
@@ -274,6 +274,7 @@ export class GameServer {
|
||||
);
|
||||
}
|
||||
},
|
||||
inside_blocks: (entity) => this.#inside_blocks(entity),
|
||||
entity_loot: (entity, source) => {
|
||||
const table = EverythingRegistry.get<EntityJson>("entities", entity.type)?.loot_table;
|
||||
if (!table) return [];
|
||||
@@ -1153,6 +1154,7 @@ export class GameServer {
|
||||
player.sneaking = message.sneaking === true;
|
||||
this.#broadcast(player_move(player), player);
|
||||
this.#update_view(player);
|
||||
this.#inside_blocks(player);
|
||||
break;
|
||||
}
|
||||
case "view_distance":
|
||||
@@ -2197,6 +2199,28 @@ export class GameServer {
|
||||
}
|
||||
}
|
||||
|
||||
// the components of every block an entity's box is in see it, after it moved. players move on their clients, so
|
||||
// theirs is after each move they send
|
||||
#inside_blocks(entity: Entity) {
|
||||
const { x, y, z } = entity;
|
||||
physics.blocks_inside(entity, (bx, by, bz) => {
|
||||
// a block before this one killed it, took it away or moved it somewhere else
|
||||
if (entity.removed || (entity instanceof LivingEntity && entity.dead)) return;
|
||||
if (entity.x !== x || entity.y !== y || entity.z !== z) return;
|
||||
const id = this.world.get_block_id(bx, by, bz);
|
||||
const components = this.mods.components_with(id, "on_entity_inside");
|
||||
if (components.length === 0) return;
|
||||
const block = this.mods.block_ref(bx, by, bz, id);
|
||||
for (const { mod, id: component_id, component, params } of components) {
|
||||
run_guarded(
|
||||
mod,
|
||||
`${component_id} on_entity_inside`,
|
||||
() => component.on_entity_inside!(block, params, entity_ref(entity)),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// feet on top of something solid, anywhere under the player's box: a thin box just under their feet touches a
|
||||
// block's collision shape. shapes, not whole blocks, so standing on a fence, a slab or a path counts too
|
||||
#on_ground(x: number, y: number, z: number) {
|
||||
|
||||
Reference in New Issue
Block a user