From da606fa9d246642c39e0ed007b2c0d9fc63400b3 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 24 Feb 2021 12:58:30 +0100 Subject: [PATCH] Add 3d wielded nodes (not functional until Right_Hand bone is added) --- mods/ITEMS/mcl_tools/init.lua | 2 +- mods/ITEMS/mcl_tools/textures/wieldhand.png | Bin 170 -> 0 bytes mods/PLAYER/wieldview/init.lua | 42 ++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) delete mode 100644 mods/ITEMS/mcl_tools/textures/wieldhand.png diff --git a/mods/ITEMS/mcl_tools/init.lua b/mods/ITEMS/mcl_tools/init.lua index b022bacd8..d40b8e01b 100644 --- a/mods/ITEMS/mcl_tools/init.lua +++ b/mods/ITEMS/mcl_tools/init.lua @@ -49,7 +49,7 @@ minetest.register_item(":", { _doc_items_longdesc = S("You use your bare hand whenever you are not wielding any item. With your hand you can mine most blocks, but this is the slowest method and only the weakest blocks will yield their useful drop. The hand also deals minor damage by punching. Using the hand is often a last resort, as proper mining tools and weapons are much better.").."\n".. S("When you are wielding an item which is not a mining tool or a weapon, it will behave as if it were the hand when you start mining or punching.").."\n".. S("In Creative Mode, the hand is able to break all blocks instantly."), - wield_image = "wieldhand.png", + wield_image = "blank.png", wield_scale = {x=1.0,y=1.0,z=2.0}, -- According to Minecraft Wiki, the exact range is 3.975. -- Minetest seems to only support whole numbers, so we use 4. diff --git a/mods/ITEMS/mcl_tools/textures/wieldhand.png b/mods/ITEMS/mcl_tools/textures/wieldhand.png deleted file mode 100644 index 47d21f69016c56acc68fcdc7c6f590f6dafdca8f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 170 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|Y$ZW{!9W@a@|Lkr1XA&yE{-7; zjL8WJ60FOgUy*sC8xt?JUq!j5I{4bj$g3$`K+b>nSmBR`+j3TqPU z)8%9YuQ7!0+HNa;NMQ}*3!x$t2Ek0J2Rw`ZIJB{`C>c(%D$?W)V~A2Jh}1Vb6AH4@ M)78&qol`;+0NNEYegFUf diff --git a/mods/PLAYER/wieldview/init.lua b/mods/PLAYER/wieldview/init.lua index dab577fa8..2da5cea86 100644 --- a/mods/PLAYER/wieldview/init.lua +++ b/mods/PLAYER/wieldview/init.lua @@ -71,6 +71,9 @@ minetest.register_on_joinplayer(function(player) wieldview.wielded_item[name] = "" minetest.after(0, function(player) wieldview:update_wielded_item(player) + local itementity = minetest.add_entity(player:get_pos(), "wieldview:wieldnode") + itementity:set_attach(player, "Right_Hand", vector.new(0, 0, 0), vector.new(15, 45, 0)) + itementity:get_luaentity().wielder = name end, player) end) @@ -80,3 +83,42 @@ minetest.register_globalstep(function() end end) +minetest.register_entity("wieldview:wieldnode", { + initial_properties = { + hp_max = 1, + visual = "wielditem", + physical = false, + textures = {""}, + automatic_rotate = 1.5, + is_visible = true, + pointable = false, + collide_with_objects = false, + static_save = false, + collisionbox = {-0.21, -0.21, -0.21, 0.21, 0.21, 0.21}, + selectionbox = {-0.21, -0.21, -0.21, 0.21, 0.21, 0.21}, + visual_size = {x = 0.21, y = 0.21}, + }, + + itemstring = "", + + on_step = function(self) + local player = minetest.get_player_by_name(self.wielder) + if player then + local wielded = player:get_wielded_item() + local itemstring = wielded:to_string() + if self.itemstring ~= itemstring then + local itemname = wielded:get_name() + local def = minetest.registered_items[itemname] + self.object:set_properties({glow = def and def.light_source or 0}) + if armor.textures[self.wielder].wielditem == "blank.png" then + self.object:set_properties({textures = {itemname}, wield_item = itemstring}) + else + self.object:set_properties({textures = {""}, wield_item = ""}) + end + self.itemstring = itemstring + end + else + self.object:remove() + end + end, +})