aboutsummaryrefslogtreecommitdiff
path: root/data/mineral_coal.png
blob: 3ff9692fb483347662c6b1aa37ff7214d1bd125d (plain)
ofshex dumpascii
0000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 10 00 00 00 10 08 06 00 00 00 1f f3 ff .PNG........IHDR................
0020 61 00 00 03 00 50 4c 54 45 00 00 00 ff 00 00 00 ff 00 ff ff 00 00 00 ff ff 00 ff 00 ff ff ff ff a....PLTE.......................
0040 ff db db db b6 b6 b6 92 92 92 6d 6d 6d 49 49 49 24 24 24 db 00 00 b6 00 00 92 00 00 6d 00 00 49 ..........mmmIII$$$.........m..I
0060 00 00 24 00 00 00 db 00 00 b6 00 00 92 00 00 6d 00 00 49 00 00 24 00 db db 00 b6 b6 00 92 92 00 ..$............m..I..$..........
0080 6d 6d 00 49 49 00 24 24 00 00 00 db 00 00 b6 00 00 92 00 00 6d 00 00 49 00 00 24 db 00 db b6 00 mm.II.$$............m..I..$.....
00a0 b6 92 00 92 6d 00 6d 49 00 49 24 00 24 00 db db 00 b6 b6 00 92 92 00 6d 6d 00 49 49 00 24 24 ff ....m.mI.I$.$..........mm.II.$$.
00c0 db db db b6 b6 b6 92 92 92 6d 6d 6d 49 49 49 24 24 ff b6 b6 db 92 92 b6 6d 6d 92 49 49 6d 24 24 .........mmmIII$$.......mm.IIm$$
00e0 ff 92 92 db 6d 6d b6 49 49 92 24 24 ff 6d 6d db 49 49 b6 24 24 ff 49 49 db 24 24 ff 24 24 db ff ....mm.II.$$.mm.II.$$.II.$$.$$..
0100 db b6 db b6 92 b6 92 6d 92 6d 49 6d 49 24 49 24 b6 ff b6 92 db 92 6d b6 6d 49 92 49 24 6d 24 92 .......m.mImI$I$......m.mI.I$m$.
0120 ff 92 6d db 6d 49 b6 49 24 92 24 6d ff 6d 49 db 49 24 b6 24 49 ff 49 24 db 24 24 ff 24 db db ff ..m.mI.I$.$m.mI.I$.$I.I$.$$.$...
0140 b6 b6 db 92 92 b6 6d 6d 92 49 49 6d 24 24 49 b6 b6 ff 92 92 db 6d 6d b6 49 49 92 24 24 6d 92 92 ......mm.IIm$$I......mm.II.$$m..
0160 ff 6d 6d db 49 49 b6 24 24 92 6d 6d ff 49 49 db 24 24 b6 49 49 ff 24 24 db 24 24 ff ff ff db db .mm.II.$$.mm.II.$$.II.$$.$$.....
0180 db b6 b6 b6 92 92 92 6d 6d 6d 49 49 49 24 ff ff b6 db db 92 b6 b6 6d 92 92 49 6d 6d 24 ff ff 92 .......mmmIII$........m..Imm$...
01a0 db db 6d b6 b6 49 92 92 24 ff ff 6d db db 49 b6 b6 24 ff ff 49 db db 24 ff ff 24 ff db ff db b6 ..m..I..$..m..I..$..I..$..$.....
01c0 db b6 92 b6 92 6d 92 6d 49 6d 49 24 49 ff b6 ff db 92 db b6 6d b6 92 49 92 6d 24 6d ff 92 ff db .....m.mImI$I.......m..I.m$m....
01e0 6d db b6 49 b6 92 24 92 ff 6d ff db 49 db b6 24 b6 ff 49 ff db 24 db ff 24 ff db ff ff b6 db db m..I..$..m..I..$..I..$..$.......
0200 92 b6 b6 6d 92 92 49 6d 6d 24 49 49 b6 ff ff 92 db db 6d b6 b6 49 92 92 24 6d 6d 92 ff ff 6d db ...m..Imm$II......m..I..$mm...m.
0220 db 49 b6 b6 24 92 92 6d ff ff 49 db db 24 b6 b6 49 ff ff 24 db db 24 ff ff ff db b6 db b6 92 b6 .I..$..m..I..$..I..$..$.........
0240 92 6d 92 6d 49 6d 49 24 49 24 00 ff b6 92 db 92 6d b6 6d 49 92 49 24 6d 24 00 ff b6 db db 92 b6 .m.mImI$I$......m.mI.I$m$.......
0260 b6 6d 92 92 49 6d 6d 24 49 49 00 24 ff 92 b6 db 6d 92 b6 49 6d 92 24 49 6d 00 24 db b6 ff b6 92 .m..Imm$II.$....m..Im.$Im.$.....
0280 db 92 6d b6 6d 49 92 49 24 6d 24 00 49 b6 92 ff 92 6d db 6d 49 b6 49 24 92 24 00 6d b6 db ff 92 ..m.mI.I$m$.I....m.mI.I$.$.m....
02a0 b6 db 6d 92 b6 49 6d 92 24 49 6d 00 24 49 92 b6 ff 6d 92 db 49 6d b6 24 49 92 00 24 6d b6 ff db ..m..Im.$Im.$I...m..Im.$I..$m...
02c0 92 db b6 6d b6 92 49 92 6d 24 6d 49 00 49 24 92 ff b6 6d db 92 49 b6 6d 24 92 49 00 6d 24 db ff ...m..I.m$mI.I$...m..I.m$.I.m$..
02e0 b6 b6 db 92 92 b6 6d 6d 92 49 49 6d 24 24 49 00 b6 ff 92 92 db 6d 6d b6 49 49 92 24 24 6d 00 ff ......mm.IIm$$I......mm.II.$$m..
0300 b6 00 db 92 00 b6 6d 00 92 49 00 ff 00 b6 db 00 92 b6 00 6d 92 00 49 00 b6 ff 00 92 db 00 6d b6 ......m..I.........m..I.......m.
0320 00 49 92 00 00 00 00 00 00 cf 2a 02 04 00 00 00 73 49 44 41 54 38 cb cd 92 31 0e c0 20 0c 03 9d .I........*.....sIDAT8...1......
0340 35 ef f0 9c ff bf 83 99 77 64 4d 27 24 a0 69 ab aa b4 aa 37 84 62 c8 d9 c0 6a 91 0c 92 f1 99 a9 5.......wdM'$.i....7.b...j......
0360 5c 0d aa 2a 4a 29 02 00 66 16 ee 0e 00 a8 b5 ca 60 d0 bf d0 2e ff a7 8c 45 ba c2 2c 55 1d ce 3d \..*J)..f.......`.......E..,U..=
0380 87 dd ae 66 36 18 35 80 af 49 b2 ef cf 29 90 8c a3 64 e4 0c 58 c6 c0 dd d7 c6 fc b8 48 72 b7 07 ...f6.5..I...)...d..X.......Hr..
03a0 cb db ba 01 5d 8e 39 8b 9c 03 e6 54 00 00 00 00 49 45 4e 44 ae 42 60 82 ....].9....T....IEND.B`.
a id='n202' href='#n202'>202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802
-- Minetest: builtin/item.lua

