Mechanical press !

This commit is contained in:
2026-10-15 13:07:09 -03:00
parent b43e8fe8b8
commit c7a2392591
15 changed files with 403 additions and 86 deletions
+9 -4
View File
@@ -30,11 +30,11 @@ export function setup(ctx: SharedContext) {
return kinetic_at(x + dx, y + dy, z + dz);
};
// the side of x y z with an axle pointing at it, like getPreferredFacing. undefined when there's none, or when
// axles point at it along two axes, since it can't line up with both
const axle_beside = (x: number, y: number, z: number): Face | undefined => {
// the side of x y z with an axle pointing at it, like getPreferredFacing, of the sides given. undefined when there's
// none, or when axles point at it along two axes, since it can't line up with both
const axle_beside = (x: number, y: number, z: number, sides = FACINGS): Face | undefined => {
let found: Face | undefined;
for (const side of FACINGS) {
for (const side of sides) {
if (!beside(x, y, z, side)?.shafts.includes(OPPOSITE[side])) continue;
if (found && face_axis(found) !== face_axis(side)) return undefined;
found = side;
@@ -73,6 +73,11 @@ export function setup(ctx: SharedContext) {
if (!cog_fits(placement.x, placement.y, placement.z, axis, params.cog)) return false;
return { [params.axis ?? "axis"]: AXES.indexOf(axis) };
}
// along an axle beside it, or else facing the player, like HorizontalKineticBlock and MechanicalPressBlock
if (params.facing !== undefined && params.horizontal) {
const side = axle_beside(placement.x, placement.y, placement.z, FACINGS.slice(0, 4));
return { [params.facing]: FACINGS.indexOf(side ?? OPPOSITE[placement.facing]) };
}
const side = axle_beside(placement.x, placement.y, placement.z);
if (params.facing !== undefined) {
const facing = side && !placement.sneaking