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