diff --git a/mods/creative/init.lua b/mods/creative/init.lua index 7afe0f2..d05bdf7 100644 --- a/mods/creative/init.lua +++ b/mods/creative/init.lua @@ -182,3 +182,11 @@ creative.is_enabled_for = function(player) return false end end + +if minetest.settings:get_bool("creative_mode") 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") + return group == 0 or group == nil + end) +end diff --git a/mods/default/bucket.lua b/mods/default/bucket.lua index b4c7342..a82f127 100644 --- a/mods/default/bucket.lua +++ b/mods/default/bucket.lua @@ -24,16 +24,18 @@ for b=1, #filled_buckets do local inv=user:get_inventory() - if itemstack:get_count() == 1 then - itemstack:set_name("default:bucket") - elseif inv:room_for_item("main", {name="default:bucket"}) then - itemstack:take_item() - inv:add_item("main", "default:bucket") - else - itemstack:take_item() - local pos = user:get_pos() - pos.y = math.floor(pos.y + 0.5) - minetest.add_item(pos, "default:bucket") + if not minetest.settings:get_bool("creative_mode") then + if itemstack:get_count() == 1 then + itemstack:set_name("default:bucket") + elseif inv:room_for_item("main", {name="default:bucket"}) then + itemstack:take_item() + inv:add_item("main", "default:bucket") + else + itemstack:take_item() + local pos = user:get_pos() + pos.y = math.floor(pos.y + 0.5) + minetest.add_item(pos, "default:bucket") + end end local pos = pointed_thing.above @@ -67,7 +69,9 @@ minetest.register_craftitem( local nodename=minetest.get_node(pointed_thing.under).name local replace_bucket = function(itemstack, new_bucket) - if itemstack:get_count() == 1 then + if minetest.settings:get_bool("creative_mode") then + -- no-op + elseif itemstack:get_count() == 1 then itemstack:set_name(new_bucket) else itemstack:take_item() diff --git a/mods/default/tools.lua b/mods/default/tools.lua index d2a3c2a..a7584e7 100644 --- a/mods/default/tools.lua +++ b/mods/default/tools.lua @@ -745,7 +745,9 @@ minetest.register_tool( param2 = node.param2 }) - itemstack:add_wear(800) + if not minetest.settings:get_bool("creative_mode") then + itemstack:add_wear(800) + end elseif nodename == "default:torch_dead" then minetest.set_node( pos, @@ -755,13 +757,17 @@ minetest.register_tool( param2 = node.param2 }) - itemstack:add_wear(800) + if not minetest.settings:get_bool("creative_mode") then + itemstack:add_wear(800) + end elseif nodename == "tnt:tnt" then local y = minetest.registered_nodes["tnt:tnt"] if y ~= nil then y.on_punch(pos, node, user) - itemstack:add_wear(800) + if not minetest.settings:get_bool("creative_mode") then + itemstack:add_wear(800) + end end end diff --git a/mods/hunger/init.lua b/mods/hunger/init.lua index 7ad3343..1960513 100644 --- a/mods/hunger/init.lua +++ b/mods/hunger/init.lua @@ -230,7 +230,9 @@ local function on_item_eat(hpdata, replace_with_item, itemstack, hunger.update_bar(player) delayed_save() - itemstack:take_item(1) + if not minetest.settings:get_bool("creative_mode") then + itemstack:take_item(1) + end return itemstack end @@ -335,7 +337,9 @@ local function fake_on_item_eat(hpdata, replace_with_item, itemstack, max_hear_distance = 8 }) - itemstack:take_item(1) + if not minetest.settings:get_bool("creative_mode") then + itemstack:take_item(1) + end return itemstack end diff --git a/mods/locks/init.lua b/mods/locks/init.lua index 849455c..187e758 100644 --- a/mods/locks/init.lua +++ b/mods/locks/init.lua @@ -98,7 +98,9 @@ minetest.register_tool( end end - itemstack:add_wear(8200) -- about 8 uses + if not minetest.settings:get_bool("creative_mode") then + itemstack:add_wear(8200) -- about 8 uses + end return itemstack end, }) diff --git a/mods/mobs/api.lua b/mods/mobs/api.lua index 1735d53..94a0e5a 100644 --- a/mods/mobs/api.lua +++ b/mods/mobs/api.lua @@ -1306,7 +1306,9 @@ function mobs:register_mob(name, def) local weapon = hitter:get_wielded_item() if weapon:get_definition().tool_capabilities ~= nil then local wear = ( (weapon:get_definition().tool_capabilities.full_punch_interval or 1.4) / 75 ) * 9000 - weapon:add_wear(wear) + if not minetest.settings:get_bool("creative_mode") then + weapon:add_wear(wear) + end hitter:set_wielded_item(weapon) end @@ -1533,7 +1535,9 @@ function mobs:register_egg(mob, desc, background) ent.owner = placer:get_player_name() ent.tamed = true end - itemstack:take_item() + if not minetest.settings:get_bool("creative_mode") then + itemstack:take_item() + end end return itemstack end, @@ -1581,11 +1585,15 @@ function mobs:capture_mob(self, clicker, chance_hand, chance_net, chance_lasso, chance = chance_hand elseif tool:get_name() == "mobs:net" then chance = chance_net - tool:add_wear(4000) -- 17 uses + if not minetest.settings:get_bool("creative_mode") then + tool:add_wear(4000) -- 17 uses + end clicker:set_wielded_item(tool) elseif tool:get_name() == "mobs:lasso" then chance = chance_lasso - tool:add_wear(1500) -- 43 uses + if not minetest.settings:get_bool("creative_mode") then + tool:add_wear(1500) -- 43 uses + end clicker:set_wielded_item(tool) end diff --git a/mods/mobs/mob_sheep.lua b/mods/mobs/mob_sheep.lua index 8c65d55..f8da2f7 100644 --- a/mods/mobs/mob_sheep.lua +++ b/mods/mobs/mob_sheep.lua @@ -107,7 +107,9 @@ mobs:register_mob( z = math.random(-1,1) }) end - item:add_wear(650) -- 100 uses + if not minetest.settings:get_bool("creative_mode") then + item:add_wear(650) -- 100 uses + end clicker:set_wielded_item(item) self.object:set_properties( { diff --git a/mods/parachute/init.lua b/mods/parachute/init.lua index ef9a997..abe521a 100644 --- a/mods/parachute/init.lua +++ b/mods/parachute/init.lua @@ -56,7 +56,9 @@ minetest.register_craftitem( default.player_attached[player:get_player_name()] = true - itemstack:take_item() + if not minetest.settings:get_bool("creative_mode") then + itemstack:take_item() + end return itemstack else