local builtin_shared = ...

local function copy_pointed_thing(pointed_thing)
	return {
		type  = pointed_thing.type,
		above = vector.new(pointed_thing.above),
		under = vector.new(pointed_thing.under),
		ref   = pointed_thing.ref,
	}
end

--
-- Item definition helpers
--

function core.inventorycube(img1, img2, img3)
	img2 = img2 or img1
	img3 = img3 or img1
	return "[inventorycube"
			.. "{" .. img1:gsub("%^", "&")
			.. "{" .. img2:gsub("%^", "&")
			.. "{" .. img3:gsub("%^", "&")
end

function core.get_pointed_thing_position(pointed_thing, above)
	if pointed_thing.type == "node" then
		if above then
			-- The position where a node would be placed
			return pointed_thing.above
		end
		-- The position where a node would be dug
		return pointed_thing.under
	elseif pointed_thing.type == "object" then
		return pointed_thing.ref and pointed_thing.ref:get_pos()
	end
end

function core.dir_to_facedir(dir, is6d)
	--account for y if requested
	if is6d and math.abs(dir.y) > math.abs(dir.x) and math.abs(dir.y) > math.abs(dir.z) then

		--from above
		if dir.y < 0 then
			if math.abs(dir.x) > math.abs(dir.z) then
				if dir.x < 0 then
					return 19
				else
					return 13
				end
			else
				if dir.z < 0 then
					return 10
				else
					return 4
				end
			end

		--from below
		else
			if math.abs(dir.x) > math.abs(dir.z) then
				if dir.x < 0 then
					return 15
				else
					return 17
				end
			else
				if dir.z < 0 then
					return 6
				else
					return 8
				end
			end
		end

	--otherwise, place horizontally
	elseif math.abs(dir.x) > math.abs(dir.z) then
		if dir.x < 0 then
			return 3
		else
			return 1
		end
	else
		if dir.z < 0 then
			return 2
		else
			return 0
		end
	end
