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