Prevent fake player crossbow shooting (#6)

Fix server crash when fake player attempts to shoot crossbow
This commit is contained in:
SX 2021-09-08 22:03:57 +03:00 committed by GitHub
parent d3cf09551a
commit d89b2519d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -368,6 +368,10 @@ minetest.register_entity("castle_weapons:crossbow_bolt_entity", {
inventory_image = "castle_crossbow_loaded.png",
groups = {not_in_creative_inventory=1},
on_use = function(itemstack, user, pointed_thing)
if type(user) ~= "userdata" then
-- Do not allow fake players to use crossbow
return itemstack
end
minetest.sound_play("castle_crossbow_click", {object=user})
if not minetest.settings:get_bool("creative_mode") then
itemstack:add_wear(65535/CROSSBOW_USES)