end

-- Table of possible dirs
local facedir_to_dir = {
	{x= 0, y=0,  z= 1},
	{x= 1, y=0,  z= 0},
	{x= 0, y=0,  z=-1},
	{x=-1, y=0,  z= 0},
	{x= 0, y=-1, z= 0},
	{x= 0, y=1,  z= 0},
}
-- Mapping from facedir value to index in facedir_to_dir.
local facedir_to_dir_map = {
	[0]=1, 2, 3, 4,
	5, 2, 6, 4,
	6, 2, 5, 4,
	1, 5, 3, 6,
	1, 6, 3, 5,
	1, 4, 3, 2,
}
function core.facedir_to_dir(facedir)
	return facedir_to_dir[facedir_to_dir_map[facedir % 32]]
end

function core.dir_to_wallmounted(dir)
	if math.abs(dir.y) > math.max(math.abs(dir.x), math.abs(dir.z)) then
		if dir.y < 0 then
			return 1
		else
			return 0
		end
	elseif math.abs(dir.x) > math.abs(dir.z) then
		if dir.x < 0 then
			return 3
		else
			return 2
		end
	else
		if dir.z < 0 then
			return 5
		else
			return 4
		end
	end
end

-- table of dirs in wallmounted order
local wallmounted_to_dir = {
	[0] = {x = 0, y = 1, z = 0},
	{x =  0, y = -1, z =  0},
	{x =  1, y =  0, z =  0},
	{x = -1, y =  0, z =  0},
	{x =  0, y =  0, z =  1},
	{x =  0, y =  0, z = -1},
}
function core.wallmounted_to_dir(wallmounted)
	return wallmounted_to_dir[wallmounted % 8]
end

function core.dir_to_yaw(dir)
	return -math.atan2(dir.x, dir.z)
end

function core.yaw_to_dir(yaw)
	return {x = -math.sin(yaw), y = 0, z = math.cos(yaw)}
end

function core.is_colored_paramtype(ptype)
	return (ptype == "color") or (ptype == "colorfacedir") or
		(ptype == "colorwallmounted") or (ptype == "colordegrotate")
end

function core.strip_param2_color(param2, paramtype2)
	if not core.is_colored_paramtype(paramtype2) then
		return nil
	end
	if paramtype2 == "colorfacedir" then
		param2 = math.floor(param2 / 32) * 32
	elseif paramtype2 == "colorwallmounted" then
		param2 = math.floor(param2 / 8) * 8
	elseif paramtype2 == "colordegrotate" then
		param2 = math.floor(param2 / 32) * 32
	end
	-- paramtype2 == "color" requires no modification.
	return param2
end

