From c106a62979b50b90305e8ec9071ca9852840dab6 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 10 Jul 2020 16:08:40 +0200 Subject: [PATCH] Use minetest.is_creative_enabled --- mods/CORE/mcl_explosions/init.lua | 8 +++--- mods/CORE/mcl_util/init.lua | 2 +- mods/ENTITIES/mcl_boats/init.lua | 4 +-- mods/ENTITIES/mcl_item_entity/init.lua | 2 +- mods/ENTITIES/mcl_minecarts/init.lua | 25 +++++++++++++------ mods/ENTITIES/mcl_mobs/api.lua | 10 +++----- mods/ENTITIES/mcl_paintings/init.lua | 8 ++++-- mods/ENTITIES/mobs_mc/1_items_default.lua | 2 +- mods/ENTITIES/mobs_mc/2_throwing.lua | 8 +++--- mods/ENTITIES/mobs_mc/cow+mooshroom.lua | 2 +- mods/ENTITIES/mobs_mc/creeper.lua | 2 +- mods/ENTITIES/mobs_mc/horse.lua | 4 +-- mods/ENTITIES/mobs_mc/llama.lua | 2 +- mods/ENTITIES/mobs_mc/ocelot.lua | 2 +- mods/ENTITIES/mobs_mc/parrot.lua | 2 +- mods/ENTITIES/mobs_mc/pig.lua | 4 +-- mods/ENTITIES/mobs_mc/sheep.lua | 4 +-- mods/ENTITIES/mobs_mc/silverfish.lua | 2 +- mods/ENTITIES/mobs_mc/snowman.lua | 2 +- mods/ENTITIES/mobs_mc/wolf.lua | 6 ++--- mods/HUD/mcl_inventory/creative.lua | 11 ++++---- mods/HUD/mcl_inventory/init.lua | 10 ++++---- .../REDSTONE/mesecons_commandblock/init.lua | 4 +-- mods/ITEMS/mcl_banners/init.lua | 2 +- mods/ITEMS/mcl_beds/api.lua | 2 +- mods/ITEMS/mcl_bows/arrow.lua | 4 +-- mods/ITEMS/mcl_bows/bow.lua | 7 +++--- mods/ITEMS/mcl_buckets/init.lua | 10 ++++---- mods/ITEMS/mcl_cake/init.lua | 6 ++--- mods/ITEMS/mcl_chests/init.lua | 4 +-- mods/ITEMS/mcl_cocoas/init.lua | 2 +- mods/ITEMS/mcl_doors/api_doors.lua | 2 +- mods/ITEMS/mcl_dye/init.lua | 2 +- mods/ITEMS/mcl_end/chorus_plant.lua | 2 +- mods/ITEMS/mcl_end/eye_of_ender.lua | 4 +-- mods/ITEMS/mcl_farming/hoes.lua | 2 +- mods/ITEMS/mcl_farming/shared_functions.lua | 2 +- mods/ITEMS/mcl_fire/fire_charge.lua | 2 +- mods/ITEMS/mcl_fire/flint_and_steel.lua | 6 ++--- mods/ITEMS/mcl_fishing/init.lua | 5 ++-- mods/ITEMS/mcl_flowerpots/init.lua | 4 +-- mods/ITEMS/mcl_flowers/init.lua | 4 +-- mods/ITEMS/mcl_itemframes/init.lua | 4 +-- mods/ITEMS/mcl_maps/init.lua | 4 +-- mods/ITEMS/mcl_mobitems/init.lua | 2 +- mods/ITEMS/mcl_monster_eggs/init.lua | 2 +- mods/ITEMS/mcl_nether/nether_wart.lua | 2 +- mods/ITEMS/mcl_ocean/corals.lua | 2 +- mods/ITEMS/mcl_ocean/kelp.lua | 2 +- mods/ITEMS/mcl_ocean/sea_pickle.lua | 2 +- mods/ITEMS/mcl_ocean/seagrass.lua | 2 +- mods/ITEMS/mcl_portals/portal_end.lua | 2 +- mods/ITEMS/mcl_potions/init.lua | 6 ++--- mods/ITEMS/mcl_potions/lingering.lua | 2 +- mods/ITEMS/mcl_potions/splash.lua | 2 +- mods/ITEMS/mcl_signs/init.lua | 2 +- mods/ITEMS/mcl_sponges/init.lua | 2 +- mods/ITEMS/mcl_stairs/api.lua | 2 +- mods/ITEMS/mcl_throwing/init.lua | 2 +- mods/ITEMS/mcl_tools/init.lua | 6 ++--- mods/ITEMS/screwdriver/init.lua | 2 +- mods/PLAYER/mcl_hunger/hunger.lua | 4 +-- 62 files changed, 133 insertions(+), 119 deletions(-) diff --git a/mods/CORE/mcl_explosions/init.lua b/mods/CORE/mcl_explosions/init.lua index 2c7e69cdc9..9962f865d1 100644 --- a/mods/CORE/mcl_explosions/init.lua +++ b/mods/CORE/mcl_explosions/init.lua @@ -12,7 +12,6 @@ under the LGPLv2.1 license. mcl_explosions = {} -local creative_mode = minetest.settings:get_bool("creative_mode") local mod_death_messages = minetest.get_modpath("mcl_death_messages") ~= nil local mod_fire = minetest.get_modpath("mcl_fire") ~= nil local CONTENT_FIRE = minetest.get_content_id("mcl_fire:fire") @@ -143,7 +142,7 @@ end -- Note that this function has been optimized, it contains code which has been -- inlined to avoid function calls and unnecessary table creation. This was -- measured to give a significant performance increase. -local function trace_explode(pos, strength, raydirs, radius, drop_chance, fire, puncher) +local function trace_explode(pos, strength, raydirs, radius, drop_chance, fire, puncher, creative_enabled) local vm = minetest.get_voxel_manip() local emin, emax = vm:read_from_map(vector.subtract(pos, radius), @@ -308,7 +307,7 @@ local function trace_explode(pos, strength, raydirs, radius, drop_chance, fire, -- Remove destroyed blocks and drop items for hash, idx in pairs(destroy) do - local do_drop = not creative_mode and math.random() <= drop_chance + local do_drop = not creative_enabled and math.random() <= drop_chance local on_blast = node_on_blast[data[idx]] local remove = true @@ -384,7 +383,8 @@ function mcl_explosions.explode(pos, strength, info, puncher) end local shape = sphere_shapes[radius] - trace_explode(pos, strength, shape, radius, (info and info.drop_chance) or 1 / strength, info.fire == true, puncher) + local creative_enabled = minetest.is_creative_enabled("") + trace_explode(pos, strength, shape, radius, (info and info.drop_chance) or 1 / strength, info.fire == true, puncher, creative_enabled) if not (info and info.no_sound) then add_particles(pos, radius) diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index 6a74bb69ce..7e85133655 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -92,7 +92,7 @@ end -- Similar to minetest.rotate_node. function mcl_util.rotate_axis(itemstack, placer, pointed_thing) mcl_util.rotate_axis_and_place(itemstack, placer, pointed_thing, - minetest.settings:get_bool("creative_mode"), + minetest.is_creative_enabled(placer:get_player_name()), placer:get_player_control().sneak) return itemstack end diff --git a/mods/ENTITIES/mcl_boats/init.lua b/mods/ENTITIES/mcl_boats/init.lua index 6c0ad9a1bf..9d0e455572 100644 --- a/mods/ENTITIES/mcl_boats/init.lua +++ b/mods/ENTITIES/mcl_boats/init.lua @@ -133,7 +133,7 @@ function boat.on_punch(self, puncher) if not self._driver then self._removed = true -- Drop boat as item on the ground after punching - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(puncher:get_player_name()) then minetest.add_item(self.object:get_pos(), self._itemstring) else local inv = puncher:get_inventory() @@ -328,7 +328,7 @@ for b=1, #boat_ids do boat:get_luaentity()._itemstring = itemstring boat:set_properties({textures = { "mcl_boats_texture_"..images[b].."_boat.png" }}) boat:set_yaw(placer:get_look_horizontal()) - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(placer:get_player_name()) then itemstack:take_item() end return itemstack diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index 7e10babc5e..a6f3fe1103 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -213,7 +213,7 @@ function minetest.handle_node_drops(pos, drops, digger) -- by hand. Creative Mode is intentionally ignored in this case. local doTileDrops = minetest.settings:get_bool("mcl_doTileDrops", true) - if (digger ~= nil and minetest.settings:get_bool("creative_mode")) or doTileDrops == false then + if (digger ~= nil and minetest.is_creative_enabled(digger:get_player_name())) or doTileDrops == false then return end diff --git a/mods/ENTITIES/mcl_minecarts/init.lua b/mods/ENTITIES/mcl_minecarts/init.lua index f3203cf265..dc617281b3 100644 --- a/mods/ENTITIES/mcl_minecarts/init.lua +++ b/mods/ENTITIES/mcl_minecarts/init.lua @@ -133,7 +133,7 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o end -- Drop items and remove cart entity - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(puncher:get_player_name()) then for d=1, #drop do minetest.add_item(self.object:get_pos(), drop[d]) end @@ -190,13 +190,14 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o node = minetest.get_node(rou_pos) local g = minetest.get_item_group(node.name, "connect_to_raillike") if g ~= self._railtype and self._railtype ~= nil then + local player -- Detach driver if self._driver then if self._old_pos then self.object:set_pos(self._old_pos) end mcl_player.player_attached[self._driver] = nil - local player = minetest.get_player_by_name(self._driver) + player = minetest.get_player_by_name(self._driver) if player then player:set_detach() player:set_eye_offset({x=0, y=0, z=0},{x=0, y=0, z=0}) @@ -211,7 +212,11 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o end -- Drop items and remove cart entity - if not minetest.settings:get_bool("creative_mode") then + local pname = "" + if player then + pname = player:get_player_name() + end + if not minetest.is_creative_enabled(pname) then for d=1, #drop do minetest.add_item(self.object:get_pos(), drop[d]) end @@ -486,7 +491,7 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o end -- Place a minecart at pointed_thing -mcl_minecarts.place_minecart = function(itemstack, pointed_thing) +mcl_minecarts.place_minecart = function(itemstack, pointed_thing, placer) if not pointed_thing.type == "node" then return end @@ -519,7 +524,11 @@ mcl_minecarts.place_minecart = function(itemstack, pointed_thing) local cart_dir = mcl_minecarts:get_rail_direction(railpos, {x=1, y=0, z=0}, nil, nil, railtype) cart:set_yaw(minetest.dir_to_yaw(cart_dir)) - if not minetest.settings:get_bool("creative_mode") then + local pname = "" + if placer then + pname = placer:get_player_name() + end + if not minetest.is_creative_enabled(pname) then itemstack:take_item() end return itemstack @@ -548,7 +557,7 @@ local register_craftitem = function(itemstring, entity_id, description, tt_help, end end - return mcl_minecarts.place_minecart(itemstack, pointed_thing) + return mcl_minecarts.place_minecart(itemstack, pointed_thing, placer) end, _on_dispense = function(stack, pos, droppos, dropnode, dropdir) -- Place minecart as entity on rail. If there's no rail, just drop it. @@ -683,7 +692,7 @@ register_minecart( if minetest.get_item_group(held:get_name(), "coal") == 1 then self._fueltime = self._fueltime + 180 - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(clicker:get_player_name()) then held:take_item() local index = clicker:get_wield_index() local inv = clicker:get_inventory() @@ -773,7 +782,7 @@ register_minecart( end local held = clicker:get_wielded_item() if held:get_name() == "mcl_fire:flint_and_steel" then - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(clicker:get_player_name()) then held:add_wear(65535/65) -- 65 uses local index = clicker:get_wield_index() local inv = clicker:get_inventory() diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 5f44d656ff..2533abdb9b 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -28,9 +28,8 @@ end -- creative check -local creative_mode_cache = minetest.settings:get_bool("creative_mode") function mobs.is_creative(name) - return creative_mode_cache or minetest.check_player_privs(name, {creative = true}) + return minetest.is_creative_enabled(name) end @@ -60,7 +59,6 @@ local mobs_spawn = minetest.settings:get_bool("mobs_spawn", true) ~= false local disable_blood = minetest.settings:get_bool("mobs_disable_blood") local mobs_drop_items = minetest.settings:get_bool("mobs_drop_items") ~= false local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false -local creative = minetest.settings:get_bool("creative_mode") local spawn_protected = minetest.settings:get_bool("mobs_spawn_protected") ~= false local remove_far = false local difficulty = tonumber(minetest.settings:get("mob_difficulty")) or 1.0 @@ -1600,7 +1598,7 @@ local monster_attack = function(self) if self.type ~= "monster" or not damage_enabled - or creative + or minetest.is_creative_enabled("") or self.state == "attack" or day_docile(self) then return @@ -2674,7 +2672,7 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir) -- add weapon wear manually -- Required because we have custom health handling ("health" property) - if minetest.settings:get_bool("creative_mode") ~= true + if minetest.is_creative_enabled("") ~= true and tool_capabilities then if tool_capabilities.punch_attack_uses then -- Without this delay, the wear does not work. Quite hacky ... @@ -3933,7 +3931,7 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative) return itemstack end mcl_mobspawners.setup_spawner(pointed_thing.under, itemstack:get_name()) - if not minetest.settings:get_bool("creative_mode") then + if not mobs.is_creative(name) then itemstack:take_item() end return itemstack diff --git a/mods/ENTITIES/mcl_paintings/init.lua b/mods/ENTITIES/mcl_paintings/init.lua index ea52ae1734..25811d87db 100644 --- a/mods/ENTITIES/mcl_paintings/init.lua +++ b/mods/ENTITIES/mcl_paintings/init.lua @@ -167,7 +167,11 @@ minetest.register_entity("mcl_paintings:painting", { end, on_death = function(self, killer) -- Drop as item on death - if not minetest.settings:get_bool("creative_mode") then + local kname = "" + if killer and killer:is_player() then + kname = killer:get_player_name() + end + if not minetest.is_creative_enabled(kname) then local pos = self._pos if not pos then pos = self.object:get_pos() @@ -279,7 +283,7 @@ minetest.register_craftitem("mcl_paintings:painting", { else return itemstack end - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(placer:get_player_name()) then itemstack:take_item() end return itemstack diff --git a/mods/ENTITIES/mobs_mc/1_items_default.lua b/mods/ENTITIES/mobs_mc/1_items_default.lua index 1085235a89..ddcc290c73 100644 --- a/mods/ENTITIES/mobs_mc/1_items_default.lua +++ b/mods/ENTITIES/mobs_mc/1_items_default.lua @@ -552,7 +552,7 @@ if c("totem") then if player:get_breath() < 11 then player:set_breath(10) end - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(player:get_player_name()) then wield:take_item() player:set_wielded_item(wield) end diff --git a/mods/ENTITIES/mobs_mc/2_throwing.lua b/mods/ENTITIES/mobs_mc/2_throwing.lua index 089e39ca94..e868cb060e 100644 --- a/mods/ENTITIES/mobs_mc/2_throwing.lua +++ b/mods/ENTITIES/mobs_mc/2_throwing.lua @@ -123,7 +123,7 @@ local arrows = { local throwing_shoot_arrow = function(itemstack, player) for _,arrow in ipairs(arrows) do if player:get_inventory():get_stack("main", player:get_wield_index()+1):get_name() == arrow[1] then - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(player:get_player_name()) then player:get_inventory():remove_item("main", arrow[1]) end local playerpos = player:get_pos() @@ -171,7 +171,7 @@ if c("bow") then inventory_image = "mcl_bows_bow.png", on_use = function(itemstack, user, pointed_thing) if throwing_shoot_arrow(itemstack, user, pointed_thing) then - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(user:get_player_name()) then itemstack:add_wear(65535/50) end end @@ -296,7 +296,7 @@ if c("egg") then local ent2 = obj:get_luaentity() ent2.playername = player:get_player_name() - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(player:get_player_name()) then item:take_item() end @@ -380,7 +380,7 @@ if c("snowball") then local ent2 = obj:get_luaentity() ent2.playername = player:get_player_name() - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(player:get_player_name()) then item:take_item() end diff --git a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua index 58d2cd58dc..cb5bb029ac 100644 --- a/mods/ENTITIES/mobs_mc/cow+mooshroom.lua +++ b/mods/ENTITIES/mobs_mc/cow+mooshroom.lua @@ -101,7 +101,7 @@ mooshroom_def.on_rightclick = function(self, clicker) local cow = minetest.add_entity(pos, "mobs_mc:cow") cow:set_yaw(oldyaw) - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(clicker:get_player_name()) then item:add_wear(mobs_mc.misc.shears_wear) clicker:get_inventory():set_stack("main", clicker:get_wield_index(), item) end diff --git a/mods/ENTITIES/mobs_mc/creeper.lua b/mods/ENTITIES/mobs_mc/creeper.lua index e5ff688c4d..c1d582bb0b 100644 --- a/mods/ENTITIES/mobs_mc/creeper.lua +++ b/mods/ENTITIES/mobs_mc/creeper.lua @@ -51,7 +51,7 @@ mobs:register_mob("mobs_mc:creeper", { end local item = clicker:get_wielded_item() if item:get_name() == mobs_mc.items.flint_and_steel then - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(clicker:get_player_name()) then -- Wear tool local wdef = item:get_definition() item:add_wear(1000) diff --git a/mods/ENTITIES/mobs_mc/horse.lua b/mods/ENTITIES/mobs_mc/horse.lua index 664a1ca857..aff938aa48 100644 --- a/mods/ENTITIES/mobs_mc/horse.lua +++ b/mods/ENTITIES/mobs_mc/horse.lua @@ -233,7 +233,7 @@ local horse = { -- Put on saddle and take saddle from player's inventory local w = clicker:get_wielded_item() self._saddle = true - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(clicker:get_player_name()) then w:take_item() clicker:set_wielded_item(w) end @@ -257,7 +257,7 @@ local horse = { local armor = minetest.get_item_group(iname, "horse_armor") self._horse_armor = iname local w = clicker:get_wielded_item() - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(clicker:get_player_name()) then w:take_item() clicker:set_wielded_item(w) end diff --git a/mods/ENTITIES/mobs_mc/llama.lua b/mods/ENTITIES/mobs_mc/llama.lua index dd2d85a376..8215dcfd16 100644 --- a/mods/ENTITIES/mobs_mc/llama.lua +++ b/mods/ENTITIES/mobs_mc/llama.lua @@ -135,7 +135,7 @@ mobs:register_mob("mobs_mc:llama", { if minetest.get_item_group(item:get_name(), "carpet") == 1 and not self.carpet then for group, carpetdata in pairs(carpets) do if minetest.get_item_group(item:get_name(), group) == 1 then - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(clicker:get_player_name()) then item:take_item() clicker:set_wielded_item(item) end diff --git a/mods/ENTITIES/mobs_mc/ocelot.lua b/mods/ENTITIES/mobs_mc/ocelot.lua index 5a9525a092..5d7fe3bc24 100644 --- a/mods/ENTITIES/mobs_mc/ocelot.lua +++ b/mods/ENTITIES/mobs_mc/ocelot.lua @@ -74,7 +74,7 @@ local ocelot = { -- Try to tame ocelot (mobs:feed_tame is intentionally NOT used) local item = clicker:get_wielded_item() if is_food(item:get_name()) then - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(clicker:get_player_name()) then item:take_item() clicker:set_wielded_item(item) end diff --git a/mods/ENTITIES/mobs_mc/parrot.lua b/mods/ENTITIES/mobs_mc/parrot.lua index 080bddd487..a6a2a276d5 100644 --- a/mods/ENTITIES/mobs_mc/parrot.lua +++ b/mods/ENTITIES/mobs_mc/parrot.lua @@ -64,7 +64,7 @@ mobs:register_mob("mobs_mc:parrot", { self.health = 0 -- Doomed to die self._doomed = true - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(clicker:get_player_name()) then item:take_item() clicker:set_wielded_item(item) end diff --git a/mods/ENTITIES/mobs_mc/pig.lua b/mods/ENTITIES/mobs_mc/pig.lua index 05e6a0859b..ebb3f7aa4f 100644 --- a/mods/ENTITIES/mobs_mc/pig.lua +++ b/mods/ENTITIES/mobs_mc/pig.lua @@ -120,7 +120,7 @@ mobs:register_mob("mobs_mc:pig", { min = 1, max = 1,}, } - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(clicker:get_player_name()) then local inv = clicker:get_inventory() local stack = inv:get_stack("main", clicker:get_wield_index()) stack:take_item() @@ -142,7 +142,7 @@ mobs:register_mob("mobs_mc:pig", { mobs.attach(self, clicker) - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(clicker:get_player_name()) then local inv = self.driver:get_inventory() -- 26 uses diff --git a/mods/ENTITIES/mobs_mc/sheep.lua b/mods/ENTITIES/mobs_mc/sheep.lua index 94c2d48c9c..a0c0a8a084 100644 --- a/mods/ENTITIES/mobs_mc/sheep.lua +++ b/mods/ENTITIES/mobs_mc/sheep.lua @@ -166,7 +166,7 @@ mobs:register_mob("mobs_mc:sheep", { self.object:set_properties({ textures = self.base_texture, }) - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(clicker:get_player_name()) then item:add_wear(mobs_mc.misc.shears_wear) clicker:get_inventory():set_stack("main", clicker:get_wield_index(), item) end @@ -183,7 +183,7 @@ mobs:register_mob("mobs_mc:sheep", { minetest.log("verbose", "[mobs_mc] " ..item:get_name() .. " " .. minetest.get_item_group(item:get_name(), "dye")) for group, colordata in pairs(colors) do if minetest.get_item_group(item:get_name(), group) == 1 then - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(clicker:get_player_name()) then item:take_item() clicker:set_wielded_item(item) end diff --git a/mods/ENTITIES/mobs_mc/silverfish.lua b/mods/ENTITIES/mobs_mc/silverfish.lua index a6baf1e466..ca45734457 100644 --- a/mods/ENTITIES/mobs_mc/silverfish.lua +++ b/mods/ENTITIES/mobs_mc/silverfish.lua @@ -50,7 +50,7 @@ mobs:register_egg("mobs_mc:silverfish", S("Silverfish"), "mobs_mc_spawn_icon_sil -- Monster egg blocks (Minetest Game) if minetest.get_modpath("default") and mobs_mc.create_monster_egg_nodes then local spawn_silverfish = function(pos, oldnode, oldmetadata, digger) - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(digger:get_player_name()) then minetest.add_entity(pos, "mobs_mc:silverfish") end end diff --git a/mods/ENTITIES/mobs_mc/snowman.lua b/mods/ENTITIES/mobs_mc/snowman.lua index fd3947d7f7..b9686ba571 100644 --- a/mods/ENTITIES/mobs_mc/snowman.lua +++ b/mods/ENTITIES/mobs_mc/snowman.lua @@ -119,7 +119,7 @@ mobs:register_mob("mobs_mc:snowman", { minetest.sound_play("shears", {pos = pos}, true) -- Wear out - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(clicker:get_player_name()) then item:add_wear(mobs_mc.misc.shears_wear) clicker:get_inventory():set_stack("main", clicker:get_wield_index(), item) end diff --git a/mods/ENTITIES/mobs_mc/wolf.lua b/mods/ENTITIES/mobs_mc/wolf.lua index 54bb0d41f9..e99853655b 100644 --- a/mods/ENTITIES/mobs_mc/wolf.lua +++ b/mods/ENTITIES/mobs_mc/wolf.lua @@ -53,7 +53,7 @@ local wolf = { local dog, ent if tool:get_name() == mobs_mc.items.bone then - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(clicker:get_player_name()) then tool:take_item() clicker:set_wielded_item(tool) end @@ -154,7 +154,7 @@ dog.on_rightclick = function(self, clicker) if new_hp > self.hp_max then new_hp = self.hp_max end - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(clicker:get_player_name()) then item:take_item() clicker:set_wielded_item(item) end @@ -172,7 +172,7 @@ dog.on_rightclick = function(self, clicker) self.object:set_properties({ textures = self.base_texture }) - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(clicker:get_player_name()) then item:take_item() clicker:set_wielded_item(item) end diff --git a/mods/HUD/mcl_inventory/creative.lua b/mods/HUD/mcl_inventory/creative.lua index 5df62b7ade..a63c85548f 100644 --- a/mods/HUD/mcl_inventory/creative.lua +++ b/mods/HUD/mcl_inventory/creative.lua @@ -128,7 +128,7 @@ local function init(player) local playername = player:get_player_name() local inv = minetest.create_detached_inventory("creative_"..playername, { allow_move = function(inv, from_list, from_index, to_list, to_index, count, player) - if minetest.settings:get_bool("creative_mode") then + if minetest.is_creative_enabled(playername) then return count else return 0 @@ -138,7 +138,7 @@ local function init(player) return 0 end, allow_take = function(inv, listname, index, stack, player) - if minetest.settings:get_bool("creative_mode") then + if minetest.is_creative_enabled(player:get_player_name()) then return -1 else return 0 @@ -151,7 +151,7 @@ end -- Create the trash field local trash = minetest.create_detached_inventory("trash", { allow_put = function(inv, listname, index, stack, player) - if minetest.settings:get_bool("creative_mode") then + if minetest.is_creative_enabled(player:get_player_name()) then return stack:get_count() else return 0 @@ -459,7 +459,8 @@ end minetest.register_on_player_receive_fields(function(player, formname, fields) local page = nil - if not minetest.settings:get_bool("creative_mode") then + + if not minetest.is_creative_enabled(player:get_player_name()) then return end if formname ~= "" or fields.quit == "true" then @@ -579,7 +580,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end) -if minetest.settings:get_bool("creative_mode") then +if minetest.is_creative_enabled("") then minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack) -- Place infinite nodes, except for shulker boxes local group = minetest.get_item_group(itemstack:get_name(), "shulker_box") diff --git a/mods/HUD/mcl_inventory/init.lua b/mods/HUD/mcl_inventory/init.lua index e6a1f14603..c358754f4d 100644 --- a/mods/HUD/mcl_inventory/init.lua +++ b/mods/HUD/mcl_inventory/init.lua @@ -46,7 +46,7 @@ local function return_fields(player, name) end local function set_inventory(player, armor_change_only) - if minetest.settings:get_bool("creative_mode") then + if minetest.is_creative_enabled(player:get_player_name()) then if armor_change_only then -- Stay on survival inventory plage if only the armor has been changed mcl_inventory.set_creative_formspec(player, 0, 0, nil, nil, "inv") @@ -137,13 +137,13 @@ end minetest.register_on_player_receive_fields(function(player, formname, fields) if fields.quit then return_fields(player,"craft") - if not minetest.settings:get_bool("creative_mode") and (formname == "" or formname == "main") then + if not minetest.is_creative_enabled(player:get_player_name()) and (formname == "" or formname == "main") then set_inventory(player) end end end) -if not minetest.settings:get_bool("creative_mode") then +if not minetest.is_creative_enabled("") then mcl_inventory.update_inventory_formspec = function(player) set_inventory(player) end @@ -180,7 +180,7 @@ minetest.register_on_joinplayer(function(player) end -- In Creative Mode, the initial inventory setup is handled in creative.lua - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(player:get_player_name()) then set_inventory(player) end @@ -191,7 +191,7 @@ minetest.register_on_joinplayer(function(player) return_fields(player, "craft") end) -if minetest.settings:get_bool("creative_mode") then +if minetest.is_creative_enabled("") then dofile(minetest.get_modpath("mcl_inventory").."/creative.lua") end diff --git a/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua b/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua index 44db17a4af..400c5e9b12 100644 --- a/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_commandblock/init.lua @@ -131,7 +131,7 @@ end local on_rightclick = function(pos, node, player, itemstack, pointed_thing) local can_edit = true -- Only allow write access in Creative Mode - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(player:get_player_name()) then can_edit = false end local pname = player:get_player_name() @@ -285,7 +285,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) if index ~= nil and x ~= nil and y ~= nil and z ~= nil then local pos = {x=tonumber(x), y=tonumber(y), z=tonumber(z)} local meta = minetest.get_meta(pos) - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(player:get_player_name()) then minetest.chat_send_player(player:get_player_name(), S("Editing the command block has failed! You can only change the command block in Creative Mode!")) return end diff --git a/mods/ITEMS/mcl_banners/init.lua b/mods/ITEMS/mcl_banners/init.lua index 57adbed863..ce76f47fd7 100644 --- a/mods/ITEMS/mcl_banners/init.lua +++ b/mods/ITEMS/mcl_banners/init.lua @@ -455,7 +455,7 @@ for colorid, colortab in pairs(mcl_banners.colors) do banner_entity:set_yaw(final_yaw) end - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(placer:get_player_name()) then itemstack:take_item() end minetest.sound_play({name="default_place_node_hard", gain=1.0}, {pos = place_pos}, true) diff --git a/mods/ITEMS/mcl_beds/api.lua b/mods/ITEMS/mcl_beds/api.lua index 7f11cf962b..aadb716b57 100644 --- a/mods/ITEMS/mcl_beds/api.lua +++ b/mods/ITEMS/mcl_beds/api.lua @@ -133,7 +133,7 @@ function mcl_beds.register_bed(name, def) minetest.set_node(pos, {name = name .. "_bottom", param2 = dir}) minetest.set_node(botpos, {name = name .. "_top", param2 = dir}) - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(placer:get_player_name()) then itemstack:take_item() end return itemstack diff --git a/mods/ITEMS/mcl_bows/arrow.lua b/mods/ITEMS/mcl_bows/arrow.lua index 9ae6e85a4b..6b901bbe92 100644 --- a/mods/ITEMS/mcl_bows/arrow.lua +++ b/mods/ITEMS/mcl_bows/arrow.lua @@ -99,7 +99,7 @@ local ARROW_ENTITY={ -- Destroy arrow entity self at pos and drops it as an item local spawn_item = function(self, pos) - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled("") then local item = minetest.add_item(pos, "mcl_bows:arrow") item:set_velocity({x=0, y=0, z=0}) item:set_yaw(self.object:get_yaw()) @@ -138,7 +138,7 @@ ARROW_ENTITY.on_step = function(self, dtime) local objects = minetest.get_objects_inside_radius(pos, 1) for _,obj in ipairs(objects) do if obj:is_player() then - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(obj:get_player_name()) then if obj:get_inventory():room_for_item("main", "mcl_bows:arrow") then obj:get_inventory():add_item("main", "mcl_bows:arrow") minetest.sound_play("item_drop_pickup", { diff --git a/mods/ITEMS/mcl_bows/bow.lua b/mods/ITEMS/mcl_bows/bow.lua index 3bae7687cd..d6fa4cf0b9 100644 --- a/mods/ITEMS/mcl_bows/bow.lua +++ b/mods/ITEMS/mcl_bows/bow.lua @@ -75,7 +75,7 @@ end local player_shoot_arrow = function(itemstack, player, power, damage) local arrow_stack, arrow_stack_id = get_arrow(player) local arrow_itemstring - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(player:get_player_name()) then if not arrow_stack then return false end @@ -209,7 +209,7 @@ controls.register_on_release(function(player, key, time) has_shot = player_shoot_arrow(wielditem, player, speed, damage) wielditem:set_name("mcl_bows:bow") - if has_shot and minetest.settings:get_bool("creative_mode") == false then + if has_shot and not minetest.is_creative_enabled(player:get_player_name()) then wielditem:add_wear(65535/BOW_DURABILITY) end player:set_wielded_item(wielditem) @@ -224,7 +224,8 @@ controls.register_on_hold(function(player, key, time) local name = player:get_player_name() local inv = minetest.get_inventory({type="player", name=name}) local wielditem = player:get_wielded_item() - if bow_load[name] == nil and wielditem:get_name()=="mcl_bows:bow" and (minetest.settings:get_bool("creative_mode") or inv:contains_item("main", "mcl_bows:arrow")) then + local creative = minetest.is_creative_enabled(name) + if bow_load[name] == nil and wielditem:get_name()=="mcl_bows:bow" and (creative or inv:contains_item("main", "mcl_bows:arrow")) then wielditem:set_name("mcl_bows:bow_0") player:set_wielded_item(wielditem) if minetest.get_modpath("playerphysics") then diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index 35ac359fdc..1ed5165542 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -141,7 +141,7 @@ function mcl_buckets.register_liquid(source_place, source_take, itemname, invent end -- Handle bucket item and inventory stuff - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(user:get_player_name()) then -- Add empty bucket and put it into inventory, if possible. -- Drop empty bucket otherwise. local new_bucket = ItemStack("mcl_buckets:bucket_empty") @@ -220,7 +220,7 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { if liquiddef ~= nil and liquiddef.itemname ~= nil and (nn == liquiddef.source_take) then -- Fill bucket, but not in Creative Mode - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(user:get_player_name()) then new_bucket = ItemStack({name = liquiddef.itemname, metadata = tostring(node.param2)}) end @@ -234,14 +234,14 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { elseif nn == "mcl_cauldrons:cauldron_3" then -- Take water out of full cauldron minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"}) - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(user:get_player_name()) then new_bucket = ItemStack("mcl_buckets:bucket_water") end sound_take("mcl_core:water_source", pointed_thing.under) elseif nn == "mcl_cauldrons:cauldron_3r" then -- Take river water out of full cauldron minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"}) - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(user:get_player_name()) then new_bucket = ItemStack("mcl_buckets:bucket_river_water") end sound_take("mclx_core:river_water_source", pointed_thing.under) @@ -259,7 +259,7 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { else minetest.add_item(user:get_pos(), new_bucket) end - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(user:get_player_name()) then itemstack:take_item() end return itemstack diff --git a/mods/ITEMS/mcl_cake/init.lua b/mods/ITEMS/mcl_cake/init.lua index 9f9dd20496..cc6d506331 100644 --- a/mods/ITEMS/mcl_cake/init.lua +++ b/mods/ITEMS/mcl_cake/init.lua @@ -62,7 +62,7 @@ minetest.register_node("mcl_cake:cake", { end local newcake = minetest.do_item_eat(2, ItemStack("mcl_cake:cake_6"), ItemStack("mcl_cake:cake"), clicker, {type="nothing"}) -- Check if we were allowed to eat - if newcake:get_name() ~= "mcl_cake:cake" or minetest.settings:get_bool("creative_mode") == true then + if newcake:get_name() ~= "mcl_cake:cake" or minetest.is_creative_enabled(clicker:get_player_name()) then minetest.add_node(pos,{type="node",name="mcl_cake:cake_6",param2=0}) end end, @@ -87,7 +87,7 @@ local register_slice = function(level, nodebox, desc) end local newcake = minetest.do_item_eat(CAKE_HUNGER_POINTS, ItemStack(after_eat), ItemStack(this), clicker, {type="nothing"}) -- Check if we were allowed to eat - if newcake:get_name() ~= this or minetest.settings:get_bool("creative_mode") == true then + if newcake:get_name() ~= this or minetest.is_creative_enabled(clicker:get_player_name()) then minetest.add_node(pos,{type="node",name=after_eat,param2=0}) end end @@ -101,7 +101,7 @@ local register_slice = function(level, nodebox, desc) end local newcake = minetest.do_item_eat(CAKE_HUNGER_POINTS, ItemStack("mcl:cake:cake 0"), ItemStack("mcl_cake:cake_1"), clicker, {type="nothing"}) -- Check if we were allowed to eat - if newcake:get_name() ~= this or minetest.settings:get_bool("creative_mode") == true then + if newcake:get_name() ~= this or minetest.is_creative_enabled(clicker:get_player_name()) then minetest.remove_node(pos) core.check_for_falling(pos) end diff --git a/mods/ITEMS/mcl_chests/init.lua b/mods/ITEMS/mcl_chests/init.lua index f71f3c13d3..7b46302a1d 100644 --- a/mods/ITEMS/mcl_chests/init.lua +++ b/mods/ITEMS/mcl_chests/init.lua @@ -845,7 +845,7 @@ for color, desc in pairs(boxtypes) do local iinv_main = minetest.deserialize(imeta) ninv:set_list("main", iinv_main) ninv:set_size("main", 9*3) - if minetest.settings:get_bool("creative_mode") then + if minetest.is_creative_enabled(placer:get_player_name()) then if not ninv:is_empty("main") then return nil else @@ -867,7 +867,7 @@ for color, desc in pairs(boxtypes) do local boxitem = ItemStack("mcl_chests:"..color.."_shulker_box") boxitem:set_metadata(data) - if minetest.settings:get_bool("creative_mode") then + if minetest.is_creative_enabled("") then if not inv:is_empty("main") then minetest.add_item(pos, boxitem) end diff --git a/mods/ITEMS/mcl_cocoas/init.lua b/mods/ITEMS/mcl_cocoas/init.lua index 8b70c1ad6f..b02a168e58 100644 --- a/mods/ITEMS/mcl_cocoas/init.lua +++ b/mods/ITEMS/mcl_cocoas/init.lua @@ -45,7 +45,7 @@ function mcl_cocoas.place(itemstack, placer, pointed_thing, plantname) minetest.sound_play("default_place_node", {pos = pt.above, gain = 1.0}, true) - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(placer:get_player_name()) then itemstack:take_item() end diff --git a/mods/ITEMS/mcl_doors/api_doors.lua b/mods/ITEMS/mcl_doors/api_doors.lua index a2685a9169..15d83a75cf 100644 --- a/mods/ITEMS/mcl_doors/api_doors.lua +++ b/mods/ITEMS/mcl_doors/api_doors.lua @@ -183,7 +183,7 @@ function mcl_doors:register_door(name, def) meta2:set_int("is_open", 0) - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(pn) then itemstack:take_item() end diff --git a/mods/ITEMS/mcl_dye/init.lua b/mods/ITEMS/mcl_dye/init.lua index eaacaecf3f..e84e75d911 100644 --- a/mods/ITEMS/mcl_dye/init.lua +++ b/mods/ITEMS/mcl_dye/init.lua @@ -337,7 +337,7 @@ minetest.register_craftitem("mcl_dye:white", { end -- Use the bone meal on the ground - if(mcl_dye.apply_bone_meal(pointed_thing) and not minetest.settings:get_bool("creative_mode")) then + if(mcl_dye.apply_bone_meal(pointed_thing) and (not minetest.is_creative_enabled(user:get_player_name()))) then itemstack:take_item() end return itemstack diff --git a/mods/ITEMS/mcl_end/chorus_plant.lua b/mods/ITEMS/mcl_end/chorus_plant.lua index e6f00d7863..d9933bcae5 100644 --- a/mods/ITEMS/mcl_end/chorus_plant.lua +++ b/mods/ITEMS/mcl_end/chorus_plant.lua @@ -538,7 +538,7 @@ local eat_chorus_fruit = function(itemstack, player, pointed_thing) local count = itemstack:get_count() local new_itemstack = minetest.do_item_eat(4, nil, itemstack, player, pointed_thing) local new_count = new_itemstack:get_count() - if count ~= new_count or new_itemstack:get_name() ~= "mcl_end:chorus_fruit" or (minetest.settings:get_bool("creative_mode") == true) then + if count ~= new_count or new_itemstack:get_name() ~= "mcl_end:chorus_fruit" or (minetest.is_creative_enabled(player:get_player_name()) == true) then random_teleport(player) end return new_itemstack diff --git a/mods/ITEMS/mcl_end/eye_of_ender.lua b/mods/ITEMS/mcl_end/eye_of_ender.lua index 117fb73c44..16f1c906bb 100644 --- a/mods/ITEMS/mcl_end/eye_of_ender.lua +++ b/mods/ITEMS/mcl_end/eye_of_ender.lua @@ -29,7 +29,7 @@ minetest.register_entity("mcl_end:ender_eye", { if self._age >= 3 then -- End of life local r = math.random(1,5) - if r == 1 or minetest.settings:get_bool("creative_mode") then + if r == 1 or minetest.is_creative_enabled("") then -- 20% chance to get destroyed completely. -- 100% if in Creative Mode self.object:remove() @@ -89,7 +89,7 @@ minetest.register_craftitem("mcl_end:ender_eye", { origin.y = origin.y + 1.5 local strongholds = mcl_structures.get_registered_structures("stronghold") local dim = mcl_worlds.pos_to_dimension(origin) - local is_creative = minetest.settings:get_bool("creative_mode") + local is_creative = minetest.is_creative_enabled(user:get_player_name()) -- Just drop the eye of ender if there are no strongholds if #strongholds <= 0 or dim ~= "overworld" then diff --git a/mods/ITEMS/mcl_farming/hoes.lua b/mods/ITEMS/mcl_farming/hoes.lua index f296bd8380..a7caadb357 100644 --- a/mods/ITEMS/mcl_farming/hoes.lua +++ b/mods/ITEMS/mcl_farming/hoes.lua @@ -41,7 +41,7 @@ local hoe_on_place_function = function(wear_divisor) end if create_soil(pointed_thing.under, user:get_inventory()) then - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(user:get_player_name()) then itemstack:add_wear(65535/wear_divisor) end return itemstack diff --git a/mods/ITEMS/mcl_farming/shared_functions.lua b/mods/ITEMS/mcl_farming/shared_functions.lua index 0c366af29e..e066092c35 100644 --- a/mods/ITEMS/mcl_farming/shared_functions.lua +++ b/mods/ITEMS/mcl_farming/shared_functions.lua @@ -90,7 +90,7 @@ function mcl_farming:place_seed(itemstack, placer, pointed_thing, plantname) return end - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(placer:get_player_name()) then itemstack:take_item() end return itemstack diff --git a/mods/ITEMS/mcl_fire/fire_charge.lua b/mods/ITEMS/mcl_fire/fire_charge.lua index 9f4f6bc0fd..dcf4ddb007 100644 --- a/mods/ITEMS/mcl_fire/fire_charge.lua +++ b/mods/ITEMS/mcl_fire/fire_charge.lua @@ -36,7 +36,7 @@ minetest.register_craftitem("mcl_fire:fire_charge", { else mcl_fire.set_fire(pointed_thing, user, false) end - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(user:get_player_name()) then itemstack:take_item() end end diff --git a/mods/ITEMS/mcl_fire/flint_and_steel.lua b/mods/ITEMS/mcl_fire/flint_and_steel.lua index d88338402d..e0bfca288d 100644 --- a/mods/ITEMS/mcl_fire/flint_and_steel.lua +++ b/mods/ITEMS/mcl_fire/flint_and_steel.lua @@ -47,7 +47,7 @@ minetest.register_tool("mcl_fire:flint_and_steel", { if itemstack:get_count() == 0 and idef.sound and idef.sound.breaks then minetest.sound_play(idef.sound.breaks, {pos=user:get_pos(), gain=0.5}, true) end - if not minetest.settings:get_bool("creative_mode") and used == true then + if (not minetest.is_creative_enabled(user:get_player_name())) and used == true then itemstack:add_wear(65535/65) -- 65 uses end return itemstack @@ -57,13 +57,13 @@ minetest.register_tool("mcl_fire:flint_and_steel", { -- Ignite air if dropnode.name == "air" then minetest.add_node(droppos, {name="mcl_fire:fire"}) - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled("") then stack:add_wear(65535/65) -- 65 uses end -- Ignite TNT elseif dropnode.name == "mcl_tnt:tnt" then tnt.ignite(droppos) - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled("") then stack:add_wear(65535/65) -- 65 uses end end diff --git a/mods/ITEMS/mcl_fishing/init.lua b/mods/ITEMS/mcl_fishing/init.lua index aee940931f..365dec0d2a 100644 --- a/mods/ITEMS/mcl_fishing/init.lua +++ b/mods/ITEMS/mcl_fishing/init.lua @@ -101,7 +101,8 @@ local fish = function(itemstack, player) if inv:room_for_item("main", item) then inv:add_item("main", item) end - if not minetest.settings:get_bool("creative_mode") then + + if not minetest.is_creative_enabled(player:get_player_name()) then local idef = itemstack:get_definition() itemstack:add_wear(65535/65) -- 65 uses if itemstack:get_count() == 0 and idef.sound and idef.sound.breaks then @@ -115,7 +116,7 @@ local fish = function(itemstack, player) local node = minetest.get_node(epos) local def = minetest.registered_nodes[node.name] if def.walkable then - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(player:get_player_name()) then local idef = itemstack:get_definition() itemstack:add_wear((65535/65)*2) -- if so and not creative then wear double like in MC. if itemstack:get_count() == 0 and idef.sound and idef.sound.breaks then diff --git a/mods/ITEMS/mcl_flowerpots/init.lua b/mods/ITEMS/mcl_flowerpots/init.lua index d2c634bd49..3e22346f7c 100644 --- a/mods/ITEMS/mcl_flowerpots/init.lua +++ b/mods/ITEMS/mcl_flowerpots/init.lua @@ -66,7 +66,7 @@ minetest.register_node("mcl_flowerpots:flower_pot", { local flower_node = row[2] if item == flower_node then minetest.swap_node(pos, {name="mcl_flowerpots:flower_pot_"..flower}) - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(clicker:get_player_name()) then itemstack:take_item() end end @@ -76,7 +76,7 @@ minetest.register_node("mcl_flowerpots:flower_pot", { local flower_node = row[2] if item == flower_node then minetest.swap_node(pos, {name="mcl_flowerpots:flower_pot_"..flower}) - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(clicker:get_player_name()) then itemstack:take_item() end end diff --git a/mods/ITEMS/mcl_flowers/init.lua b/mods/ITEMS/mcl_flowers/init.lua index 68ad9538e6..0a0fa2228d 100644 --- a/mods/ITEMS/mcl_flowers/init.lua +++ b/mods/ITEMS/mcl_flowers/init.lua @@ -264,7 +264,7 @@ local function add_large_plant(name, desc, longdesc, bottom_img, top_img, inv_im minetest.sound_play(minetest.registered_nodes[itemstring].sounds.place, {pos = bottom, gain=1}, true) minetest.set_node(bottom, {name=itemstring, param2=param2}) minetest.set_node(top, {name=itemstring.."_top", param2=param2}) - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(placer:get_player_name()) then itemstack:take_item() end end @@ -419,7 +419,7 @@ minetest.register_node("mcl_flowers:waterlily", { minetest.sound_play(idef.sounds.place, {pos=pointed_thing.above, gain=1}, true) end - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(player_name) then itemstack:take_item() end else diff --git a/mods/ITEMS/mcl_itemframes/init.lua b/mods/ITEMS/mcl_itemframes/init.lua index b9fa704874..8be81bac3e 100644 --- a/mods/ITEMS/mcl_itemframes/init.lua +++ b/mods/ITEMS/mcl_itemframes/init.lua @@ -88,7 +88,7 @@ local update_item_entity = function(pos, node, param2) end local drop_item = function(pos, node, meta) - if node.name == "mcl_itemframes:item_frame" and not minetest.settings:get_bool("creative_mode") then + if node.name == "mcl_itemframes:item_frame" and not minetest.is_creative_enabled("") then local inv = meta:get_inventory() local item = inv:get_stack("main", 1) if not item:is_empty() then @@ -151,7 +151,7 @@ minetest.register_node("mcl_itemframes:item_frame",{ meta:set_string("infotext", iname) end - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(clicker:get_player_name()) then itemstack:take_item() end return itemstack diff --git a/mods/ITEMS/mcl_maps/init.lua b/mods/ITEMS/mcl_maps/init.lua index 4c919c347e..893e700736 100644 --- a/mods/ITEMS/mcl_maps/init.lua +++ b/mods/ITEMS/mcl_maps/init.lua @@ -42,7 +42,7 @@ end -- Checks if player is still allowed to display the minimap local function update_minimap(player) - local creative = minetest.settings:get_bool("creative_mode") + local creative = minetest.is_creative_enabled(player:get_player_name()) if creative then player:hud_set_flags({minimap=true, minimap_radar = true}) else @@ -94,7 +94,7 @@ minetest.register_on_joinplayer(function(player) end) local updatetimer = 0 -if not minetest.settings:get_bool("creative_mode") then +if not minetest.is_creative_enabled("") then minetest.register_globalstep(function(dtime) updatetimer = updatetimer + dtime if updatetimer > 0.1 then diff --git a/mods/ITEMS/mcl_mobitems/init.lua b/mods/ITEMS/mcl_mobitems/init.lua index 6c6953d845..5c52fdf11e 100644 --- a/mods/ITEMS/mcl_mobitems/init.lua +++ b/mods/ITEMS/mcl_mobitems/init.lua @@ -139,7 +139,7 @@ minetest.register_craftitem("mcl_mobitems:cooked_rabbit", { local drink_milk = function(itemstack, player, pointed_thing) local bucket = minetest.do_item_eat(0, "mcl_buckets:bucket_empty", itemstack, player, pointed_thing) -- Check if we were allowed to drink this (eat delay check) - if mcl_hunger.active and (bucket:get_name() ~= "mcl_mobitems:milk_bucket" or minetest.settings:get_bool("creative_mode") == true) then + if mcl_hunger.active and (bucket:get_name() ~= "mcl_mobitems:milk_bucket" or minetest.is_creative_enabled(player:get_player_name())) then mcl_hunger.stop_poison(player) end mcl_potions._reset_player_effects(player) diff --git a/mods/ITEMS/mcl_monster_eggs/init.lua b/mods/ITEMS/mcl_monster_eggs/init.lua index a4c0144d46..55875159e5 100644 --- a/mods/ITEMS/mcl_monster_eggs/init.lua +++ b/mods/ITEMS/mcl_monster_eggs/init.lua @@ -4,7 +4,7 @@ local S = minetest.get_translator("mcl_monster_eggs") local spawn_silverfish = function(pos, oldnode, oldmetadata, digger) - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled("") then minetest.add_entity(pos, "mobs_mc:silverfish") end end diff --git a/mods/ITEMS/mcl_nether/nether_wart.lua b/mods/ITEMS/mcl_nether/nether_wart.lua index a408b96c57..354fa6139a 100644 --- a/mods/ITEMS/mcl_nether/nether_wart.lua +++ b/mods/ITEMS/mcl_nether/nether_wart.lua @@ -128,7 +128,7 @@ minetest.register_craftitem("mcl_nether:nether_wart_item", { minetest.sound_play({name="default_place_node", gain=1.0}, {pos=placepos}, true) minetest.set_node(placepos, {name="mcl_nether:nether_wart_0", param2 = 3}) - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(placer:get_player_name()) then itemstack:take_item() end return itemstack diff --git a/mods/ITEMS/mcl_ocean/corals.lua b/mods/ITEMS/mcl_ocean/corals.lua index 7b076c3e48..f04a023167 100644 --- a/mods/ITEMS/mcl_ocean/corals.lua +++ b/mods/ITEMS/mcl_ocean/corals.lua @@ -61,7 +61,7 @@ local function coral_on_place(itemstack, placer, pointed_thing) if def_node.sounds then minetest.sound_play(def_node.sounds.place, { gain = 0.5, pos = pos_under }, true) end - if not (minetest.settings:get_bool("creative_mode")) then + if not minetest.is_creative_enabled(player_name) then itemstack:take_item() end diff --git a/mods/ITEMS/mcl_ocean/kelp.lua b/mods/ITEMS/mcl_ocean/kelp.lua index a79ec06a28..5751506a12 100644 --- a/mods/ITEMS/mcl_ocean/kelp.lua +++ b/mods/ITEMS/mcl_ocean/kelp.lua @@ -123,7 +123,7 @@ local function kelp_on_place(itemstack, placer, pointed_thing) minetest.sound_play(def_node.sounds.place, { gain = 0.5, pos = pos_under }, true) end minetest.set_node(pos_under, node_under) - if not (minetest.settings:get_bool("creative_mode")) then + if not minetest.is_creative_enabled(player_name) then itemstack:take_item() end diff --git a/mods/ITEMS/mcl_ocean/sea_pickle.lua b/mods/ITEMS/mcl_ocean/sea_pickle.lua index 55ea1755e4..45b934a92c 100644 --- a/mods/ITEMS/mcl_ocean/sea_pickle.lua +++ b/mods/ITEMS/mcl_ocean/sea_pickle.lua @@ -54,7 +54,7 @@ local function sea_pickle_on_place(itemstack, placer, pointed_thing) else return itemstack end - if not (minetest.settings:get_bool("creative_mode")) then + if not minetest.is_creative_enabled(player_name) then itemstack:take_item() end return itemstack diff --git a/mods/ITEMS/mcl_ocean/seagrass.lua b/mods/ITEMS/mcl_ocean/seagrass.lua index a5765cf930..4922051382 100644 --- a/mods/ITEMS/mcl_ocean/seagrass.lua +++ b/mods/ITEMS/mcl_ocean/seagrass.lua @@ -70,7 +70,7 @@ local function seagrass_on_place(itemstack, placer, pointed_thing) minetest.sound_play(def_node.sounds.place, { gain = 0.5, pos = pos_under }, true) end minetest.set_node(pos_under, node_under) - if not (minetest.settings:get_bool("creative_mode")) then + if not minetest.is_creative_enabled(player_name) then itemstack:take_item() end diff --git a/mods/ITEMS/mcl_portals/portal_end.lua b/mods/ITEMS/mcl_portals/portal_end.lua index 8506dd271e..5a5e74b33f 100644 --- a/mods/ITEMS/mcl_portals/portal_end.lua +++ b/mods/ITEMS/mcl_portals/portal_end.lua @@ -405,7 +405,7 @@ minetest.override_item("mcl_end:ender_eye", { minetest.sound_play( "default_place_node_hard", {pos = pointed_thing.under, gain = 0.5, max_hear_distance = 16}, true) - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(user:get_player_name()) then itemstack:take_item() -- 1 use end diff --git a/mods/ITEMS/mcl_potions/init.lua b/mods/ITEMS/mcl_potions/init.lua index 8ef68a955b..648aa7e7ae 100644 --- a/mods/ITEMS/mcl_potions/init.lua +++ b/mods/ITEMS/mcl_potions/init.lua @@ -100,7 +100,7 @@ minetest.register_craftitem("mcl_potions:glass_bottle", { end end if get_water then - local creative = minetest.settings:get_bool("creative_mode") == true + local creative = minetest.is_creative_enabled(placer:get_player_name()) if from_liquid_source or creative then -- Replace with water bottle, if possible, otherwise -- place the water potion at a place where's space @@ -210,7 +210,7 @@ minetest.register_craftitem("mcl_potions:water", { -- Increase water level of cauldron by 1 minetest.set_node(pointed_thing.under, {name=cauldron}) minetest.sound_play("mcl_potions_bottle_pour", {pos=pointed_thing.under, gain=0.5, max_hear_range=16}, true) - if minetest.settings:get_bool("creative_mode") == true then + if minetest.is_creative_enabled(placer:get_player_name()) then return itemstack else return "mcl_potions:glass_bottle" @@ -256,7 +256,7 @@ minetest.register_craftitem("mcl_potions:river_water", { -- Increase water level of cauldron by 1 minetest.set_node(pointed_thing.under, {name=cauldron}) minetest.sound_play("mcl_potions_bottle_pour", {pos=pointed_thing.under, gain=0.5, max_hear_range=16}, true) - if minetest.settings:get_bool("creative_mode") == true then + if minetest.is_creative_enabled(placer:get_player_name()) then return itemstack else return "mcl_potions:glass_bottle" diff --git a/mods/ITEMS/mcl_potions/lingering.lua b/mods/ITEMS/mcl_potions/lingering.lua index bf18345280..26ea47f340 100644 --- a/mods/ITEMS/mcl_potions/lingering.lua +++ b/mods/ITEMS/mcl_potions/lingering.lua @@ -81,7 +81,7 @@ local function register_lingering(name, descr, color, def) local obj = minetest.add_entity({x=pos.x+dir.x,y=pos.y+2+dir.y,z=pos.z+dir.z}, id.."_flying") obj:setvelocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity}) obj:setacceleration({x=0, y=-9.8, z=0}) - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(placer:get_player_name()) then item:take_item() end return item diff --git a/mods/ITEMS/mcl_potions/splash.lua b/mods/ITEMS/mcl_potions/splash.lua index 2cd8fbbb27..a9efe52f83 100644 --- a/mods/ITEMS/mcl_potions/splash.lua +++ b/mods/ITEMS/mcl_potions/splash.lua @@ -23,7 +23,7 @@ local function register_splash(name, descr, color, def) local obj = minetest.add_entity({x=pos.x+dir.x,y=pos.y+2+dir.y,z=pos.z+dir.z}, id.."_flying") obj:set_velocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity}) obj:set_acceleration({x=0, y=-9.8, z=0}) - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(placer:get_player_name()) then item:take_item() end return item diff --git a/mods/ITEMS/mcl_signs/init.lua b/mods/ITEMS/mcl_signs/init.lua index 89d6b78bac..441fcbb4c8 100644 --- a/mods/ITEMS/mcl_signs/init.lua +++ b/mods/ITEMS/mcl_signs/init.lua @@ -362,7 +362,7 @@ minetest.register_node("mcl_signs:wall_sign", { if not success then return itemstack end - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(placer:get_player_name()) then itemstack:take_item() end sign_info = signtext_info_standing[rotation_level + 1] diff --git a/mods/ITEMS/mcl_sponges/init.lua b/mods/ITEMS/mcl_sponges/init.lua index db68b28156..4a2107f880 100644 --- a/mods/ITEMS/mcl_sponges/init.lua +++ b/mods/ITEMS/mcl_sponges/init.lua @@ -82,7 +82,7 @@ minetest.register_node("mcl_sponges:sponge", { local absorbed, wet_sponge = absorb(pos) if absorbed then minetest.item_place_node(ItemStack(wet_sponge), placer, pointed_thing) - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(placer:get_player_name()) then itemstack:take_item() end return itemstack diff --git a/mods/ITEMS/mcl_stairs/api.lua b/mods/ITEMS/mcl_stairs/api.lua index 9f396473b2..1c81167f68 100644 --- a/mods/ITEMS/mcl_stairs/api.lua +++ b/mods/ITEMS/mcl_stairs/api.lua @@ -229,7 +229,7 @@ function mcl_stairs.register_slab(subname, recipeitem, groups, images, descripti on_place = function(itemstack, placer, pointed_thing) local under = minetest.get_node(pointed_thing.under) local wield_item = itemstack:get_name() - local creative_enabled = minetest.settings:get_bool("creative_mode") + local creative_enabled = minetest.is_creative_enabled(placer:get_player_name()) -- place slab using under node orientation local dir = vector.subtract(pointed_thing.above, pointed_thing.under) diff --git a/mods/ITEMS/mcl_throwing/init.lua b/mods/ITEMS/mcl_throwing/init.lua index e588363f46..58399a29d6 100644 --- a/mods/ITEMS/mcl_throwing/init.lua +++ b/mods/ITEMS/mcl_throwing/init.lua @@ -48,7 +48,7 @@ local player_throw_function = function(entity_name, velocity) local playerpos = player:get_pos() local dir = player:get_look_dir() local obj = mcl_throwing.throw(item, {x=playerpos.x, y=playerpos.y+1.5, z=playerpos.z}, dir, velocity, player:get_player_name()) - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(player:get_player_name()) then item:take_item() end return item diff --git a/mods/ITEMS/mcl_tools/init.lua b/mods/ITEMS/mcl_tools/init.lua index 7cd6f9b9ce..f88ea8fa18 100644 --- a/mods/ITEMS/mcl_tools/init.lua +++ b/mods/ITEMS/mcl_tools/init.lua @@ -26,7 +26,7 @@ dig_speed_class group: -- The hand local groupcaps, hand_range, hand_groups -if minetest.settings:get_bool("creative_mode") then +if minetest.is_creative_enabled("") then -- Instant breaking in creative mode groupcaps = { creative_breakable = {times={[1]=0}, uses=0}, @@ -213,7 +213,7 @@ local make_grass_path = function(itemstack, placer, pointed_thing) return itemstack end - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(placer:get_player_name()) then -- Add wear, as if digging a level 0 shovely node local toolname = itemstack:get_name() local def = minetest.registered_items[toolname] @@ -247,7 +247,7 @@ if minetest.get_modpath("mcl_farming") then return end if node.name == "mcl_farming:pumpkin" then - if not minetest.settings:get_bool("creative_mode") then + if not minetest.is_creative_enabled(placer:get_player_name()) then -- Add wear (as if digging a shearsy node) local toolname = itemstack:get_name() local def = minetest.registered_items[toolname] diff --git a/mods/ITEMS/screwdriver/init.lua b/mods/ITEMS/screwdriver/init.lua index 7fad2bdcbe..1fb9745ab5 100644 --- a/mods/ITEMS/screwdriver/init.lua +++ b/mods/ITEMS/screwdriver/init.lua @@ -160,7 +160,7 @@ screwdriver.handler = function(itemstack, user, pointed_thing, mode, uses) minetest.check_for_falling(pos) end - if not (minetest.settings:get_bool("creative_mode")) then + if not (minetest.is_creative_enabled(user:get_player_name())) then itemstack:add_wear(65535 / ((uses or 200) - 1)) end diff --git a/mods/PLAYER/mcl_hunger/hunger.lua b/mods/PLAYER/mcl_hunger/hunger.lua index a664b6ad8e..cff54b169d 100644 --- a/mods/PLAYER/mcl_hunger/hunger.lua +++ b/mods/PLAYER/mcl_hunger/hunger.lua @@ -23,7 +23,7 @@ minetest.do_item_eat = function(hp_change, replace_with_item, itemstack, user, p local name = user:get_player_name() - local creative = minetest.settings:get_bool("creative_mode") == true + local creative = minetest.is_creative_enabled(name) -- Special foodstuffs like the cake may disable the eating delay local no_eat_delay = creative or (minetest.get_item_group(itemstack:get_name(), "no_eat_delay") == 1) @@ -130,7 +130,7 @@ local poisonrandomizer = PseudoRandom(os.time()) function mcl_hunger.item_eat(hunger_change, replace_with_item, poisontime, poison, exhaust, poisonchance, sound) return function(itemstack, user, pointed_thing) local itemname = itemstack:get_name() - local creative = minetest.settings:get_bool("creative_mode") == true + local creative = minetest.is_creative_enabled(user:get_player_name()) if itemstack:peek_item() ~= nil and user ~= nil then if not creative then itemstack:take_item()