From b9ec1a46118435757f5004d4ea8909c4e6e8a226 Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Sun, 5 May 2024 20:25:19 +0200 Subject: [PATCH] Complete migration to vl_held_item --- mods/ENTITIES/vl_held_item/init.lua | 22 ++++++++++++---------- mods/ENTITIES/vl_held_item/mod.conf | 6 +++--- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/mods/ENTITIES/vl_held_item/init.lua b/mods/ENTITIES/vl_held_item/init.lua index b0ca52748..f64ad9928 100644 --- a/mods/ENTITIES/vl_held_item/init.lua +++ b/mods/ENTITIES/vl_held_item/init.lua @@ -1,38 +1,40 @@ local modname = minetest.get_current_modname() local modpath = minetest.get_modpath(modname) -vl_node_entity = {} -local mod = vl_node_entity +vl_held_item = {} +local mod = vl_held_item -local cube_node_entity = { +local held_item_entity = { initial_properties = { hp_max = 1, physical = true, pointable = false, collide_with_objects = true, + static_save = false, -- TODO remove/change later when needed to persist + -- WARNING persisting held items not recommended, mob can recreate it after_activate collision_box = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }, }, visual = "wielditem", textures = { "mcl_core:dirt_with_grass" }, } -function cube_node_entity:on_activate(staticdata, dtime_unloaded) +function held_item_entity:on_activate(staticdata, dtime_unloaded) local staticdata = minetest.deserialize(staticdata) self._staticdata = staticdata local props = { visual = "wielditem", - textures = { staticdata.nodename }, + textures = { staticdata.itemname }, } self.object:set_properties(props) end -function cube_node_entity:get_staticdata() +function held_item_entity:get_staticdata() return minetest.serialize(self._staticdata) end -minetest.register_entity("vl_node_entity:cube_node", cube_node_entity) +minetest.register_entity("vl_held_item:held_item_entity", held_item_entity) -function mod.create_node_entity(pos, nodename) +function mod.create_item_entity(pos, itemname) local staticdata = { - nodename = nodename + itemname = itemname } - return minetest.add_entity(pos, "vl_node_entity:cube_node",minetest.serialize(staticdata)) + return minetest.add_entity(pos, "vl_held_item:held_item_entity", minetest.serialize(staticdata)) end diff --git a/mods/ENTITIES/vl_held_item/mod.conf b/mods/ENTITIES/vl_held_item/mod.conf index 92c06b5de..c5068855f 100644 --- a/mods/ENTITIES/vl_held_item/mod.conf +++ b/mods/ENTITIES/vl_held_item/mod.conf @@ -1,4 +1,4 @@ -name = vl_node_entity -author = teknomunk -description = An entity that duplicates a registered node +name = vl_held_item +author = teknomunk, Herowl +description = An entity that represents an item held by a mob depends = mcl_core