Trapdoors
This commit is contained in:
+1
-1
@@ -59,7 +59,7 @@ export class MultiPlayerGameMode {
|
||||
const level = this.client.level;
|
||||
// the server checks that the block isn't going inside the player with where it is now, like this does
|
||||
this.client.player.send_position_now();
|
||||
this.client.connection.send({ type: "use_block", x: hit.x, y: hit.y, z: hit.z, face: hit.face });
|
||||
this.client.connection.send({ type: "use_block", x: hit.x, y: hit.y, z: hit.z, face: hit.face, hit: hit.hit });
|
||||
|
||||
// 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
|
||||
|
||||
@@ -81,6 +81,8 @@ export interface BlockHitResult {
|
||||
z: number;
|
||||
block: number;
|
||||
face: Faces;
|
||||
// where the view went into the block, 0 to 1 on each axis
|
||||
hit: [number, number, number];
|
||||
}
|
||||
|
||||
const NEIGHBOR_OFFSETS = [[-1, 0], [1, 0], [0, -1], [0, 1]] as const;
|
||||
@@ -707,7 +709,10 @@ export class ClientLevel {
|
||||
: hit.axis === 1
|
||||
? (hit.sign > 0 ? "bottom" : "top")
|
||||
: (hit.sign > 0 ? "north" : "south");
|
||||
return { x: bx, y: by, z: bz, face, block };
|
||||
const at = [0, 1, 2].map((axis) =>
|
||||
Math.min(Math.max(origin[axis] + direction[axis] * hit.distance - [bx, by, bz][axis], 0), 1)
|
||||
);
|
||||
return { x: bx, y: by, z: bz, face, block, hit: [at[0], at[1], at[2]] };
|
||||
}
|
||||
|
||||
return undefined;
|
||||
|
||||
Reference in New Issue
Block a user