From e0765da83943e10830c17b381253bb32760c6ca7 Mon Sep 17 00:00:00 2001 From: Alexander Weber Date: Sat, 5 Mar 2022 12:42:45 +0100 Subject: [PATCH] adjustments from code review --- API.md | 7 ++++--- init.lua | 7 +++++++ skin_meta_api.lua | 3 ++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/API.md b/API.md index 95fe031..830b30e 100644 --- a/API.md +++ b/API.md @@ -60,9 +60,10 @@ Set the hand node to be used with this skin ## skin:set_hand_from_texture() Register and set hand node based on skin texture +Only works on mod load -##skin:get_hand() -Get hand node +## skin:get_hand() +Get hand node. Returns ItemStack ## skin:set_preview(texture) Set the skin preview - usually at the init time only @@ -76,7 +77,7 @@ Could be redefined for dynamic preview texture generation Hook for dynamic skins updates on select. Is called in skins.set_player_skin() In skinsdb the default implementation for this function is empty. -skin:apply_skin_to_player(player) +## skin:apply_skin_to_player(player) Apply the skin to the player. Called in skins.update_player_skin() to update visuals ## skin:set_meta(key, value) diff --git a/init.lua b/init.lua index 202821b..718c7c3 100644 --- a/init.lua +++ b/init.lua @@ -93,3 +93,10 @@ if not default_skin_obj then default_skin_obj:set_meta("name", "Sam") default_skin_obj:set_hand_from_texture() end + +-- Secure hand inventory slot +minetest.register_allow_player_inventory_action(function(player, action, inv, data) + if data.to_list == "hand" or data.from_list == "hand" or data.listname == "hand" then + return 0 + end +end) diff --git a/skin_meta_api.lua b/skin_meta_api.lua index fd362a3..e9a4c7c 100644 --- a/skin_meta_api.lua +++ b/skin_meta_api.lua @@ -55,6 +55,7 @@ function skin_class:set_hand(hand) self._hand = hand end +local ALPHA_CLIP = minetest.features.use_texture_alpha_string_modes and "clip" or true function skin_class:set_hand_from_texture() local hand = core.get_current_modname()..':'..self._texture:gsub('[%p%c%s]', '') @@ -66,7 +67,7 @@ function skin_class:set_hand_from_texture() paramtype = "light", drawtype = "mesh", mesh = "skinsdb_hand.b3d", - use_texture_alpha = "clip", + use_texture_alpha = ALPHA_CLIP, node_placement_prediction = "", groups = { not_in_creative_inventory = 1 } })