Don't wear or destroy items in creative
This commit is contained in:
parent
940b9f87f6
commit
c0f377c100
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
})
|
||||
|
@ -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
|
||||
|
||||
|
@ -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(
|
||||
{
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user