Merge pull request 'Lava cauldrons and other cauldron/bucket fixes' (#2350) from lava_cauldron into master

Reviewed-on: MineClone2/MineClone2#2350
Reviewed-by: MysticTempest <mystictempest@noreply.git.minetest.land>
This commit is contained in:
cora 2022-06-22 10:41:20 +00:00
commit ecbc94e822
4 changed files with 76 additions and 60 deletions

View File

@ -29,15 +29,15 @@ local is_creative_enabled = minetest.is_creative_enabled
local is_protected = minetest.is_protected
local record_protection_violation = minetest.record_protection_violation
if mod_mcl_core then
minetest.register_craft({
output = "mcl_buckets:bucket_empty 1",
recipe = {
{"mcl_core:iron_ingot", "", "mcl_core:iron_ingot"},
{"", "mcl_core:iron_ingot", ""},
},
})
end
minetest.register_craft({
output = "mcl_buckets:bucket_empty 1",
recipe = {
{"mcl_core:iron_ingot", "", "mcl_core:iron_ingot"},
{"", "mcl_core:iron_ingot", ""},
},
})
mcl_buckets = {
liquids = {},
@ -88,9 +88,7 @@ end
local pointable_sources = {}
local function bucket_raycast(user)
--local pos = user:get_pos()
local pos = user:get_pos()
--local pos = vector.add(user:get_pos(), user:get_bone_position("Head_Control"))
pos.y = pos.y + user:get_properties().eye_height
local look_dir = user:get_look_dir()
look_dir = vector.multiply(look_dir, 5)
@ -100,7 +98,6 @@ local function bucket_raycast(user)
if ray then
for pointed_thing in ray do
if pointed_thing and pointable_sources[get_node(pointed_thing.above).name] then
--minetest.chat_send_all("found!")
return {under=pointed_thing.under,above=pointed_thing.above}
end
end
@ -242,7 +239,6 @@ local function on_place_bucket_empty(itemstack, user, pointed_thing)
if liquid_name then
local liquid_def = mcl_buckets.liquids[liquid_name]
if liquid_def then
--minetest.chat_send_all("test")
-- Fill bucket, but not in Creative Mode
-- FIXME: remove this line
--if not is_creative_enabled(user:get_player_name()) then
@ -282,6 +278,12 @@ local function on_place_bucket_empty(itemstack, user, pointed_thing)
new_bucket = ItemStack("mcl_buckets:bucket_river_water")
end
sound_take("mclx_core:river_water_source", pointed_thing.under)
elseif nn == "mcl_cauldrons:cauldron_3_lava" then
set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"})
if not is_creative_enabled(user:get_player_name()) then
new_bucket = ItemStack("mcl_buckets:bucket_lava")
end
sound_take("mcl_core:lava_source", pointed_thing.under)
end
if new_bucket then
return give_bucket(new_bucket, itemstack, user)
@ -366,7 +368,6 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", {
_doc_items_longdesc = S("A bucket can be used to collect and release liquids."),
_doc_items_usagehelp = S("Punch a liquid source to collect it. You can then use the filled bucket to place the liquid somewhere else."),
_tt_help = S("Collects liquids"),
--liquids_pointable = true,
inventory_image = "bucket.png",
stack_max = 16,
_on_dispense = function(stack, pos, droppos, dropnode, dropdir)

View File

@ -10,13 +10,6 @@ local function sound_place(itemname, pos)
end
end
--[[local sound_take = function(itemname, pos)
local def = minetest.registered_nodes[itemname]
if def and def.sounds and def.sounds.dug then
minetest.sound_play(def.sounds.dug, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true)
end
end]]
if mod_mcl_core then
-- Lava bucket
mcl_buckets.register_liquid({
@ -29,11 +22,21 @@ if mod_mcl_core then
end
end,
source_take = {"mcl_core:lava_source", "mcl_nether:nether_lava_source"},
on_take = function(user)
if has_awards and user and user:is_player() then
awards.unlock(user:get_player_name(), "mcl:hotStuff")
end
end,
on_take = function(user)
if has_awards and user and user:is_player() then
awards.unlock(user:get_player_name(), "mcl:hotStuff")
end
end,
extra_check = function(pos, placer)
local nn = minetest.get_node(pos).name
if minetest.get_item_group(nn, "cauldron") ~= 0 then
if nn ~= "mcl_cauldrons:cauldron_3_lava" then
minetest.set_node(pos, {name="mcl_cauldrons:cauldron_3_lava"})
end
sound_place("mcl_core:lava_source", pos)
return false, true
end
end,
bucketname = "mcl_buckets:bucket_lava",
inventory_image = "bucket_lava.png",
name = S("Lava Bucket"),

View File

@ -5,7 +5,7 @@ local S = minetest.get_translator(minetest.get_current_modname())
-- TODO: Extinguish fire of burning entities
-- Convenience function because the cauldron nodeboxes are very similar
local create_cauldron_nodebox = function(water_level)
local function create_cauldron_nodebox(water_level)
local floor_y
if water_level == 0 then -- empty
floor_y = -0.1875
@ -36,12 +36,6 @@ local create_cauldron_nodebox = function(water_level)
}
end
local cauldron_nodeboxes = {}
for w=0,3 do
cauldron_nodeboxes[w] = create_cauldron_nodebox(w)
end
-- Empty cauldron
minetest.register_node("mcl_cauldrons:cauldron", {
description = S("Cauldron"),
@ -55,7 +49,7 @@ minetest.register_node("mcl_cauldrons:cauldron", {
paramtype = "light",
is_ground_content = false,
groups = {pickaxey=1, deco_block=1, cauldron=1},
node_box = cauldron_nodeboxes[0],
node_box = create_cauldron_nodebox(0),
selection_box = { type = "regular" },
tiles = {
"mcl_cauldrons_cauldron_inner.png^mcl_cauldrons_cauldron_top.png",
@ -68,12 +62,15 @@ minetest.register_node("mcl_cauldrons:cauldron", {
})
-- Template function for cauldrons with water
local register_filled_cauldron = function(water_level, description, river_water)
local function register_filled_cauldron(water_level, description, liquid)
local id = "mcl_cauldrons:cauldron_"..water_level
local water_tex
if river_water then
if liquid == "river_water" then
id = id .. "r"
water_tex = "default_river_water_source_animated.png^[verticalframe:16:0"
elseif liquid == "lava" then
id = id .. "_lava"
water_tex = "default_lava_source_animated.png^[verticalframe:16:0"
else
water_tex = "default_water_source_animated.png^[verticalframe:16:0"
end
@ -85,8 +82,8 @@ local register_filled_cauldron = function(water_level, description, river_water)
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],
node_box = create_cauldron_nodebox(water_level),
collision_box = create_cauldron_nodebox(0),
selection_box = { type = "regular" },
tiles = {
"("..water_tex..")^mcl_cauldrons_cauldron_top.png",
@ -106,14 +103,12 @@ local register_filled_cauldron = function(water_level, description, river_water)
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)"))
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)
register_filled_cauldron(3, S("Cauldron (3/3 River Water)"), true)
for i=1,3 do
register_filled_cauldron(i, S("Cauldron (" ..i .. "/3 Water)"))
register_filled_cauldron(i, S("Cauldron (" ..i .. "/3 Water)"),"lava")
if minetest.get_modpath("mclx_core") then
register_filled_cauldron(i, S("Cauldron (" ..i .. "/3 Water)"),"river_water")
end
end
minetest.register_craft({
@ -125,19 +120,36 @@ minetest.register_craft({
}
})
minetest.register_abm({
label = "cauldrons",
nodenames = {"group:cauldron_filled"},
interval = 0.5,
chance = 1,
action = function(pos, node)
for _, obj in pairs(minetest.get_objects_inside_radius(pos, 0.4)) do
if mcl_burning.is_burning(obj) then
mcl_burning.extinguish(obj)
local new_group = minetest.get_item_group(node.name, "cauldron_filled") - 1
minetest.swap_node(pos, {name = "mcl_cauldrons:cauldron" .. (new_group == 0 and "" or "_" .. new_group)})
break
local function cauldron_extinguish(obj,pos)
local node = minetest.get_node(pos)
if mcl_burning.is_burning(obj) then
mcl_burning.extinguish(obj)
local new_group = minetest.get_item_group(node.name, "cauldron_filled") - 1
minetest.swap_node(pos, {name = "mcl_cauldrons:cauldron" .. (new_group == 0 and "" or "_" .. new_group)})
end
end
local etime = 0
minetest.register_globalstep(function(dtime)
etime = dtime + etime
if etime < 0.5 then return end
etime = 0
for _,pl in pairs(minetest.get_connected_players()) do
local n = minetest.find_node_near(pl:get_pos(),0.4,{"group:cauldron_filled"},true)
if n and not minetest.get_node(n).name:find("lava") then
cauldron_extinguish(pl,n)
elseif n and minetest.get_node(n).name:find("lava") then
mcl_burning.set_on_fire(pl, 5)
end
end
for _,ent in pairs(minetest.luaentities) do
if ent.object:get_pos() and ent.is_mob then
local n = minetest.find_node_near(ent.object:get_pos(),0.4,{"group:cauldron_filled"},true)
if n and not minetest.get_node(n).name:find("lava") then
cauldron_extinguish(ent.object,n)
elseif n and minetest.get_node(n).name:find("lava") then
mcl_burning.set_on_fire(ent.object, 5)
end
end
end
})
end)

View File

@ -1,3 +1,3 @@
name = mcl_cauldrons
depends = mcl_core, mcl_sounds
optional_depends = mclx_core, doc
optional_depends = mclx_core, doc, mcl_burning