]> git.lizzy.rs Git - minetest.git/blob - builtin/game/item.lua
Check item_drop amount clientside (#6242)
[minetest.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                         for _, tool in ipairs(item.tools) do
219                                 if tool:sub(1, 1) == '~' then
220                                         good_tool = toolname:find(tool:sub(2)) ~= nil
221                                 else
222                                         good_tool = toolname == tool
223                                 end
224                                 if good_tool then
225                                         break
226                                 end
227                         end
228                 end
229                 if good_rarity and good_tool then
230                         got_count = got_count + 1
231                         for _, add_item in ipairs(item.items) do
232                                 -- add color, if necessary
233                                 if item.inherit_color and palette_index then
234                                         local stack = ItemStack(add_item)
235                                         stack:get_meta():set_int("palette_index", palette_index)
236                                         add_item = stack:to_string()
237                                 end
238                                 got_items[#got_items+1] = add_item
239                         end
240                         if drop.max_items ~= nil and got_count == drop.max_items then
241                                 break
242                         end
243                 end
244         end
245         return got_items
246 end
247
248 function core.item_place_node(itemstack, placer, pointed_thing, param2)
249         local def = itemstack:get_definition()
250         if def.type ~= "node" or pointed_thing.type ~= "node" then
251                 return itemstack, false
252         end
253
254         local under = pointed_thing.under
255         local oldnode_under = core.get_node_or_nil(under)
256         local above = pointed_thing.above
257         local oldnode_above = core.get_node_or_nil(above)
258         local playername = placer:get_player_name()
259
260         if not oldnode_under or not oldnode_above then
261                 core.log("info", playername .. " tried to place"
262                         .. " node in unloaded position " .. core.pos_to_string(above))
263                 return itemstack, false
264         end
265
266         local olddef_under = core.registered_nodes[oldnode_under.name]
267         olddef_under = olddef_under or core.nodedef_default
268         local olddef_above = core.registered_nodes[oldnode_above.name]
269         olddef_above = olddef_above or core.nodedef_default
270
271         if not olddef_above.buildable_to and not olddef_under.buildable_to then
272                 core.log("info", playername .. " tried to place"
273                         .. " node in invalid position " .. core.pos_to_string(above)
274                         .. ", replacing " .. oldnode_above.name)
275                 return itemstack, false
276         end
277
278         -- Place above pointed node
279         local place_to = {x = above.x, y = above.y, z = above.z}
280
281         -- If node under is buildable_to, place into it instead (eg. snow)
282         if olddef_under.buildable_to then
283                 core.log("info", "node under is buildable to")
284                 place_to = {x = under.x, y = under.y, z = under.z}
285         end
286
287         if core.is_protected(place_to, playername) and
288                         not minetest.check_player_privs(placer, "protection_bypass") then
289                 core.log("action", playername
290                                 .. " tried to place " .. def.name
291                                 .. " at protected position "
292                                 .. core.pos_to_string(place_to))
293                 core.record_protection_violation(place_to, playername)
294                 return itemstack
295         end
296
297         core.log("action", playername .. " places node "
298                 .. def.name .. " at " .. core.pos_to_string(place_to))
299
300         local oldnode = core.get_node(place_to)
301         local newnode = {name = def.name, param1 = 0, param2 = param2 or 0}
302
303         -- Calculate direction for wall mounted stuff like torches and signs
304         if def.place_param2 ~= nil then
305                 newnode.param2 = def.place_param2
306         elseif (def.paramtype2 == "wallmounted" or
307                         def.paramtype2 == "colorwallmounted") and not param2 then
308                 local dir = {
309                         x = under.x - above.x,
310                         y = under.y - above.y,
311                         z = under.z - above.z
312                 }
313                 newnode.param2 = core.dir_to_wallmounted(dir)
314         -- Calculate the direction for furnaces and chests and stuff
315         elseif (def.paramtype2 == "facedir" or
316                         def.paramtype2 == "colorfacedir") and not param2 then
317                 local placer_pos = placer:getpos()
318                 if placer_pos then
319                         local dir = {
320                                 x = above.x - placer_pos.x,
321                                 y = above.y - placer_pos.y,
322                                 z = above.z - placer_pos.z
323                         }
324                         newnode.param2 = core.dir_to_facedir(dir)
325                         core.log("action", "facedir: " .. newnode.param2)
326                 end
327         end
328
329         local metatable = itemstack:get_meta():to_table().fields
330
331         -- Transfer color information
332         if metatable.palette_index and not def.place_param2 then
333                 local color_divisor = nil
334                 if def.paramtype2 == "color" then
335                         color_divisor = 1
336                 elseif def.paramtype2 == "colorwallmounted" then
337                         color_divisor = 8
338                 elseif def.paramtype2 == "colorfacedir" then
339                         color_divisor = 32
340                 end
341                 if color_divisor then
342                         local color = math.floor(metatable.palette_index / color_divisor)
343                         local other = newnode.param2 % color_divisor
344                         newnode.param2 = color * color_divisor + other
345                 end
346         end
347
348         -- Check if the node is attached and if it can be placed there
349         if core.get_item_group(def.name, "attached_node") ~= 0 and
350                 not builtin_shared.check_attached_node(place_to, newnode) then
351                 core.log("action", "attached node " .. def.name ..
352                         " can not be placed at " .. core.pos_to_string(place_to))
353                 return itemstack, false
354         end
355
356         -- Add node and update
357         core.add_node(place_to, newnode)
358
359         local take_item = true
360
361         -- Run callback
362         if def.after_place_node then
363                 -- Deepcopy place_to and pointed_thing because callback can modify it
364                 local place_to_copy = {x=place_to.x, y=place_to.y, z=place_to.z}
365                 local pointed_thing_copy = copy_pointed_thing(pointed_thing)
366                 if def.after_place_node(place_to_copy, placer, itemstack,
367                                 pointed_thing_copy) then
368                         take_item = false
369                 end
370         end
371
372         -- Run script hook
373         for _, callback in ipairs(core.registered_on_placenodes) do
374                 -- Deepcopy pos, node and pointed_thing because callback can modify them
375                 local place_to_copy = {x=place_to.x, y=place_to.y, z=place_to.z}
376                 local newnode_copy = {name=newnode.name, param1=newnode.param1, param2=newnode.param2}
377                 local oldnode_copy = {name=oldnode.name, param1=oldnode.param1, param2=oldnode.param2}
378                 local pointed_thing_copy = copy_pointed_thing(pointed_thing)
379                 if callback(place_to_copy, newnode_copy, placer, oldnode_copy, itemstack, pointed_thing_copy) then
380                         take_item = false
381                 end
382         end
383
384         if take_item then
385                 itemstack:take_item()
386         end
387         return itemstack, true
388 end
389
390 function core.item_place_object(itemstack, placer, pointed_thing)
391         local pos = core.get_pointed_thing_position(pointed_thing, true)
392         if pos ~= nil then
393                 local item = itemstack:take_item()
394                 core.add_item(pos, item)
395         end
396         return itemstack
397 end
398
399 function core.item_place(itemstack, placer, pointed_thing, param2)
400         -- Call on_rightclick if the pointed node defines it
401         if pointed_thing.type == "node" and placer and
402                         not placer:get_player_control().sneak then
403                 local n = core.get_node(pointed_thing.under)
404                 local nn = n.name
405                 if core.registered_nodes[nn] and core.registered_nodes[nn].on_rightclick then
406                         return core.registered_nodes[nn].on_rightclick(pointed_thing.under, n,
407                                         placer, itemstack, pointed_thing) or itemstack, false
408                 end
409         end
410
411         if itemstack:get_definition().type == "node" then
412                 return core.item_place_node(itemstack, placer, pointed_thing, param2)
413         end
414         return itemstack
415 end
416
417 function core.item_secondary_use(itemstack, placer)
418         return itemstack
419 end
420
421 function core.item_drop(itemstack, dropper, pos)
422         if dropper and dropper:is_player() then
423                 local dir = dropper:get_look_dir()
424                 local p = {x = pos.x, y = pos.y + 1.2, z = pos.z}
425                 local cnt = itemstack:get_count()
426                 local item = itemstack:take_item(cnt)
427                 local obj = core.add_item(p, item)
428                 if obj then
429                         dir.x = dir.x * 2
430                         dir.y = dir.y * 2 + 2
431                         dir.z = dir.z * 2
432                         obj:set_velocity(dir)
433                         obj:get_luaentity().dropped_by = dropper:get_player_name()
434                         return itemstack
435                 end
436
437         else
438                 if core.add_item(pos, itemstack) then
439                         return itemstack
440                 end
441         end
442         -- If we reach this, adding the object to the
443         -- environment failed
444 end
445
446 function core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)
447         for _, callback in pairs(core.registered_on_item_eats) do
448                 local result = callback(hp_change, replace_with_item, itemstack, user, pointed_thing)
449                 if result then
450                         return result
451                 end
452         end
453         if itemstack:take_item() ~= nil then
454                 user:set_hp(user:get_hp() + hp_change)
455
456                 if replace_with_item then
457                         if itemstack:is_empty() then
458                                 itemstack:add_item(replace_with_item)
459                         else
460                                 local inv = user:get_inventory()
461                                 if inv:room_for_item("main", {name=replace_with_item}) then
462                                         inv:add_item("main", replace_with_item)
463                                 else
464                                         local pos = user:getpos()
465                                         pos.y = math.floor(pos.y + 0.5)
466                                         core.add_item(pos, replace_with_item)
467                                 end
468                         end
469                 end
470         end
471         return itemstack
472 end
473
474 function core.item_eat(hp_change, replace_with_item)
475         return function(itemstack, user, pointed_thing)  -- closure
476                 return core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)
477         end
478 end
479
480 function core.node_punch(pos, node, puncher, pointed_thing)
481         -- Run script hook
482         for _, callback in ipairs(core.registered_on_punchnodes) do
483                 -- Copy pos and node because callback can modify them
484                 local pos_copy = vector.new(pos)
485                 local node_copy = {name=node.name, param1=node.param1, param2=node.param2}
486                 local pointed_thing_copy = pointed_thing and copy_pointed_thing(pointed_thing) or nil
487                 callback(pos_copy, node_copy, puncher, pointed_thing_copy)
488         end
489 end
490
491 function core.handle_node_drops(pos, drops, digger)
492         -- Add dropped items to object's inventory
493         if digger:get_inventory() then
494                 local _, dropped_item
495                 for _, dropped_item in ipairs(drops) do
496                         local left = digger:get_inventory():add_item("main", dropped_item)
497                         if not left:is_empty() then
498                                 local p = {
499                                         x = pos.x + math.random()/2-0.25,
500                                         y = pos.y + math.random()/2-0.25,
501                                         z = pos.z + math.random()/2-0.25,
502                                 }
503                                 core.add_item(p, left)
504                         end
505                 end
506         end
507 end
508
509 function core.node_dig(pos, node, digger)
510         local def = core.registered_nodes[node.name]
511         if def and (not def.diggable or
512                         (def.can_dig and not def.can_dig(pos, digger))) then
513                 core.log("info", digger:get_player_name() .. " tried to dig "
514                         .. node.name .. " which is not diggable "
515                         .. core.pos_to_string(pos))
516                 return
517         end
518
519         if core.is_protected(pos, digger:get_player_name()) and
520                         not minetest.check_player_privs(digger, "protection_bypass") then
521                 core.log("action", digger:get_player_name()
522                                 .. " tried to dig " .. node.name
523                                 .. " at protected position "
524                                 .. core.pos_to_string(pos))
525                 core.record_protection_violation(pos, digger:get_player_name())
526                 return
527         end
528
529         core.log('action', digger:get_player_name() .. " digs "
530                 .. node.name .. " at " .. core.pos_to_string(pos))
531
532         local wielded = digger:get_wielded_item()
533         local drops = core.get_node_drops(node, wielded:get_name())
534
535         local wdef = wielded:get_definition()
536         local tp = wielded:get_tool_capabilities()
537         local dp = core.get_dig_params(def and def.groups, tp)
538         if wdef and wdef.after_use then
539                 wielded = wdef.after_use(wielded, digger, node, dp) or wielded
540         else
541                 -- Wear out tool
542                 if not core.settings:get_bool("creative_mode") then
543                         wielded:add_wear(dp.wear)
544                         if wielded:get_count() == 0 and wdef.sound and wdef.sound.breaks then
545                                 core.sound_play(wdef.sound.breaks, {pos = pos, gain = 0.5})
546                         end
547                 end
548         end
549         digger:set_wielded_item(wielded)
550
551         -- Handle drops
552         core.handle_node_drops(pos, drops, digger)
553
554         local oldmetadata = nil
555         if def and def.after_dig_node then
556                 oldmetadata = core.get_meta(pos):to_table()
557         end
558
559         -- Remove node and update
560         core.remove_node(pos)
561
562         -- Run callback
563         if def and def.after_dig_node then
564                 -- Copy pos and node because callback can modify them
565                 local pos_copy = {x=pos.x, y=pos.y, z=pos.z}
566                 local node_copy = {name=node.name, param1=node.param1, param2=node.param2}
567                 def.after_dig_node(pos_copy, node_copy, oldmetadata, digger)
568         end
569
570         -- Run script hook
571         local _, callback
572         for _, callback in ipairs(core.registered_on_dignodes) do
573                 local origin = core.callback_origins[callback]
574                 if origin then
575                         core.set_last_run_mod(origin.mod)
576                         --print("Running " .. tostring(callback) ..
577                         --      " (a " .. origin.name .. " callback in " .. origin.mod .. ")")
578                 else
579                         --print("No data associated with callback")
580                 end
581
582                 -- Copy pos and node because callback can modify them
583                 local pos_copy = {x=pos.x, y=pos.y, z=pos.z}
584                 local node_copy = {name=node.name, param1=node.param1, param2=node.param2}
585                 callback(pos_copy, node_copy, digger)
586         end
587 end
588
589 function core.itemstring_with_palette(item, palette_index)
590         local stack = ItemStack(item) -- convert to ItemStack
591         stack:get_meta():set_int("palette_index", palette_index)
592         return stack:to_string()
593 end
594
595 function core.itemstring_with_color(item, colorstring)
596         local stack = ItemStack(item) -- convert to ItemStack
597         stack:get_meta():set_string("color", colorstring)
598         return stack:to_string()
599 end
600
601 -- This is used to allow mods to redefine core.item_place and so on
602 -- NOTE: This is not the preferred way. Preferred way is to provide enough
603 --       callbacks to not require redefining global functions. -celeron55
604 local function redef_wrapper(table, name)
605         return function(...)
606                 return table[name](...)
607         end
608 end
609
610 --
611 -- Item definition defaults
612 --
613
614 core.nodedef_default = {
615         -- Item properties
616         type="node",
617         -- name intentionally not defined here
618         description = "",
619         groups = {},
620         inventory_image = "",
621         wield_image = "",
622         wield_scale = {x=1,y=1,z=1},
623         stack_max = 99,
624         usable = false,
625         liquids_pointable = false,
626         tool_capabilities = nil,
627         node_placement_prediction = nil,
628
629         -- Interaction callbacks
630         on_place = redef_wrapper(core, 'item_place'), -- core.item_place
631         on_drop = redef_wrapper(core, 'item_drop'), -- core.item_drop
632         on_use = nil,
633         can_dig = nil,
634
635         on_punch = redef_wrapper(core, 'node_punch'), -- core.node_punch
636         on_rightclick = nil,
637         on_dig = redef_wrapper(core, 'node_dig'), -- core.node_dig
638
639         on_receive_fields = nil,
640
641         on_metadata_inventory_move = core.node_metadata_inventory_move_allow_all,
642         on_metadata_inventory_offer = core.node_metadata_inventory_offer_allow_all,
643         on_metadata_inventory_take = core.node_metadata_inventory_take_allow_all,
644
645         -- Node properties
646         drawtype = "normal",
647         visual_scale = 1.0,
648         -- Don't define these because otherwise the old tile_images and
649         -- special_materials wouldn't be read
650         --tiles ={""},
651         --special_tiles = {
652         --      {name="", backface_culling=true},
653         --      {name="", backface_culling=true},
654         --},
655         alpha = 255,
656         post_effect_color = {a=0, r=0, g=0, b=0},
657         paramtype = "none",
658         paramtype2 = "none",
659         is_ground_content = true,
660         sunlight_propagates = false,
661         walkable = true,
662         pointable = true,
663         diggable = true,
664         climbable = false,
665         buildable_to = false,
666         floodable = false,
667         liquidtype = "none",
668         liquid_alternative_flowing = "",
669         liquid_alternative_source = "",
670         liquid_viscosity = 0,
671         drowning = 0,
672         light_source = 0,
673         damage_per_second = 0,
674         selection_box = {type="regular"},
675         legacy_facedir_simple = false,
676         legacy_wallmounted = false,
677 }
678
679 core.craftitemdef_default = {
680         type="craft",
681         -- name intentionally not defined here
682         description = "",
683         groups = {},
684         inventory_image = "",
685         wield_image = "",
686         wield_scale = {x=1,y=1,z=1},
687         stack_max = 99,
688         liquids_pointable = false,
689         tool_capabilities = nil,
690
691         -- Interaction callbacks
692         on_place = redef_wrapper(core, 'item_place'), -- core.item_place
693         on_drop = redef_wrapper(core, 'item_drop'), -- core.item_drop
694         on_secondary_use = redef_wrapper(core, 'item_secondary_use'),
695         on_use = nil,
696 }
697
698 core.tooldef_default = {
699         type="tool",
700         -- name intentionally not defined here
701         description = "",
702         groups = {},
703         inventory_image = "",
704         wield_image = "",
705         wield_scale = {x=1,y=1,z=1},
706         stack_max = 1,
707         liquids_pointable = false,
708         tool_capabilities = nil,
709
710         -- Interaction callbacks
711         on_place = redef_wrapper(core, 'item_place'), -- core.item_place
712         on_secondary_use = redef_wrapper(core, 'item_secondary_use'),
713         on_drop = redef_wrapper(core, 'item_drop'), -- core.item_drop
714         on_use = nil,
715 }
716
717 core.noneitemdef_default = {  -- This is used for the hand and unknown items
718         type="none",
719         -- name intentionally not defined here
720         description = "",
721         groups = {},
722         inventory_image = "",
723         wield_image = "",
724         wield_scale = {x=1,y=1,z=1},
725         stack_max = 99,
726         liquids_pointable = false,
727         tool_capabilities = nil,
728
729         -- Interaction callbacks
730         on_place = redef_wrapper(core, 'item_place'),
731         on_secondary_use = redef_wrapper(core, 'item_secondary_use'),
732         on_drop = nil,
733         on_use = nil,
734 }