Change how targetting liquids work
This commit is contained in:
@@ -301,6 +301,7 @@ export class Client {
|
||||
player.yaw,
|
||||
player.pitch,
|
||||
picked?.distance ?? BLOCK_REACH,
|
||||
this.game_mode.held_item()?.targets_liquids,
|
||||
);
|
||||
this.entity_hit = picked && !this.hit_result ? picked.entity : undefined;
|
||||
}
|
||||
|
||||
+3
-3
@@ -34,7 +34,7 @@ export class MultiPlayerGameMode {
|
||||
// called every tick the attack button is held on a block
|
||||
continue_destroy_block(hit: BlockHitResult) {
|
||||
const block_info = EverythingRegistry.get_by_id<BlockRegistry>("blocks", hit.block)!;
|
||||
const tool = this.#held_item()?.tool;
|
||||
const tool = this.held_item()?.tool;
|
||||
|
||||
// looking at another block starts it over
|
||||
const pos = this.destroy_pos;
|
||||
@@ -75,7 +75,7 @@ export class MultiPlayerGameMode {
|
||||
const current = level.get_block(target.x, target.y, target.z);
|
||||
const below = level.get_block(target.x, target.y - 1, target.z);
|
||||
const below_id = EverythingRegistry.get_by_id<BlockRegistry>("blocks", below)?.id ?? AIR_ID;
|
||||
const held = this.#held_item();
|
||||
const held = this.held_item();
|
||||
// items with components might do something else on the server, like on_use
|
||||
const place_id = held?.components ? undefined : held?.block_id;
|
||||
const place_block = place_id !== undefined
|
||||
@@ -150,7 +150,7 @@ export class MultiPlayerGameMode {
|
||||
return inventories.inventory.get_slot(inventories.hotbar_selected);
|
||||
}
|
||||
|
||||
#held_item() {
|
||||
held_item() {
|
||||
return EverythingRegistry.get<ItemRegistry>("items", this.#held_slot().type_id ?? "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -665,7 +665,8 @@ export class ClientLevel {
|
||||
}
|
||||
|
||||
// the first block along the view of something at x/y/z looking at yaw/pitch, like minecraft's pick. it has to go
|
||||
// into one of the block's boxes (see common/block_shapes.ts), so it looks past the empty half of a slab
|
||||
// into one of the block's boxes (see common/block_shapes.ts), so it looks past the empty half of a slab. it looks
|
||||
// through liquids unless liquids is set, see ItemRegistry.targets_liquids
|
||||
pick(
|
||||
x: number,
|
||||
y: number,
|
||||
@@ -673,6 +674,7 @@ export class ClientLevel {
|
||||
yaw: number,
|
||||
pitch: number,
|
||||
max_distance = 6,
|
||||
liquids = false,
|
||||
step = 0.05,
|
||||
): BlockHitResult | undefined {
|
||||
const cos_pitch = Math.cos(pitch);
|
||||
@@ -702,6 +704,9 @@ export class ClientLevel {
|
||||
continue;
|
||||
}
|
||||
const info = this.#blocks[block];
|
||||
if (!liquids && is_liquid_block(info)) {
|
||||
continue;
|
||||
}
|
||||
const hit = clip_shape(
|
||||
info ? shape_at(info, value) : FULL_SHAPE,
|
||||
bx,
|
||||
|
||||
Reference in New Issue
Block a user