Player api
This commit is contained in:
+9
-3
@@ -88,8 +88,13 @@ export class MultiPlayerGameMode {
|
||||
const held = this.held_item();
|
||||
const value = level.get_block_value(hit.x, hit.y, hit.z);
|
||||
const used = (held?.targets_liquids && liquid_block(value, block_info)) || block_info;
|
||||
const interaction = { face: hit.face, hit: hit.hit };
|
||||
if (block_rules.interact(used, hit.x, hit.y, hit.z, interaction, this.client.player.yaw)) return;
|
||||
// sneaking with an item skips the block, like on the server
|
||||
const sneaking = this.client.player.holding_sneak;
|
||||
const skips_block = sneaking && held !== undefined;
|
||||
const interaction = { face: hit.face, hit: hit.hit, sneaking };
|
||||
if (!skips_block && block_rules.interact(used, hit.x, hit.y, hit.z, interaction, this.client.player.yaw)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// guess that it places the held block, unless the block does something when used. the same rules as the server:
|
||||
// into the clicked block when it's replaceable, and only where place_in and place_on allow
|
||||
@@ -109,6 +114,7 @@ export class MultiPlayerGameMode {
|
||||
...target,
|
||||
face: hit.face,
|
||||
hit: hit.hit,
|
||||
sneaking,
|
||||
}),
|
||||
place_block,
|
||||
level.get_block_value(target.x, target.y, target.z),
|
||||
@@ -120,7 +126,7 @@ export class MultiPlayerGameMode {
|
||||
level.get_block_value(target.x, target.y, target.z),
|
||||
below_id,
|
||||
) && !(place_block?.has_collision && this.#occupied(target.x, target.y, target.z, place_block, place_value!));
|
||||
if (!block_info.interactive && place_id && placeable) {
|
||||
if ((!block_info.interactive || skips_block) && place_id && placeable) {
|
||||
level.add_block({ ...target, id: place_id }, place_value! >>> 16);
|
||||
predict_neighbors(target.x, target.y, target.z);
|
||||
const slot = this.#held_slot();
|
||||
|
||||
Reference in New Issue
Block a user