mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-12-29 04:37:31 +01:00
Complete migration to vl_held_item
This commit is contained in:
parent
25321a5ac7
commit
b9ec1a4611
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user