This commit is contained in:
AFCMS 2021-03-18 09:43:31 +01:00
parent 182e825303
commit 72149a2c56
2 changed files with 37 additions and 55 deletions

View File

@ -217,8 +217,7 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", {
end
elseif minetest.get_item_group(nn, "cauldron") then
mcl_cauldrons.take_cauldron(pos, itemstack)
-- Take water out of full cauldron
mcl_cauldrons.take_cauldron(pointed_thing.under, new_bucket, user)
minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"})
if not minetest.is_creative_enabled(user:get_player_name()) then
new_bucket = ItemStack("mcl_buckets:bucket_water")

View File

@ -67,25 +67,45 @@ minetest.register_node("mcl_cauldrons:cauldron", {
})
function mcl_cauldrons.set_cauldron(pos, type, level)
if cauldrons_list["mcl_cauldrons:cauldron_"..type.."_"..level] then
minetest.set_node(pos, {name="mcl_cauldrons:cauldron_"..type.."_"..level})
minetest.set_node(pos, {name = mcl_cauldrons.get_cauldron_string(type, level)})
return true
end
function mcl_cauldrons.take_cauldron(pos, itemstack, user)
if user and not minetest.is_creative_enabled(user:get_player_name()) then
return ItemStack("mcl_buckets:bucket_water")
else
minetest.log("error", "[mcl_cauldrons] trying to set invalid cauldron")
return false
return itemstack
end
end
function mcl_cauldrons.take_cauldron(pos, itemstack, sound)
function mcl_cauldrons.get_cauldron_string(type, level)
if cauldrons_list["mcl_cauldrons:cauldron_"..type.."_"..level] then
return "mcl_cauldrons:cauldron_"..type.."_"..level
else
minetest.log("warning", "[mcl_cauldrons] trying to get string from invalid cauldron params")
return "air"
end
end
function mcl_cauldrons.add_cauldron_level(pos, number)
local nn = minetest.get_node(pos).name
if cauldrons_list[nn] and number >= 1 and number <= 3 then
local nb = minetest.get_item_group(nn, "cauldron_filled")
if nb > 3 then nb = 3 end
else
minetest.log("error", "[mcl_cauldrons] trying to add level to not cauldron node at "..minetest.serialize(pos))
end
return
end
function mcl_cauldrons.register_cauldron_type(name, desc, texture)
function mcl_cauldrons.register_cauldron_type(def)
for water_level = 1,3 do
local id = "mcl_cauldrons:cauldron_"..name.."_"..water_level
local id = "mcl_cauldrons:cauldron_"..def.name.."_"..water_level
cauldrons_list[id] = true
minetest.register_node(id, {
description = string.format(desc, water_level),
description = string.format(def.desc, water_level),
_doc_items_create_entry = false,
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false,
drawtype = "nodebox",
@ -96,7 +116,7 @@ function mcl_cauldrons.register_cauldron_type(name, desc, texture)
collision_box = cauldron_nodeboxes[0],
selection_box = { type = "regular" },
tiles = {
"("..texture.."^[verticalframe:16:0"..")^mcl_cauldrons_cauldron_top.png",
"("..def.texture.."^[verticalframe:16:0"..")^mcl_cauldrons_cauldron_top.png",
"mcl_cauldrons_cauldron_inner.png^mcl_cauldrons_cauldron_bottom.png",
"mcl_cauldrons_cauldron_side.png"
},
@ -113,50 +133,13 @@ function mcl_cauldrons.register_cauldron_type(name, desc, texture)
end
end
-- Template function for cauldrons with water
local register_filled_cauldron = function(water_level, description, river_water)
local id = "mcl_cauldrons:cauldron_"..water_level
local water_tex
if river_water then
id = id .. "r"
water_tex = "default_river_water_source_animated.png^[verticalframe:16:0"
else
water_tex = "default_water_source_animated.png^[verticalframe:16:0"
end
minetest.register_node(id, {
description = description,
_doc_items_create_entry = false,
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false,
drawtype = "nodebox",
paramtype = "light",
is_ground_content = false,
groups = {pickaxey=1, not_in_creative_inventory=1, cauldron=(1+water_level), cauldron_filled=water_level, comparator_signal=water_level},
node_box = cauldron_nodeboxes[water_level],
collision_box = cauldron_nodeboxes[0],
selection_box = { type = "regular" },
tiles = {
"("..water_tex..")^mcl_cauldrons_cauldron_top.png",
"mcl_cauldrons_cauldron_inner.png^mcl_cauldrons_cauldron_bottom.png",
"mcl_cauldrons_cauldron_side.png"
},
sounds = mcl_sounds.node_sound_metal_defaults(),
drop = "mcl_cauldrons:cauldron",
_mcl_hardness = 2,
_mcl_blast_resistance = 2,
mcl_cauldrons.register_cauldron_type({
name = "water",
bucket = "mcl_buckets:bucket_water",
desc = S("Cauldron (%s/3 Water)"),
texture = "default_water_source_animated.png"
})
-- Add entry aliases for the Help
if minetest.get_modpath("doc") then
doc.add_entry_alias("nodes", "mcl_cauldrons:cauldron", "nodes", id)
end
end
-- Filled cauldrons (3 levels)
--register_filled_cauldron(1, S("Cauldron (1/3 Water)"))
--register_filled_cauldron(2, S("Cauldron (2/3 Water)"))
--register_filled_cauldron(3, S("Cauldron (3/3 Water)"))
mcl_cauldrons.register_cauldron_type("water", S("Cauldron (%s/3 Water)"), "default_water_source_animated.png")
if minetest.get_modpath("mclx_core") then
--register_filled_cauldron(1, S("Cauldron (1/3 River Water)"), true)
--register_filled_cauldron(2, S("Cauldron (2/3 River Water)"), true)