<commit_before>local itemframe, tmp = {}, {}
screwdriver = screwdriver or {}
minetest.register_alias("itemframes:frame", "xdecor:itemframe")--maikerumine added
minetest.register_alias("itemframes:item", "xdecor:f_item")--maikerumine added

local function remove_item(pos, node)
	local objs = minetest.get_objects_inside_radius(pos, 0.5)
	if not objs then return end

	for _, obj in pairs(objs) do
		if obj and obj:get_luaentity() and
				obj:get_luaentity().name == "xdecor:f_item" then
			obj:remove() break
		end
	end
end

local facedir = {
	[0] = {x=0, y=0, z=1}, {x=1, y=0, z=0}, {x=0, y=0, z=-1}, {x=-1, y=0, z=0}
}

local function update_item(pos, node)
	remove_item(pos, node)
	local meta = minetest.get_meta(pos)
	local itemstring = meta:get_string("item")
	local posad = facedir[node.param2]
	if not posad or itemstring == "" then return end

	pos = vector.add(pos, vector.multiply(posad, 6.5/16))
	tmp.nodename = node.name
	tmp.texture = ItemStack(itemstring):get_name()

	local entity = minetest.add_entity(pos, "xdecor:f_item")
	local yaw = math.pi*2 - node.param2 * math.pi/2
	entity:setyaw(yaw)

	local timer = minetest.get_node_timer(pos)
	timer:start(15.0)
end

local function drop_item(pos, node)
	local meta = minetest.get_meta(pos)
	local item = meta:get_string("item")
	if item == "" then return end

	minetest.add_item(pos, item)
	meta:set_string("item", "")
	remove_item(pos, node)

	local timer = minetest.get_node_timer(pos)
	timer:stop()
end

function itemframe.after_place(pos, placer, itemstack)
	local meta = minetest.get_meta(pos)
	--local name = placer:get_player_name()
	--meta:set_string("owner", name)
	--meta:set_string("infotext", "Item Frame (owned by "..name..")")
end

function itemframe.timer(pos)
	local node = minetest.get_node(pos)
	local meta = minetest.get_meta(pos)
	local num = #minetest.get_objects_inside_radius(pos, 0.5)

	if num == 0 and meta:get_string("item") ~= "" then
		update_item(pos, node)
	end
	return true
end

function itemframe.rightclick(pos, node, clicker, itemstack)
	local meta = minetest.get_meta(pos)
	local player = clicker:get_player_name()
	--local owner = meta:get_string("owner")
	--if player ~= owner or not itemstack then return end

	drop_item(pos, node)
	local itemstring = itemstack:take_item():to_string()
	meta:set_string("item", itemstring)
	update_item(pos, node)

	return itemstack
end

function itemframe.punch(pos, node, puncher)
	local meta = minetest.get_meta(pos)
	local player = puncher:get_player_name()
	--local owner = meta:get_string("owner")

	--if player ~= owner then return end
	drop_item(pos, node)
end

function itemframe.dig(pos, player)
	local meta = minetest.get_meta(pos)
	local pname = player:get_player_name()
	--local owner = meta:get_string("owner")

	return player-- and pname == owner
end

xdecor.register("itemframe", {
	description = "Item Frame",
	groups = {choppy=3, oddly_breakable_by_hand=2, flammable=3},
	sounds = default.node_sound_wood_defaults(),
	on_rotate = screwdriver.disallow,
	sunlight_propagates = true,
	inventory_image = "xdecor_itemframe.png",
	node_box = xdecor.nodebox.slab_z(0.9375),
	tiles = {"xdecor_wood.png", "xdecor_wood.png", "xdecor_wood.png",
		 "xdecor_wood.png", "xdecor_wood.png", "xdecor_itemframe.png"},
	after_place_node = itemframe.after_place,
	on_timer = itemframe.timer,
	on_rightclick = itemframe.rightclick,
	on_punch = itemframe.punch,
	can_dig = itemframe.dig,
	after_destruct = remove_item
})

