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
|
return false
|
||||||
end
|
end
|
||||||
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()
|
local inv=user:get_inventory()
|
||||||
|
|
||||||
if itemstack:get_count() == 1 then
|
if not minetest.settings:get_bool("creative_mode") then
|
||||||
itemstack:set_name("default:bucket")
|
if itemstack:get_count() == 1 then
|
||||||
elseif inv:room_for_item("main", {name="default:bucket"}) then
|
itemstack:set_name("default:bucket")
|
||||||
itemstack:take_item()
|
elseif inv:room_for_item("main", {name="default:bucket"}) then
|
||||||
inv:add_item("main", "default:bucket")
|
itemstack:take_item()
|
||||||
else
|
inv:add_item("main", "default:bucket")
|
||||||
itemstack:take_item()
|
else
|
||||||
local pos = user:get_pos()
|
itemstack:take_item()
|
||||||
pos.y = math.floor(pos.y + 0.5)
|
local pos = user:get_pos()
|
||||||
minetest.add_item(pos, "default:bucket")
|
pos.y = math.floor(pos.y + 0.5)
|
||||||
|
minetest.add_item(pos, "default:bucket")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local pos = pointed_thing.above
|
local pos = pointed_thing.above
|
||||||
@ -67,7 +69,9 @@ minetest.register_craftitem(
|
|||||||
local nodename=minetest.get_node(pointed_thing.under).name
|
local nodename=minetest.get_node(pointed_thing.under).name
|
||||||
|
|
||||||
local replace_bucket = function(itemstack, new_bucket)
|
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)
|
itemstack:set_name(new_bucket)
|
||||||
else
|
else
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
|
@ -745,7 +745,9 @@ minetest.register_tool(
|
|||||||
param2 = node.param2
|
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
|
elseif nodename == "default:torch_dead" then
|
||||||
minetest.set_node(
|
minetest.set_node(
|
||||||
pos,
|
pos,
|
||||||
@ -755,13 +757,17 @@ minetest.register_tool(
|
|||||||
param2 = node.param2
|
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
|
elseif nodename == "tnt:tnt" then
|
||||||
local y = minetest.registered_nodes["tnt:tnt"]
|
local y = minetest.registered_nodes["tnt:tnt"]
|
||||||
if y ~= nil then
|
if y ~= nil then
|
||||||
y.on_punch(pos, node, user)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -230,7 +230,9 @@ local function on_item_eat(hpdata, replace_with_item, itemstack,
|
|||||||
hunger.update_bar(player)
|
hunger.update_bar(player)
|
||||||
delayed_save()
|
delayed_save()
|
||||||
|
|
||||||
itemstack:take_item(1)
|
if not minetest.settings:get_bool("creative_mode") then
|
||||||
|
itemstack:take_item(1)
|
||||||
|
end
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
@ -335,7 +337,9 @@ local function fake_on_item_eat(hpdata, replace_with_item, itemstack,
|
|||||||
max_hear_distance = 8
|
max_hear_distance = 8
|
||||||
})
|
})
|
||||||
|
|
||||||
itemstack:take_item(1)
|
if not minetest.settings:get_bool("creative_mode") then
|
||||||
|
itemstack:take_item(1)
|
||||||
|
end
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
@ -98,7 +98,9 @@ minetest.register_tool(
|
|||||||
end
|
end
|
||||||
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
|
return itemstack
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
@ -1306,7 +1306,9 @@ function mobs:register_mob(name, def)
|
|||||||
local weapon = hitter:get_wielded_item()
|
local weapon = hitter:get_wielded_item()
|
||||||
if weapon:get_definition().tool_capabilities ~= nil then
|
if weapon:get_definition().tool_capabilities ~= nil then
|
||||||
local wear = ( (weapon:get_definition().tool_capabilities.full_punch_interval or 1.4) / 75 ) * 9000
|
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)
|
hitter:set_wielded_item(weapon)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1533,7 +1535,9 @@ function mobs:register_egg(mob, desc, background)
|
|||||||
ent.owner = placer:get_player_name()
|
ent.owner = placer:get_player_name()
|
||||||
ent.tamed = true
|
ent.tamed = true
|
||||||
end
|
end
|
||||||
itemstack:take_item()
|
if not minetest.settings:get_bool("creative_mode") then
|
||||||
|
itemstack:take_item()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end,
|
||||||
@ -1581,11 +1585,15 @@ function mobs:capture_mob(self, clicker, chance_hand, chance_net, chance_lasso,
|
|||||||
chance = chance_hand
|
chance = chance_hand
|
||||||
elseif tool:get_name() == "mobs:net" then
|
elseif tool:get_name() == "mobs:net" then
|
||||||
chance = chance_net
|
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)
|
clicker:set_wielded_item(tool)
|
||||||
elseif tool:get_name() == "mobs:lasso" then
|
elseif tool:get_name() == "mobs:lasso" then
|
||||||
chance = chance_lasso
|
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)
|
clicker:set_wielded_item(tool)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -107,7 +107,9 @@ mobs:register_mob(
|
|||||||
z = math.random(-1,1)
|
z = math.random(-1,1)
|
||||||
})
|
})
|
||||||
end
|
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)
|
clicker:set_wielded_item(item)
|
||||||
self.object:set_properties(
|
self.object:set_properties(
|
||||||
{
|
{
|
||||||
|
@ -56,7 +56,9 @@ minetest.register_craftitem(
|
|||||||
|
|
||||||
default.player_attached[player:get_player_name()] = true
|
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
|
return itemstack
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user