function core.get_node_drops(node, toolname)
	-- Compatibility, if node is string
	local nodename = node
	local param2 = 0
	-- New format, if node is table
	if (type(node) == "table") then
		nodename = node.name
		param2 = node.param2
	end
	local def = core.registered_nodes[nodename]
	local drop = def and def.drop
	local ptype = def and def.paramtype2
	-- get color, if there is color (otherwise nil)
	local palette_index = core.strip_param2_color(param2, ptype)
	if drop == nil then
		-- default drop
		if palette_index then
			local stack = ItemStack(nodename)
			stack:get_meta():set_int("palette_index", palette_index)
			return {stack:to_string()}
		end
		return {nodename}
	elseif type(drop) == "string" then
		-- itemstring drop
		return drop ~= "" and {drop} or {}
	elseif drop.items == nil then
		-- drop = {} to disable default drop
		return {}
	end

	-- Extended drop table
	local got_items = {}
	local got_count = 0
	for _, item in ipairs(drop.items) do
		local good_rarity = true
		local good_tool = true
		if item.rarity ~= nil then
			good_rarity = item.rarity < 1 or math.random(item.rarity) == 1
		end
		if item.tools ~= nil then
			good_tool = false
		end
		if item.tools ~= nil and toolname then
			for _, tool in ipairs(item.tools) do
				if tool:sub(1, 1) == '~' then
					good_tool = toolname:find(tool:sub(2)) ~= nil
				else
					good_tool = toolname == tool
				end
				if good_tool then
					break
				end
			end
		end
		if good_rarity and good_tool then
			got_count = got_count + 1
			for _, add_item in ipairs(item.items) do
				-- add color, if necessary
				if item.inherit_color and palette_index then
					local stack = ItemStack(add_item)
					stack:get_meta():set_int("palette_index", palette_index)
					add_item = stack:to_string()
				end
				got_items[#got_items+1] = add_item
			end
			if drop.max_items ~= nil and got_count == drop.max_items then
				break
			end
		end
	end
	return got_items
end

local function user_name(user)
	return user and user:get_player_name() or ""
end

-- Returns a logging function. For empty names, does not log.
local function make_log(name)
	return name ~= "" and core.log or function() end
end

function core.item_place_node(itemstack, placer, pointed_thing, param2,
		prevent_after_place)
	local def = itemstack:get_definition()
	if def.type ~= "node" or pointed_thing.type ~= "node" then
		return itemstack, nil
	end

	local under = pointed_thing.under
	local oldnode_under = core.get_node_or_nil(under)
	local above = pointed_thing.above
	local oldnode_above = core.get_node_or_nil(above)
	local playername = user_name(placer)
	local log = make_log(playername)

	if not oldnode_under or not oldnode_above then
		log("info", playername .. " tried to place"
			.. " node in unloaded position " .. core.pos_to_string(above))
		return itemstack, nil
	end

	local olddef_under = core.registered_nodes[oldnode_under.name]
	olddef_under = olddef_under or core.nodedef_default
	local olddef_above = core.registered_nodes[oldnode_above.name]
	olddef_above = olddef_above or core.nodedef_default

	if not olddef_above.buildable_to and not olddef_under.buildable_to then
		log("info", playername .. " tried to place"
			.. " node in invalid position " .. core.pos_to_string(above)
			.. ", replacing " .. oldnode_above.name)
		return itemstack, nil
	end

	-- Place above pointed node
	local place_to = {x = above.x, y = above.y, z = above.z}

	-- If node under is buildable_to, place into it instead (eg. snow)
	if olddef_under.buildable_to then
		log("info", "node under is buildable to")
		place_to = {x = under.x, y = under.y, z = under.z}
	end

	if core.is_protected(place_to, playername) then
		log("action", playername
				.. " tried to place " .. def.name
				.. " at protected position "
				.. core.pos_to_string(place_to))
		core.record_protection_violation(place_to, playername)
		return itemstack, nil
	end

	local oldnode = core.get_node(place_to)
	local newnode = {name = def.name, param1 = 0, param2 = param2 or 0}

	-- Calculate direction for wall mounted stuff like torches and signs
	if def.place_param2 ~= nil then
		newnode.param2 = def.place_param2
	elseif (def.paramtype2 == "wallmounted" or
			def.paramtype2 == "colorwallmounted") and not param2 then
		local dir = {
			x = under.x - above.x,
			y = under.y - above.y,
			z = under.z - above.z
		}
		newnode.param2 = core.dir_to_wallmounted(dir)
	-- Calculate the direction for furnaces and chests and stuff
	elseif (def.paramtype2 == "facedir" or
			def.paramtype2 == "colorfacedir") and not param2 then
		local placer_pos = placer and placer:get_pos()
		if placer_pos then
			local dir = {
				x = above.x - placer_pos.x,
				y = above.y - placer_pos.y,
				z = above.z - placer_pos.z
			}
			newnode.param2 = core.dir_to_facedir(dir)
			log("info", "facedir: " .. newnode.param2)
		end
	end

	local metatable = itemstack:get_meta():to_table().fields

	-- Transfer color information
	if metatable.palette_index and not def.place_param2 then
		local color_divisor = nil
		if def.paramtype2 == "color" then
			color_divisor = 1
		elseif def.paramtype2 == "colorwallmounted" then
			color_divisor = 8
		elseif def.paramtype2 == "colorfacedir" then
			color_divisor = 32
		elseif def.paramtype2 == "colordegrotate" then
			color_divisor = 32
		end
		if color_divisor then
			local color = math.floor(metatable.palette_index / color_divisor)
			local other = newnode.param2 % color_divisor
			newnode.param2 = color * color_divisor + other
		end
	end

	-- Check if the node is attached and if it can be placed there
	if core.get_item_group(def.name, "attached_node") ~= 0 and
		not builtin_shared.check_attached_node(place_to, newnode) then
		log("action", "attached node " .. def.name ..
			" can not be placed at " .. core.pos_to_string(place_to))
		return itemstack, nil
	end

	log("action", playername .. " places node "
		.. def.name .. " at " .. core.pos_to_string(place_to))

	-- Add node and update
	core.add_node(place_to, newnode)

	-- Play sound if it was done by a player
	if playername ~= "" and def.sounds and def.sounds.place then
		core.sound_play(def.sounds.place, {
			pos = place_to,
			exclude_player = playername,
		}, true)
	end

	local take_item = true

	-- Run callback
	if def.after_place_node and not prevent_after_place then
		-- Deepcopy place_to and pointed_thing because callback can modify it
		local place_to_copy = {x=place_to.x, y=place_to.y, z=place_to.z}
		local pointed_thing_copy = copy_pointed_thing(pointed_thing)
		if def.after_place_node(place_to_copy, placer, itemstack,
				pointed_thing_copy) then
			take_item = false
		end
	end

	-- Run script hook
	for _, callback in ipairs(core.registered_on_placenodes) do
		-- Deepcopy pos, node and pointed_thing because callback can modify them
		local place_to_copy = {x=place_to.x, y=place_to.y, z=place_to.z}
		local newnode_copy = {name=newnode.name, param1=newnode.param1, param2=newnode.param2}
		local oldnode_copy = {name=oldnode.name, param1=oldnode.param1, param2=oldnode.param2}
		local pointed_thing_copy = copy_pointed_thing(pointed_thing)
		if callback(place_to_copy, newnode_copy, placer, oldnode_copy, itemstack, pointed_thing_copy) then
			take_item = false
		end
	end

	if take_item then
		itemstack:take_item()
	end
	return itemstack, place_to
end

-- deprecated, item_place does not call this
function core.item_place_object(itemstack, placer, pointed_thing)
	local pos = core.get_pointed_thing_position(pointed_thing, true)
	if pos ~= nil then
		local item = itemstack:take_item()
		core.add_item(pos, item)
	end
	return itemstack
end

function core.item_place(itemstack, placer, pointed_thing, param2)
	-- Call on_rightclick if the pointed node defines it
	if pointed_thing.type == "node" and placer and
			not placer:get_player_control().sneak then
		local n = core.get_node(pointed_thing.under)
		local nn = n.name
		if core.registered_nodes[nn] and core.registered_nodes[nn].on_rightclick then
			return core.registered_nodes[nn].on_rightclick(pointed_thing.under, n,
					placer, itemstack, pointed_thing) or itemstack, nil
		end
	end

	-- Place if node, otherwise do nothing
	if itemstack:get_definition().type == "node" then
		return core.item_place_node(itemstack, placer, pointed_thing, param2)
	end
	return itemstack, nil
end

function core.item_secondary_use(itemstack, placer)
	return itemstack
end

function core.item_drop(itemstack, dropper, pos)
	local dropper_is_player = dropper and dropper:is_player()
	local p = table.copy(pos)
	local cnt = itemstack:get_count()
	if dropper_is_player then
		p.y = p.y + 1.2
	end
	local item = itemstack:take_item(cnt)
	local obj = core.add_item(p, item)
	if obj then
		if dropper_is_player then
			local dir = dropper:get_look_dir()
			dir.x = dir.x * 2.9
			dir.y = dir.y * 2.9 + 2
			dir.z = dir.z * 2.9
			obj:set_velocity(dir)
			obj:get_luaentity().dropped_by = dropper:get_player_name()
		end
		return itemstack
	end
	-- If we reach this, adding the object to the
	-- environment failed
end

function core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)
	for _, callback in pairs(core.registered_on_item_eats) do
		local result = callback(hp_change, replace_with_item, itemstack, user, pointed_thing)
		if result then
			return result
		end
	end
	local def = itemstack:get_definition()
	if itemstack:take_item() ~= nil then
		user:set_hp(user:get_hp() + hp_change)

		if def and def.sound and def.sound.eat then
			core.sound_play(def.sound.eat, {
				pos = user:get_pos(),
				max_hear_distance = 16
			}, true)
		end

		if replace_with_item then
			if itemstack:is_empty() then
				itemstack:add_item(replace_with_item)
			else
				local inv = user:get_inventory()
				-- Check if inv is null, since non-players don't have one
				if inv and inv:room_for_item("main", {name=replace_with_item}) then
					inv:add_item("main", replace_with_item)
				else
					local pos = user:get_pos()
					pos.y = math.floor(pos.y + 0.5)
					core.add_item(pos, replace_with_item)
				end
			end
		end
	end
	return itemstack
end

function core.item_eat(hp_change, replace_with_item)
	return function(itemstack, user, pointed_thing)  -- closure
		if user then
			return core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)
		end
	end
end

function core.node_punch(pos, node, puncher, pointed_thing)
	-- Run script hook
	for _, callback in ipairs(core.registered_on_punchnodes) do
		-- Copy pos and node because callback can modify them
		local pos_copy = vector.new(pos)