From 0efd61af6d6de835ae4efc9bb755f0a89cd23220 Mon Sep 17 00:00:00 2001 From: copygirl Date: Fri, 20 Sep 2024 07:38:40 +0200 Subject: [PATCH] Let NodeCore fix non-canonical facedir itself With commit 24e2e7b7, NodeCore has changed its rotation API. It now automatically fixes "non-canonical" facedir values on node update, and `spindata` is no longer. --- init.lua | 7 ++----- state.lua | 2 -- utility.lua | 10 ---------- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/init.lua b/init.lua index 1fa2cec..a1137a9 100755 --- a/init.lua +++ b/init.lua @@ -9,11 +9,8 @@ nc_extended_rotating.entity = include("entity") -- Depends on `utility`. nc_extended_rotating.registry = include("registry") -- Depends on `rotate` and `state` (late). nc_extended_rotating.state = include("state") -- Depends on `registry`, `rotate` and `utility`. -do - -- Do a quick check if we're using a compatible version of NodeCore. - local lens_def = minetest.registered_nodes["nc_optics:lens"] - if not lens_def.spindata then error("Requires NodeCore 966ed012 or later") end -end +-- Do a quick check if we're using a compatible version of NodeCore. +if not nodecore.param2_canonical then error("Requires NodeCore 24e2e7b7 or later") end ------------------------------------- -- Register Player Update Function -- diff --git a/state.lua b/state.lua index 1f92ed7..53c1149 100755 --- a/state.lua +++ b/state.lua @@ -4,7 +4,6 @@ local math_round, minetest, vector local is_rightclick_filtered = nc_extended_rotating.registry.is_rightclick_filtered; local is_rotatable = nc_extended_rotating.registry.is_rotatable; local rotate_facedir = nc_extended_rotating.rotate.rotate_facedir; -local fix_rotatable_facedir = nc_extended_rotating.utility.fix_rotatable_facedir; local rotation_vector_from_lookat = nc_extended_rotating.utility.rotation_vector_from_lookat; -- Distance at which we want to rotate by "pushing" on an edge. @@ -66,7 +65,6 @@ local function calculate_rotating_state(player, data) state.invert = is_sneaking state.facedir = rotate_facedir(state.node.param2, state.axis, -degrees) - state.facedir = fix_rotatable_facedir(state.node, state.facedir) state.success = state.facedir and state.facedir ~= state.node.param2 -- TODO: Until we have a way to display "rotation non-success", don't show rotation hint at all. diff --git a/utility.lua b/utility.lua index a08f079..7ac5e13 100644 --- a/utility.lua +++ b/utility.lua @@ -44,14 +44,4 @@ function utility.rotation_vector_from_lookat(node, pointed_thing, edge_distance) return b - math_abs(p) <= edge_distance and math_sign(p) or 0 end) end --- NodeCore only has a couple of "canonical" orientations for its nodes. --- This returns a canonical facedir equivalent to the one passed in. -function utility.fix_rotatable_facedir(node, facedir) - local name = node and node.name or "" - local def = minetest.registered_nodes[name] - if not def then return nil end - if not def.spindata then return facedir end - return def.spindata.equiv[facedir] -end - return utility