minetest.register_entity("xdecor:f_item", {<commit_msg>max stack 64<commit_after>local itemframe, tmp = {}, {}
screwdriver = screwdriver or {}
minetest.register_alias("itemframes:frame", "xdecor:itemframe")--maikerumine added
minetest.register_alias("itemframes:item", "xdecor:f_item")--maikerumine added

local function remove_item(pos, node)
	local objs = minetest.get_objects_inside_radius(pos, 0.5)
	if not objs then return end

	for _, obj in pairs(objs) do
		if obj and obj:get_luaentity() and
				obj:get_luaentity().name == "xdecor:f_item" then
			obj:remove() break
		end
	end
end

local facedir = {
	[0] = {x=0, y=0, z=1}, {x=1, y=0, z=0}, {x=0, y=0, z=-1}, {x=-1, y=0, z=0}
}

local function update_item(pos, node)
	remove_item(pos, node)
	local meta = minetest.get_meta(pos)
	local itemstring = meta:get_string("item")
	local posad = facedir[node.param2]
	if not posad or itemstring == "" then return end

	pos = vector.add(pos, vector.multiply(posad, 6.5/16))
	tmp.nodename = node.name
	tmp.texture = ItemStack(itemstring):get_name()

	local entity = minetest.add_entity(pos, "xdecor:f_item")
	local yaw = math.pi*2 - node.param2 * math.pi/2
	entity:setyaw(yaw)

	local timer = minetest.get_node_timer(pos)
	timer:start(15.0)
end

local function drop_item(pos, node)
	local meta = minetest.get_meta(pos)
	local item = meta:get_string("item")
	if item == "" then return end

	minetest.add_item(pos, item)
	meta:set_string("item", "")
	remove_item(pos, node)

	local timer = minetest.get_node_timer(pos)
	timer:stop()
end

function itemframe.after_place(pos, placer, itemstack)
	local meta = minetest.get_meta(pos)
	--local name = placer:get_player_name()
	--meta:set_string("owner", name)
	--meta:set_string("infotext", "Item Frame (owned by "..name..")")
end

function itemframe.timer(pos)
	local node = minetest.get_node(pos)
	local meta = minetest.get_meta(pos)
	local num = #minetest.get_objects_inside_radius(pos, 0.5)

	if num == 0 and meta:get_string("item") ~= "" then
		update_item(pos, node)
	end
	return true
end

function itemframe.rightclick(pos, node, clicker, itemstack)
	local meta = minetest.get_meta(pos)
	local player = clicker:get_player_name()
	--local owner = meta:get_string("owner")
	--if player ~= owner or not itemstack then return end

	drop_item(pos, node)
	local itemstring = itemstack:take_item():to_string()
	meta:set_string("item", itemstring)
	update_item(pos, node)

	return itemstack
end

function itemframe.punch(pos, node, puncher)
	local meta = minetest.get_meta(pos)
	local player = puncher:get_player_name()
	--local owner = meta:get_string("owner")

	--if player ~= owner then return end
	drop_item(pos, node)
end

function itemframe.dig(pos, player)
	local meta = minetest.get_meta(pos)
	local pname = player:get_player_name()
	--local owner = meta:get_string("owner")

	return player-- and pname == owner
end

xdecor.register("itemframe", {
	description = "Item Frame",
	groups = {choppy=3, oddly_breakable_by_hand=2, flammable=3},
	stack_max = 64,
	sounds = default.node_sound_wood_defaults(),
	on_rotate = screwdriver.disallow,
	sunlight_propagates = true,
	inventory_image = "xdecor_itemframe.png",
	node_box = xdecor.nodebox.slab_z(0.9375),
	tiles = {"xdecor_wood.png", "xdecor_wood.png", "xdecor_wood.png",
		 "xdecor_wood.png", "xdecor_wood.png", "xdecor_itemframe.png"},
	after_place_node = itemframe.after_place,
	on_timer = itemframe.timer,
	on_rightclick = itemframe.rightclick,
	on_punch = itemframe.punch,
	can_dig = itemframe.dig,
	after_destruct = remove_item
})

minetest.register_entity("xdecor:f_item", {
{'fraction_non_alphanumeric': 0.13606604042129233, 'fraction_numerical': 0.011101622544833475, 'mean_word_length': 5.405651777575205, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7130561', 'n_tokens_mistral': 2711, 'n_tokens_neox': 2642, 'n_words': 576}