]> git.lizzy.rs Git - dragonfireclient.git/blob - builtin/game/item.lua
Fix default item callbacks to work with nil users (#5819)
[dragonfireclient.git] / builtin / game / item.lua
1 -- Minetest: builtin/item.lua
2
3 local builtin_shared = ...
4
5 local function copy_pointed_thing(pointed_thing)
6         return {
7                 type  = pointed_thing.type,
8                 above = vector.new(pointed_thing.above),
9                 under = vector.new(pointed_thing.under),
10                 ref   = pointed_thing.ref,
11         }
12 end
13
14 --
15 -- Item definition helpers
16 --
17
18 function core.inventorycube(img1, img2, img3)
19         img2 = img2 or img1
20         img3 = img3 or img1
21         return "[inventorycube"
22                         .. "{" .. img1:gsub("%^", "&")
23                         .. "{" .. img2:gsub("%^", "&")
24                         .. "{" .. img3:gsub("%^", "&")
25 end
26
27 function core.get_pointed_thing_position(pointed_thing, above)
28         if pointed_thing.type == "node" then
29                 if above then
30                         -- The position where a node would be placed
31                         return pointed_thing.above
32                 end
33                 -- The position where a node would be dug
34                 return pointed_thing.under
35         elseif pointed_thing.type == "object" then
36                 return pointed_thing.ref and pointed_thing.ref:getpos()
37         end
38 end
39
40 function core.dir_to_facedir(dir, is6d)
41         --account for y if requested
42         if is6d and math.abs(dir.y) > math.abs(dir.x) and math.abs(dir.y) > math.abs(dir.z) then
43
44                 --from above
45                 if dir.y < 0 then
46                         if math.abs(dir.x) > math.abs(dir.z) then
47                                 if dir.x < 0 then
48                                         return 19
49                                 else
50                                         return 13
51                                 end
52                         else
53                                 if dir.z < 0 then
54                                         return 10
55                                 else
56                                         return 4
57                                 end
58                         end
59
60                 --from below
61                 else
62                         if math.abs(dir.x) > math.abs(dir.z) then
63                                 if dir.x < 0 then
64                                         return 15
65                                 else
66                                         return 17
67                                 end
68                         else
69                                 if dir.z < 0 then
70                                         return 6
71                                 else
72                                         return 8
73                                 end
74                         end
75                 end
76
77         --otherwise, place horizontally
78         elseif math.abs(dir.x) > math.abs(dir.z) then
79                 if dir.x < 0 then
80                         return 3
81                 else
82                         return 1
83                 end
84         else
85                 if dir.z < 0 then
86                         return 2
87                 else
88                         return 0
89                 end
90         end
91 end
92
93 -- Table of possible dirs
94 local facedir_to_dir = {
95         {x= 0, y=0,  z= 1},
96         {x= 1, y=0,  z= 0},
97         {x= 0, y=0,  z=-1},
98         {x=-1, y=0,  z= 0},
99         {x= 0, y=-1, z= 0},
100         {x= 0, y=1,  z= 0},
101 }
102 -- Mapping from facedir value to index in facedir_to_dir.
103 local facedir_to_dir_map = {
104         [0]=1, 2, 3, 4,
105         5, 2, 6, 4,
106         6, 2, 5, 4,
107         1, 5, 3, 6,
108         1, 6, 3, 5,
109         1, 4, 3, 2,
110 }
111 function core.facedir_to_dir(facedir)
112         return facedir_to_dir[facedir_to_dir_map[facedir % 32]]
113 end
114
115 function core.dir_to_wallmounted(dir)
116         if math.abs(dir.y) > math.max(math.abs(dir.x), math.abs(dir.z)) then
117                 if dir.y < 0 then
118                         return 1
119                 else
120                         return 0
121                 end
122         elseif math.abs(dir.x) > math.abs(dir.z) then
123                 if dir.x < 0 then
124                         return 3
125                 else
126                         return 2
127                 end
128         else
129                 if dir.z < 0 then
130                         return 5
131                 else
132                         return 4
133                 end
134         end
135 end
136
137 -- table of dirs in wallmounted order
138 local wallmounted_to_dir = {
139         [0] = {x = 0, y = 1, z = 0},
140         {x =  0, y = -1, z =  0},
141         {x =  1, y =  0, z =  0},
142         {x = -1, y =  0, z =  0},
143         {x =  0, y =  0, z =  1},
144         {x =  0, y =  0, z = -1},
145 }
146 function core.wallmounted_to_dir(wallmounted)
147         return wallmounted_to_dir[wallmounted % 8]
148 end
149
150 function core.dir_to_yaw(dir)
151         return -math.atan2(dir.x, dir.z)
152 end
153
154 function core.yaw_to_dir(yaw)
155         return {x = -math.sin(yaw), y = 0, z = math.cos(yaw)}
156 end
157
158 function core.is_colored_paramtype(ptype)
159         return (ptype == "color") or (ptype == "colorfacedir") or
160                 (ptype == "colorwallmounted")
161 end
162
163 function core.strip_param2_color(param2, paramtype2)
164         if not core.is_colored_paramtype(paramtype2) then
165                 return nil
166         end
167         if paramtype2 == "colorfacedir" then
168                 param2 = math.floor(param2 / 32) * 32
169         elseif paramtype2 == "colorwallmounted" then
170                 param2 = math.floor(param2 / 8) * 8
171         end
172         -- paramtype2 == "color" requires no modification.
173         return param2
174 end
175
176 function core.get_node_drops(node, toolname)
177         -- Compatibility, if node is string
178         local nodename = node
179         local param2 = 0
180         -- New format, if node is table
181         if (type(node) == "table") then
182                 nodename = node.name
183                 param2 = node.param2
184         end
185         local def = core.registered_nodes[nodename]
186         local drop = def and def.drop
187         local ptype = def and def.paramtype2
188         -- get color, if there is color (otherwise nil)
189         local palette_index = core.strip_param2_color(param2, ptype)
190         if drop == nil then
191                 -- default drop
192                 if palette_index then
193                         local stack = ItemStack(nodename)
194                         stack:get_meta():set_int("palette_index", palette_index)
195                         return {stack:to_string()}
196                 end
197                 return {nodename}
198         elseif type(drop) == "string" then
199                 -- itemstring drop
200                 return {drop}
201         elseif drop.items == nil then
202                 -- drop = {} to disable default drop
203                 return {}
204         end
205
206         -- Extended drop table
207         local got_items = {}
208         local got_count = 0
209         local _, item, tool
210         for _, item in ipairs(drop.items) do
211                 local good_rarity = true
212                 local good_tool = true
213                 if item.rarity ~= nil then
214                         good_rarity = item.rarity < 1 or math.random(item.rarity) == 1
215                 end
216                 if item.tools ~= nil then
217                         good_tool = false
218                 end
219                 if item.tools ~= nil and toolname then
220                         for _, tool in ipairs(item.tools) do
221                                 if tool:sub(1, 1) == '~' then
222                                         good_tool = toolname:find(tool:sub(2)) ~= nil
223                                 else
224                                         good_tool = toolname == tool
225                                 end
226                                 if good_tool then
227                                         break
228                                 end
229                         end
230                 end
231                 if good_rarity and good_tool then
232                         got_count = got_count + 1
233                         for _, add_item in ipairs(item.items) do
234                                 -- add color, if necessary
235                                 if item.inherit_color and palette_index then
236                                         local stack = ItemStack(add_item)
237                                         stack:get_meta():set_int("palette_index", palette_index)
238                                         add_item = stack:to_string()
239                                 end
240                                 got_items[#got_items+1] = add_item
241                         end
242                         if drop.max_items ~= nil and got_count == drop.max_items then
243                                 break
244                         end
245                 end
246         end
247         return got_items
248 end
249
250 local function user_name(user)
251         return user and user:get_player_name() or ""
252 end
253
254 local function is_protected(pos, name)
255         return core.is_protected(pos, name) and
256                 not minetest.check_player_privs(name, "protection_bypass")
257 end
258
259 -- Returns a logging function. For empty names, does not log.
260 local function make_log(name)
261         return name ~= "" and core.log or function() end
262 end
263
264 function core.item_place_node(itemstack, placer, pointed_thing, param2)
265         local def = itemstack:get_definition()
266         if def.type ~= "node" or pointed_thing.type ~= "node" then
267                 return itemstack, false
268         end
269
270         local under = pointed_thing.under
271         local oldnode_under = core.get_node_or_nil(under)
272         local above = pointed_thing.above
273         local oldnode_above = core.get_node_or_nil(above)
274         local playername = user_name(placer)
275         local log = make_log(playername)
276
277         if not oldnode_under or not oldnode_above then
278                 log("info", playername .. " tried to place"
279                         .. " node in unloaded position " .. core.pos_to_string(above))
280                 return itemstack, false
281         end
282
283         local olddef_under = core.registered_nodes[oldnode_under.name]
284         olddef_under = olddef_under or core.nodedef_default
285         local olddef_above = core.registered_nodes[oldnode_above.name]
286         olddef_above = olddef_above or core.nodedef_default
287
288         if not olddef_above.buildable_to and not olddef_under.buildable_to then
289                 log("info", playername .. " tried to place"
290                         .. " node in invalid position " .. core.pos_to_string(above)
291                         .. ", replacing " .. oldnode_above.name)
292                 return itemstack, false
293         end
294
295         -- Place above pointed node
296         local place_to = {x = above.x, y = above.y, z = above.z}
297
298         -- If node under is buildable_to, place into it instead (eg. snow)
299         if olddef_under.buildable_to then
300                 log("info", "node under is buildable to")
301                 place_to = {x = under.x, y = under.y, z = under.z}
302         end
303
304         if is_protected(place_to, playername) then
305                 log("action", playername
306                                 .. " tried to place " .. def.name
307                                 .. " at protected position "
308                                 .. core.pos_to_string(place_to))
309                 core.record_protection_violation(place_to, playername)
310                 return itemstack
311         end
312
313         log("action", playername .. " places node "
314                 .. def.name .. " at " .. core.pos_to_string(place_to))
315
316         local oldnode = core.get_node(place_to)
317         local newnode = {name = def.name, param1 = 0, param2 = param2 or 0}
318
319         -- Calculate direction for wall mounted stuff like torches and signs
320         if def.place_param2 ~= nil then
321                 newnode.param2 = def.place_param2
322         elseif (def.paramtype2 == "wallmounted" or
323                         def.paramtype2 == "colorwallmounted") and not param2 then
324                 local dir = {
325                         x = under.x - above.x,
326                         y = under.y - above.y,
327                         z = under.z - above.z
328                 }
329                 newnode.param2 = core.dir_to_wallmounted(dir)
330         -- Calculate the direction for furnaces and chests and stuff
331         elseif (def.paramtype2 == "facedir" or
332                         def.paramtype2 == "colorfacedir") and not param2 then
333                 local placer_pos = placer and placer:getpos()
334                 if placer_pos then
335                         local dir = {
336                                 x = above.x - placer_pos.x,
337                                 y = above.y - placer_pos.y,
338                                 z = above.z - placer_pos.z
339                         }
340                         newnode.param2 = core.dir_to_facedir(dir)
341                         log("action", "facedir: " .. newnode.param2)
342                 end
343         end
344
345         local metatable = itemstack:get_meta():to_table().fields
346
347         -- Transfer color information
348         if metatable.palette_index and not def.place_param2 then
349                 local color_divisor = nil
350                 if def.paramtype2 == "color" then
351                         color_divisor = 1
352                 elseif def.paramtype2 == "colorwallmounted" then
353                         color_divisor = 8
354                 elseif def.paramtype2 == "colorfacedir" then
355                         color_divisor = 32
356                 end
357                 if color_divisor then
358                         local color = math.floor(metatable.palette_index / color_divisor)
359                         local other = newnode.param2 % color_divisor
360                         newnode.param2 = color * color_divisor + other
361                 end
362         end
363
364         -- Check if the node is attached and if it can be placed there
365         if core.get_item_group(def.name, "attached_node") ~= 0 and
366                 not builtin_shared.check_attached_node(place_to, newnode) then
367                 log("action", "attached node " .. def.name ..
368                         " can not be placed at " .. core.pos_to_string(place_to))
369                 return itemstack, false
370         end
371
372         -- Add node and update
373         core.add_node(place_to, newnode)
374
375         local take_item = true
376
377         -- Run callback
378         if def.after_place_node then
379                 -- Deepcopy place_to and pointed_thing because callback can modify it
380                 local place_to_copy = {x=place_to.x, y=place_to.y, z=place_to.z}
381                 local pointed_thing_copy = copy_pointed_thing(pointed_thing)
382                 if def.after_place_node(place_to_copy, placer, itemstack,
383                                 pointed_thing_copy) then
384                         take_item = false
385                 end
386         end
387
388         -- Run script hook
389         for _, callback in ipairs(core.registered_on_placenodes) do
390                 -- Deepcopy pos, node and pointed_thing because callback can modify them
391                 local place_to_copy = {x=place_to.x, y=place_to.y, z=place_to.z}
392                 local newnode_copy = {name=newnode.name, param1=newnode.param1, param2=newnode.param2}
393                 local oldnode_copy = {name=oldnode.name, param1=oldnode.param1, param2=oldnode.param2}
394                 local pointed_thing_copy = copy_pointed_thing(pointed_thing)
395                 if callback(place_to_copy, newnode_copy, placer, oldnode_copy, itemstack, pointed_thing_copy) then
396                         take_item = false
397                 end
398         end
399
400         if take_item then
401                 itemstack:take_item()
402         end
403         return itemstack, true
404 end
405
406 function core.item_place_object(itemstack, placer, pointed_thing)
407         local pos = core.get_pointed_thing_position(pointed_thing, true)
408         if pos ~= nil then
409                 local item = itemstack:take_item()
410                 core.add_item(pos, item)
411         end
412         return itemstack
413 end
414
415 function core.item_place(itemstack, placer, pointed_thing, param2)
416         -- Call on_rightclick if the pointed node defines it
417         if pointed_thing.type == "node" and placer and
418                         not placer:get_player_control().sneak then
419                 local n = core.get_node(pointed_thing.under)
420                 local nn = n.name
421                 if core.registered_nodes[nn] and core.registered_nodes[nn].on_rightclick then
422                         return core.registered_nodes[nn].on_rightclick(pointed_thing.under, n,
423                                         placer, itemstack, pointed_thing) or itemstack, false
424                 end
425         end
426
427         if itemstack:get_definition().type == "node" then
428                 return core.item_place_node(itemstack, placer, pointed_thing, param2)
429         end
430         return itemstack
431 end
432
433 function core.item_secondary_use(itemstack, placer)
434         return itemstack
435 end
436
437 function core.item_drop(itemstack, dropper, pos)
438         local dropper_is_player = dropper and dropper:is_player()
439         local p = table.copy(pos)
440         local cnt = itemstack:get_count()
441         if dropper_is_player then
442                 p.y = p.y + 1.2
443         end
444         local item = itemstack:take_item(cnt)
445         local obj = core.add_item(p, item)
446         if obj then
447                 if dropper_is_player then
448                         local dir = dropper:get_look_dir()
449                         dir.x = dir.x * 2.9
450                         dir.y = dir.y * 2.9 + 2
451                         dir.z = dir.z * 2.9
452                         obj:set_velocity(dir)
453                         obj:get_luaentity().dropped_by = dropper:get_player_name()
454                 end
455                 return itemstack
456         end
457         -- If we reach this, adding the object to the
458         -- environment failed
459 end
460
461 function core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)
462         for _, callback in pairs(core.registered_on_item_eats) do
463                 local result = callback(hp_change, replace_with_item, itemstack, user, pointed_thing)
464                 if result then
465                         return result
466                 end
467         end
468         if itemstack:take_item() ~= nil then
469                 user:set_hp(user:get_hp() + hp_change)
470
471                 if replace_with_item then
472                         if itemstack:is_empty() then
473                                 itemstack:add_item(replace_with_item)
474                         else
475                                 local inv = user:get_inventory()
476                                 -- Check if inv is null, since non-players don't have one
477                                 if inv and inv:room_for_item("main", {name=replace_with_item}) then
478                                         inv:add_item("main", replace_with_item)
479                                 else
480                                         local pos = user:getpos()
481                                         pos.y = math.floor(pos.y + 0.5)
482                                         core.add_item(pos, replace_with_item)
483                                 end
484                         end
485                 end
486         end
487         return itemstack
488 end
489
490 function core.item_eat(hp_change, replace_with_item)
491         return function(itemstack, user, pointed_thing)  -- closure
492                 if user then
493                         return core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)
494                 end
495         end
496 end
497
498 function core.node_punch(pos, node, puncher, pointed_thing)
499         -- Run script hook
500         for _, callback in ipairs(core.registered_on_punchnodes) do
501                 -- Copy pos and node because callback can modify them
502                 local pos_copy = vector.new(pos)
503                 local node_copy = {name=node.name, param1=node.param1, param2=node.param2}
504                 local pointed_thing_copy = pointed_thing and copy_pointed_thing(pointed_thing) or nil
505                 callback(pos_copy, node_copy, puncher, pointed_thing_copy)
506         end
507 end
508
509 function core.handle_node_drops(pos, drops, digger)
510         -- Add dropped items to object's inventory
511         local inv = digger and digger:get_inventory()
512         local give_item
513         if inv then
514                 give_item = function(item)
515                         return inv:add_item("main", item)
516                 end
517         else
518                 give_item = function(item)
519                         return item
520                 end
521         end
522
523         for _, dropped_item in pairs(drops) do
524                 local left = give_item(dropped_item)
525                 if not left:is_empty() then
526                         local p = {
527                                 x = pos.x + math.random()/2-0.25,
528                                 y = pos.y + math.random()/2-0.25,
529                                 z = pos.z + math.random()/2-0.25,
530                         }
531                         core.add_item(p, left)
532                 end
533         end
534 end
535
536 function core.node_dig(pos, node, digger)
537         local diggername = user_name(digger)
538         local log = make_log(diggername)
539         local def = core.registered_nodes[node.name]
540         if def and (not def.diggable or
541                         (def.can_dig and not def.can_dig(pos, digger))) then
542                 log("info", diggername .. " tried to dig "
543                         .. node.name .. " which is not diggable "
544                         .. core.pos_to_string(pos))
545                 return
546         end
547
548         if is_protected(pos, diggername) then
549                 log("action", diggername
550                                 .. " tried to dig " .. node.name
551                                 .. " at protected position "
552                                 .. core.pos_to_string(pos))
553                 core.record_protection_violation(pos, diggername)
554                 return
555         end
556
557         log('action', diggername .. " digs "
558                 .. node.name .. " at " .. core.pos_to_string(pos))
559
560         local wielded = digger and digger:get_wielded_item()
561         local drops = core.get_node_drops(node, wielded and wielded:get_name())
562
563         if wielded then
564                 local wdef = wielded:get_definition()
565                 local tp = wielded:get_tool_capabilities()
566                 local dp = core.get_dig_params(def and def.groups, tp)
567                 if wdef and wdef.after_use then
568                         wielded = wdef.after_use(wielded, digger, node, dp) or wielded
569                 else
570                         -- Wear out tool
571                         if not core.settings:get_bool("creative_mode") then
572                                 wielded:add_wear(dp.wear)
573                                 if wielded:get_count() == 0 and wdef.sound and wdef.sound.breaks then
574                                         core.sound_play(wdef.sound.breaks, {pos = pos, gain = 0.5})
575                                 end
576                         end
577                 end
578                 digger:set_wielded_item(wielded)
579         end
580
581         -- Handle drops
582         core.handle_node_drops(pos, drops, digger)
583
584         local oldmetadata = nil
585         if def and def.after_dig_node then
586                 oldmetadata = core.get_meta(pos):to_table()
587         end
588
589         -- Remove node and update
590         core.remove_node(pos)
591
592         -- Run callback
593         if def and def.after_dig_node then
594                 -- Copy pos and node because callback can modify them
595                 local pos_copy = {x=pos.x, y=pos.y, z=pos.z}
596                 local node_copy = {name=node.name, param1=node.param1, param2=node.param2}
597                 def.after_dig_node(pos_copy, node_copy, oldmetadata, digger)
598         end
599
600         -- Run script hook
601         local _, callback
602         for _, callback in ipairs(core.registered_on_dignodes) do
603                 local origin = core.callback_origins[callback]
604                 if origin then
605                         core.set_last_run_mod(origin.mod)
606                         --print("Running " .. tostring(callback) ..
607                         --      " (a " .. origin.name .. " callback in " .. origin.mod .. ")")
608                 else
609                         --print("No data associated with callback")
610                 end
611
612                 -- Copy pos and node because callback can modify them
613                 local pos_copy = {x=pos.x, y=pos.y, z=pos.z}
614                 local node_copy = {name=node.name, param1=node.param1, param2=node.param2}
615                 callback(pos_copy, node_copy, digger)
616         end
617 end
618
619 function core.itemstring_with_palette(item, palette_index)
620         local stack = ItemStack(item) -- convert to ItemStack
621         stack:get_meta():set_int("palette_index", palette_index)
622         return stack:to_string()
623 end
624
625 function core.itemstring_with_color(item, colorstring)
626         local stack = ItemStack(item) -- convert to ItemStack
627         stack:get_meta():set_string("color", colorstring)
628         return stack:to_string()
629 end
630
631 -- This is used to allow mods to redefine core.item_place and so on
632 -- NOTE: This is not the preferred way. Preferred way is to provide enough
633 --       callbacks to not require redefining global functions. -celeron55
634 local function redef_wrapper(table, name)
635         return function(...)
636                 return table[name](...)
637         end
638 end
639
640 --
641 -- Item definition defaults
642 --
643
644 core.nodedef_default = {
645         -- Item properties
646         type="node",
647         -- name intentionally not defined here
648         description = "",
649         groups = {},
650         inventory_image = "",
651         wield_image = "",
652         wield_scale = {x=1,y=1,z=1},
653         stack_max = 99,
654         usable = false,
655         liquids_pointable = false,
656         tool_capabilities = nil,
657         node_placement_prediction = nil,
658
659         -- Interaction callbacks
660         on_place = redef_wrapper(core, 'item_place'), -- core.item_place
661         on_drop = redef_wrapper(core, 'item_drop'), -- core.item_drop
662         on_use = nil,
663         can_dig = nil,
664
665         on_punch = redef_wrapper(core, 'node_punch'), -- core.node_punch
666         on_rightclick = nil,
667         on_dig = redef_wrapper(core, 'node_dig'), -- core.node_dig
668
669         on_receive_fields = nil,
670
671         on_metadata_inventory_move = core.node_metadata_inventory_move_allow_all,
672         on_metadata_inventory_offer = core.node_metadata_inventory_offer_allow_all,
673         on_metadata_inventory_take = core.node_metadata_inventory_take_allow_all,
674
675         -- Node properties
676         drawtype = "normal",
677         visual_scale = 1.0,
678         -- Don't define these because otherwise the old tile_images and
679         -- special_materials wouldn't be read
680         --tiles ={""},
681         --special_tiles = {
682         --      {name="", backface_culling=true},
683         --      {name="", backface_culling=true},
684         --},
685         alpha = 255,
686         post_effect_color = {a=0, r=0, g=0, b=0},
687         paramtype = "none",
688         paramtype2 = "none",
689         is_ground_content = true,
690         sunlight_propagates = false,
691         walkable = true,
692         pointable = true,
693         diggable = true,
694         climbable = false,
695         buildable_to = false,
696         floodable = false,
697         liquidtype = "none",
698         liquid_alternative_flowing = "",
699         liquid_alternative_source = "",
700         liquid_viscosity = 0,
701         drowning = 0,
702         light_source = 0,
703         damage_per_second = 0,
704         selection_box = {type="regular"},
705         legacy_facedir_simple = false,
706         legacy_wallmounted = false,
707 }
708
709 core.craftitemdef_default = {
710         type="craft",
711         -- name intentionally not defined here
712         description = "",
713         groups = {},
714         inventory_image = "",
715         wield_image = "",
716         wield_scale = {x=1,y=1,z=1},
717         stack_max = 99,
718         liquids_pointable = false,
719         tool_capabilities = nil,
720
721         -- Interaction callbacks
722         on_place = redef_wrapper(core, 'item_place'), -- core.item_place
723         on_drop = redef_wrapper(core, 'item_drop'), -- core.item_drop
724         on_secondary_use = redef_wrapper(core, 'item_secondary_use'),
725         on_use = nil,
726 }
727
728 core.tooldef_default = {
729         type="tool",
730         -- name intentionally not defined here
731         description = "",
732         groups = {},
733         inventory_image = "",
734         wield_image = "",
735         wield_scale = {x=1,y=1,z=1},
736         stack_max = 1,
737         liquids_pointable = false,
738         tool_capabilities = nil,
739
740         -- Interaction callbacks
741         on_place = redef_wrapper(core, 'item_place'), -- core.item_place
742         on_secondary_use = redef_wrapper(core, 'item_secondary_use'),
743         on_drop = redef_wrapper(core, 'item_drop'), -- core.item_drop
744         on_use = nil,
745 }
746
747 core.noneitemdef_default = {  -- This is used for the hand and unknown items
748         type="none",
749         -- name intentionally not defined here
750         description = "",
751         groups = {},
752         inventory_image = "",
753         wield_image = "",
754         wield_scale = {x=1,y=1,z=1},
755         stack_max = 99,
756         liquids_pointable = false,
757         tool_capabilities = nil,
758
759         -- Interaction callbacks
760         on_place = redef_wrapper(core, 'item_place'),
761         on_secondary_use = redef_wrapper(core, 'item_secondary_use'),
762         on_drop = nil,
763         on_use = nil,
764 }