1
0
mirror of https://github.com/minetest/minetest_game.git synced 2025-06-28 04:40:22 +02:00

Use Minetest 5.3 'minetest.is_creative_enabled' API (#2795)

This commit is contained in:
Maksim
2020-12-13 18:59:19 +01:00
committed by GitHub
parent 9c29019301
commit e6aec880de
19 changed files with 34 additions and 65 deletions

View File

@ -45,12 +45,14 @@ farming.hoe_on_use = function(itemstack, user, pointed_thing, uses)
return
end
if minetest.is_protected(pt.under, user:get_player_name()) then
minetest.record_protection_violation(pt.under, user:get_player_name())
local player_name = user and user:get_player_name() or ""
if minetest.is_protected(pt.under, player_name) then
minetest.record_protection_violation(pt.under, player_name)
return
end
if minetest.is_protected(pt.above, user:get_player_name()) then
minetest.record_protection_violation(pt.above, user:get_player_name())
if minetest.is_protected(pt.above, player_name) then
minetest.record_protection_violation(pt.above, player_name)
return
end
@ -61,8 +63,7 @@ farming.hoe_on_use = function(itemstack, user, pointed_thing, uses)
gain = 0.5,
}, true)
if not (creative and creative.is_enabled_for
and creative.is_enabled_for(user:get_player_name())) then
if not minetest.is_creative_enabled(player_name) then
-- wear tool
local wdef = itemstack:get_definition()
itemstack:add_wear(65535/(uses-1))
@ -181,8 +182,7 @@ farming.place_seed = function(itemstack, placer, pointed_thing, plantname)
minetest.pos_to_string(pt.above))
minetest.add_node(pt.above, {name = plantname, param2 = 1})
tick(pt.above)
if not (creative and creative.is_enabled_for
and creative.is_enabled_for(player_name)) then
if not minetest.is_creative_enabled(player_name) then
itemstack:take_item()
end
return itemstack