Add 24 uses of watering can before water is empty

This is done by abusing
There is a problem with that: If a mod uses a tool repair recipe, you can magically
fill up watering cans by placing two partly empty watering cans into the crafting grid … :/
This commit is contained in:
Wuzzy 2014-06-13 16:59:54 +02:00
parent 3106b6de5e
commit 9354224a11

@ -2,17 +2,36 @@ minetest.register_tool("wateringcan:wateringcan_water", {
description = "watering can with water",
inventory_image = "wateringcan_wateringcan_water.png",
wield_image = "wateringcan_wateringcan_wield.png",
liquids_pointable = true,
stack_max = 1,
tool_capabilities = {
full_punch_interval = 2.0,
},
on_place = function(itemstack, user, pointed_thing)
if(pointed_thing.type == "node") then
local node = minetest.get_node_or_nil(pointed_thing.under)
if node ~= nil then
local name = node.name
local nodedef = minetest.registered_nodes[name]
local watered = false
local wear, newtool
if name == "farming:soil" and minetest.get_modpath("farming") ~= nil then
minetest.set_node(pointed_thing.under, { name = "farming:soil_wet" })
watered = true
elseif minetest.get_item_group(name, "sucky") > 0 and minetest.get_modpath("pedology") ~= nil then
pedology.wetten(pointed_thing.under)
watered = true
end
if watered then
wear = itemstack:get_wear()
wear = wear + 2849 -- 24 uses
if(wear > 65535) then
newtool = { name = "wateringcan:wateringcan_empty" }
else
newtool = { name = "wateringcan:wateringcan_water", wear = wear }
end
end
return newtool
end
end
end
@ -20,9 +39,13 @@ minetest.register_tool("wateringcan:wateringcan_water", {
}
)
minetest.register_craftitem("wateringcan:wateringcan_empty", {
minetest.register_tool("wateringcan:wateringcan_empty", {
description = "empty watering can",
inventory_image = "wateringcan_wateringcan_empty.png",
wield_image = "wateringcan_wateringcan_wield.png",
}
)
liquids_pointable = true,
stack_max = 1,
tool_capabilities = {
full_punch_interval = 2.0,
},
})