forked from VoxeLibre/VoxeLibre
Compare commits
34 Commits
master
...
api-cauldr
Author | SHA1 | Date |
---|---|---|
AFCMS | 225650904c | |
AFCMS | 1b144d507d | |
AFCMS | 738519f0a4 | |
AFCMS | d1ca012ea0 | |
AFCMS | a18a2127c5 | |
AFCMS | 7156afcd03 | |
AFCMS | e3b3e2343b | |
AFCMS | 6f23351126 | |
AFCMS | a99619774d | |
AFCMS | 989384f362 | |
AFCMS | 69da355f96 | |
AFCMS | 297d4e707c | |
AFCMS | b4033ddfc9 | |
AFCMS | c35c8a1713 | |
AFCMS | 64b49ba719 | |
AFCMS | d00490c86f | |
AFCMS | 8c91d23eb8 | |
AFCMS | 294cb3eb7d | |
AFCMS | cf4d57e584 | |
AFCMS | 890b95bb49 | |
AFCMS | 8611d27f1d | |
AFCMS | 59892abf6d | |
AFCMS | e69365f44d | |
AFCMS | aa0c7bd2cf | |
AFCMS | 2b73c16c69 | |
AFCMS | 36f479b2ec | |
AFCMS | 717a18ef16 | |
AFCMS | 9b0c87dabc | |
AFCMS | 3c83898095 | |
AFCMS | 6ebae965f6 | |
AFCMS | 5e5b3ebf75 | |
AFCMS | e68736a040 | |
AFCMS | 72149a2c56 | |
AFCMS | 182e825303 |
|
@ -212,46 +212,21 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", {
|
|||
end
|
||||
end
|
||||
|
||||
minetest.add_node(pointed_thing.under, {name="air"})
|
||||
minetest.set_node(pointed_thing.under, {name="air"})
|
||||
sound_take(nn, pointed_thing.under)
|
||||
|
||||
if mod_doc and doc.entry_exists("nodes", nn) then
|
||||
doc.mark_entry_as_revealed(user:get_player_name(), "nodes", nn)
|
||||
end
|
||||
|
||||
elseif nn == "mcl_cauldrons:cauldron_3" then
|
||||
-- Take water out of full cauldron
|
||||
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")
|
||||
end
|
||||
sound_take("mcl_core:water_source", pointed_thing.under)
|
||||
elseif nn == "mcl_cauldrons:cauldron_3r" then
|
||||
-- Take river water out of full cauldron
|
||||
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_river_water")
|
||||
end
|
||||
sound_take("mclx_core:river_water_source", pointed_thing.under)
|
||||
elseif minetest.get_item_group(nn, "cauldron") then
|
||||
new_bucket = mcl_cauldrons.take_cauldron(pointed_thing.under, new_bucket, user)
|
||||
end
|
||||
|
||||
-- Add liquid bucket and put it into inventory, if possible.
|
||||
-- Drop new bucket otherwise.
|
||||
if new_bucket then
|
||||
if itemstack:get_count() == 1 then
|
||||
return new_bucket
|
||||
else
|
||||
local inv = user:get_inventory()
|
||||
if inv:room_for_item("main", new_bucket) then
|
||||
inv:add_item("main", new_bucket)
|
||||
else
|
||||
minetest.add_item(user:get_pos(), new_bucket)
|
||||
end
|
||||
if not minetest.is_creative_enabled(user:get_player_name()) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
if minetest.is_creative_enabled(user:get_player_name()) then --TODO
|
||||
itemstack:take_item()
|
||||
end
|
||||
end,
|
||||
_on_dispense = function(stack, pos, droppos, dropnode, dropdir)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name = mcl_buckets
|
||||
author = Kahrl
|
||||
description =
|
||||
depends = mcl_worlds
|
||||
depends = mcl_worlds, mcl_cauldrons
|
||||
optional_depends = mcl_core, mclx_core, doc
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ if mod_mcl_core then
|
|||
if minetest.get_item_group(nn, "cauldron") ~= 0 then
|
||||
-- Put water into cauldron
|
||||
if nn ~= "mcl_cauldrons:cauldron_3" then
|
||||
minetest.set_node(pos, {name="mcl_cauldrons:cauldron_3"})
|
||||
mcl_cauldrons.set_cauldron_level(pos, "water", 3)
|
||||
end
|
||||
sound_place("mcl_core:water_source", pos)
|
||||
return false
|
||||
|
@ -104,7 +104,7 @@ if mod_mclx_core then
|
|||
if minetest.get_item_group(nn, "cauldron") ~= 0 then
|
||||
-- Put water into cauldron
|
||||
if nn ~= "mcl_cauldrons:cauldron_3r" then
|
||||
minetest.set_node(pos, {name="mcl_cauldrons:cauldron_3r"})
|
||||
mcl_cauldrons.set_cauldron(pos, "river_water", 3)
|
||||
end
|
||||
sound_place("mcl_core:water_source", pos)
|
||||
return false
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
# mcl_cauldrons
|
||||
|
||||
This mod add an API to add cauldrons to mcl.
|
||||
|
||||
## mcl_cauldrons.is_cauldron(name)
|
||||
return true if name is cauldron, false overwise.
|
||||
|
||||
## mcl_cauldrons.get_cauldron_string(type, level)
|
||||
return itemstring of cauldron with <type> and <level>
|
||||
e.g: `mcl_cauldrons.get_cauldron_string("water", 1) --return itemstring of a water cauldron with 1 level of water`
|
||||
|
||||
## mcl_cauldrons.take_cauldron(pos, itemstack, user, sounds)
|
||||
empty cauldron at `pos`
|
||||
return `bucket` field of the cauldron def if user is player, itemstack overwise.
|
||||
* pos: position of the cauldron
|
||||
* itemstack: will be return if `bucket` field isn't defined in cauldron def or user is nil or not player.
|
||||
* user: player who takes cauldron
|
||||
* sounds: sounds table. If not nil, dug sound will be played.
|
||||
|
||||
## mcl_cauldrons.register_cauldron_type(def)
|
||||
def can have these fields:
|
||||
* name: name of the liquid e.g: "water"
|
||||
* bucket: string of the bucket item. can be nil. e.g: "mcl_buckets:bucket_water"
|
||||
* desc: description of the item. %s will be replaced by the level. e.g: "Water Cauldron %s/3 full"
|
||||
* texture: texture of the flowing liquid e.g: "mcl_core_water_flowing.png"
|
||||
|
||||
## mcl_cauldrons.registered_cauldrons
|
||||
Table containing chauldrons def indexed by name.
|
|
@ -0,0 +1,159 @@
|
|||
local has_doc = minetest.get_modpath(minetest.get_current_modname())
|
||||
|
||||
local function survival_give(inv, original_item, itemstack)
|
||||
if inv:room_for_item("main", itemstack) then
|
||||
inv:add_item("main", itemstack)
|
||||
return original_item:take_item()
|
||||
else
|
||||
minetest.add_item(user:get_pos(), itemstack)
|
||||
return original_item
|
||||
end
|
||||
end
|
||||
|
||||
local function creative_give(inv, original_item, itemstack)
|
||||
if not inv:contains_item("main", itemstack) then
|
||||
inv:add_item("main", itemstack)
|
||||
return original_item
|
||||
end
|
||||
end
|
||||
|
||||
local function give_item(user, original_item, itemstack)
|
||||
local inv = user:get_inventory()
|
||||
if inv then
|
||||
if minetest.is_creative_enabled(user:get_player_name()) then
|
||||
creative_give(inv, original_item, itemstack)
|
||||
else
|
||||
survival_give(inv, original_item, itemstack)
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
|
||||
mcl_cauldrons.registered_cauldrons = {}
|
||||
|
||||
function mcl_cauldrons.register_cauldron_type(def)
|
||||
for water_level = 1,3 do
|
||||
local id = "mcl_cauldrons:cauldron_"..def.name.."_"..water_level
|
||||
mcl_cauldrons.registered_cauldrons[id] = def
|
||||
minetest.register_node(id, {
|
||||
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",
|
||||
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 = mcl_cauldrons.cauldron_nodeboxes[water_level],
|
||||
collision_box = mcl_cauldrons.cauldron_nodeboxes[0],
|
||||
selection_box = { type = "regular" },
|
||||
tiles = {
|
||||
"("..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"
|
||||
},
|
||||
sounds = mcl_sounds.node_sound_metal_defaults(),
|
||||
drop = "mcl_cauldrons:cauldron",
|
||||
_mcl_hardness = 2,
|
||||
_mcl_blast_resistance = 2,
|
||||
})
|
||||
-- Add entry aliases for the Help
|
||||
if has_doc then
|
||||
doc.add_entry_alias("nodes", "mcl_cauldrons:cauldron", "nodes", id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mcl_cauldrons.is_cauldron(name)
|
||||
return minetest.get_item_group(name, "cauldron") ~= 0
|
||||
end
|
||||
|
||||
-------------------------------------
|
||||
--Functions to get/set cauldron level
|
||||
-------------------------------------
|
||||
function mcl_cauldrons.get_cauldron_level(pos)
|
||||
local nn = minetest.get_node(pos)
|
||||
return minetest.get_item_group(nn.name, "cauldron")
|
||||
end
|
||||
|
||||
function mcl_cauldrons.set_cauldron_level(pos, type, level)
|
||||
return minetest.set_node(pos, {name = mcl_cauldrons.get_cauldron_string(type, level)})
|
||||
end
|
||||
|
||||
function mcl_cauldrons.add_cauldron_level(pos, type, number)
|
||||
local current = mcl_cauldrons.get_cauldron_level(pos)
|
||||
local number = current + number
|
||||
if number > 4 then number = 4 end
|
||||
if number < 1 then number = 1 end
|
||||
mcl_cauldrons.set_cauldron_level(pos, type, number)
|
||||
return number, not current == number
|
||||
end
|
||||
|
||||
function mcl_cauldrons.get_cauldron_string(type, level)
|
||||
if mcl_cauldrons.registered_cauldrons["mcl_cauldrons:cauldron_"..type.."_"..level] then
|
||||
return "mcl_cauldrons:cauldron_"..type.."_"..level
|
||||
elseif level == 0 then
|
||||
return "mcl_cauldrons:cauldron"
|
||||
else
|
||||
minetest.log("warning", "[mcl_cauldrons] trying to get string from invalid cauldron params")
|
||||
return "air"
|
||||
end
|
||||
end
|
||||
|
||||
----------------------------
|
||||
--Functions to take cauldron
|
||||
----------------------------
|
||||
function mcl_cauldrons.take_cauldron(pos, itemstack, user, sounds)
|
||||
local nn = minetest.get_node(pos)
|
||||
if mcl_cauldrons.registered_cauldrons[nn.name] and mcl_cauldrons.registered_cauldrons[nn.name].bucket then
|
||||
if user and not minetest.is_creative_enabled(user:get_player_name()) then
|
||||
minetest.set_node(pos, {name="mcl_cauldrons:cauldron"})
|
||||
if sounds then minetest.sound_play(sounds.dug, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true) end
|
||||
return give_item(user, original, ItemStack(mcl_cauldrons.registered_cauldrons[nn.name].bucket))
|
||||
else
|
||||
minetest.set_node(pos, {name="mcl_cauldrons:cauldron"})
|
||||
if sounds then minetest.sound_play(sounds.dug, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true) end
|
||||
return itemstack
|
||||
end
|
||||
else
|
||||
minetest.set_node(pos, {name="mcl_cauldrons:cauldron"})
|
||||
if sounds then minetest.sound_play(sounds.dug, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true) end
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
|
||||
function mcl_cauldrons.take_small_cauldron(pos, itemstack, user, sounds)
|
||||
local nn = minetest.get_node(pos)
|
||||
if mcl_cauldrons.registered_cauldrons[nn.name] and mcl_cauldrons.registered_cauldrons[nn.name].bottle then
|
||||
if user and not minetest.is_creative_enabled(user:get_player_name()) then
|
||||
local number, changed = mcl_cauldrons.add_cauldron_level(pos, mcl_cauldrons.registered_cauldrons[nn.name].name, -1)
|
||||
if changed then
|
||||
if sounds then minetest.sound_play(sounds.dug, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true) end
|
||||
local item_name = mcl_cauldrons.registered_cauldrons[nn.name].bottle
|
||||
local inv = placer:get_inventory()
|
||||
minetest.sound_play("mcl_potions_bottle_fill", {pos=pointed_thing.under, gain=0.5, max_hear_range=16}, true)
|
||||
if minetest.is_creative_enabled(placer:get_player_name()) then
|
||||
-- Don't replace empty bottle in creative for convenience reasons
|
||||
if not inv:contains_item("main", item_name) then
|
||||
inv:add_item("main", item_name)
|
||||
end
|
||||
elseif itemstack:get_count() == 1 then
|
||||
return item_name
|
||||
else
|
||||
return give_item(user, ItemStack(mcl_cauldrons.registered_cauldrons[nn.name].bucket))
|
||||
end
|
||||
end
|
||||
else
|
||||
local number = mcl_cauldrons.add_cauldron_level(pos, mcl_cauldrons.registered_cauldrons[nn.name].name, -1)
|
||||
if number ~= 0 then
|
||||
if sounds then minetest.sound_play(sounds.dug, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true) end
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
else
|
||||
local number = mcl_cauldrons.add_cauldron_level(pos, mcl_cauldrons.registered_cauldrons[nn.name].name, -1)
|
||||
if number ~= 0 then
|
||||
if sounds then minetest.sound_play(sounds.dug, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true) end
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
end
|
|
@ -1,143 +1,9 @@
|
|||
local S = minetest.get_translator("mcl_cauldron")
|
||||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||
|
||||
mcl_cauldrons = {}
|
||||
-- Cauldron mod, adds cauldrons.
|
||||
|
||||
-- TODO: Extinguish fire of burning entities
|
||||
|
||||
-- Convenience function because the cauldron nodeboxes are very similar
|
||||
local create_cauldron_nodebox = function(water_level)
|
||||
local floor_y
|
||||
if water_level == 0 then -- empty
|
||||
floor_y = -0.1875
|
||||
elseif water_level == 1 then -- 1/3 filled
|
||||
floor_y = 1/16
|
||||
elseif water_level == 2 then -- 2/3 filled
|
||||
floor_y = 4/16
|
||||
elseif water_level == 3 then -- full
|
||||
floor_y = 7/16
|
||||
end
|
||||
return {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.1875, -0.5, -0.375, 0.5, 0.5}, -- Left wall
|
||||
{0.375, -0.1875, -0.5, 0.5, 0.5, 0.5}, -- Right wall
|
||||
{-0.375, -0.1875, 0.375, 0.375, 0.5, 0.5}, -- Back wall
|
||||
{-0.375, -0.1875, -0.5, 0.375, 0.5, -0.375}, -- Front wall
|
||||
{-0.5, -0.3125, -0.5, 0.5, floor_y, 0.5}, -- Floor
|
||||
{-0.5, -0.5, -0.5, -0.375, -0.3125, -0.25}, -- Left front foot, part 1
|
||||
{-0.375, -0.5, -0.5, -0.25, -0.3125, -0.375}, -- Left front foot, part 2
|
||||
{-0.5, -0.5, 0.25, -0.375, -0.3125, 0.5}, -- Left back foot, part 1
|
||||
{-0.375, -0.5, 0.375, -0.25, -0.3125, 0.5}, -- Left back foot, part 2
|
||||
{0.375, -0.5, 0.25, 0.5, -0.3125, 0.5}, -- Right back foot, part 1
|
||||
{0.25, -0.5, 0.375, 0.375, -0.3125, 0.5}, -- Right back foot, part 2
|
||||
{0.375, -0.5, -0.5, 0.5, -0.3125, -0.25}, -- Right front foot, part 1
|
||||
{0.25, -0.5, -0.5, 0.375, -0.3125, -0.375}, -- Right front foot, part 2
|
||||
}
|
||||
}
|
||||
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"),
|
||||
_tt_help = S("Stores water"),
|
||||
_doc_items_longdesc = S("Cauldrons are used to store water and slowly fill up under rain."),
|
||||
_doc_items_usagehelp = S("Place a water pucket into the cauldron to fill it with water. Place an empty bucket on a full cauldron to retrieve the water. Place a water bottle into the cauldron to fill the cauldron to one third with water. Place a glass bottle in a cauldron with water to retrieve one third of the water."),
|
||||
wield_image = "mcl_cauldrons_cauldron.png",
|
||||
inventory_image = "mcl_cauldrons_cauldron.png",
|
||||
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, deco_block=1, cauldron=1},
|
||||
node_box = cauldron_nodeboxes[0],
|
||||
selection_box = { type = "regular" },
|
||||
tiles = {
|
||||
"mcl_cauldrons_cauldron_inner.png^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(),
|
||||
_mcl_hardness = 2,
|
||||
_mcl_blast_resistance = 2,
|
||||
})
|
||||
|
||||
-- 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,
|
||||
})
|
||||
|
||||
-- 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)"))
|
||||
|
||||
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)
|
||||
end
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mcl_cauldrons:cauldron",
|
||||
recipe = {
|
||||
{ "mcl_core:iron_ingot", "", "mcl_core:iron_ingot" },
|
||||
{ "mcl_core:iron_ingot", "", "mcl_core:iron_ingot" },
|
||||
{ "mcl_core:iron_ingot", "mcl_core:iron_ingot", "mcl_core:iron_ingot" },
|
||||
}
|
||||
})
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
dofile(modpath.."/utils.lua")
|
||||
dofile(modpath.."/api.lua")
|
||||
dofile(modpath.."/register.lua")
|
|
@ -1,3 +1,4 @@
|
|||
name = mcl_cauldrons
|
||||
description = Add cauldrons to mcl
|
||||
depends = mcl_core, mcl_sounds
|
||||
optional_depends = mclx_core, doc
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
mcl_cauldrons.register_cauldron_type({
|
||||
name = "water",
|
||||
bucket = "mcl_buckets:bucket_water",
|
||||
bottle = "mcl_potions:water",
|
||||
desc = S("Cauldron (%s/3 Water)"),
|
||||
texture = "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)
|
||||
--register_filled_cauldron(3, S("Cauldron (3/3 River Water)"), true)
|
||||
end
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mcl_cauldrons:cauldron",
|
||||
recipe = {
|
||||
{ "mcl_core:iron_ingot", "", "mcl_core:iron_ingot" },
|
||||
{ "mcl_core:iron_ingot", "", "mcl_core:iron_ingot" },
|
||||
{ "mcl_core:iron_ingot", "mcl_core:iron_ingot", "mcl_core:iron_ingot" },
|
||||
}
|
||||
})
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
for i = 1, 3 do --Backward compatibility
|
||||
minetest.register_alias("mcl_cauldrons:cauldron_"..i, "mcl_cauldrons:cauldron_water_"..i)
|
||||
end
|
||||
for i = 1, 3 do
|
||||
minetest.register_alias("mcl_cauldrons:cauldron_"..i.."r", "mcl_cauldrons:cauldron_river_water_"..i)
|
||||
end
|
|
@ -0,0 +1,63 @@
|
|||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
-- Convenience function because the cauldron nodeboxes are very similar
|
||||
local create_cauldron_nodebox = function(water_level)
|
||||
local floor_y
|
||||
if water_level == 0 then -- empty
|
||||
floor_y = -0.1875
|
||||
elseif water_level == 1 then -- 1/3 filled
|
||||
floor_y = 1/16
|
||||
elseif water_level == 2 then -- 2/3 filled
|
||||
floor_y = 4/16
|
||||
elseif water_level == 3 then -- full
|
||||
floor_y = 7/16
|
||||
end
|
||||
return {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.1875, -0.5, -0.375, 0.5, 0.5}, -- Left wall
|
||||
{0.375, -0.1875, -0.5, 0.5, 0.5, 0.5}, -- Right wall
|
||||
{-0.375, -0.1875, 0.375, 0.375, 0.5, 0.5}, -- Back wall
|
||||
{-0.375, -0.1875, -0.5, 0.375, 0.5, -0.375}, -- Front wall
|
||||
{-0.5, -0.3125, -0.5, 0.5, floor_y, 0.5}, -- Floor
|
||||
{-0.5, -0.5, -0.5, -0.375, -0.3125, -0.25}, -- Left front foot, part 1
|
||||
{-0.375, -0.5, -0.5, -0.25, -0.3125, -0.375}, -- Left front foot, part 2
|
||||
{-0.5, -0.5, 0.25, -0.375, -0.3125, 0.5}, -- Left back foot, part 1
|
||||
{-0.375, -0.5, 0.375, -0.25, -0.3125, 0.5}, -- Left back foot, part 2
|
||||
{0.375, -0.5, 0.25, 0.5, -0.3125, 0.5}, -- Right back foot, part 1
|
||||
{0.25, -0.5, 0.375, 0.375, -0.3125, 0.5}, -- Right back foot, part 2
|
||||
{0.375, -0.5, -0.5, 0.5, -0.3125, -0.25}, -- Right front foot, part 1
|
||||
{0.25, -0.5, -0.5, 0.375, -0.3125, -0.375}, -- Right front foot, part 2
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
mcl_cauldrons.cauldron_nodeboxes = {}
|
||||
for w=0,3 do
|
||||
mcl_cauldrons.cauldron_nodeboxes[w] = create_cauldron_nodebox(w)
|
||||
end
|
||||
|
||||
-- Empty cauldron
|
||||
minetest.register_node("mcl_cauldrons:cauldron", {
|
||||
description = S("Cauldron"),
|
||||
_tt_help = S("Stores water"),
|
||||
_doc_items_longdesc = S("Cauldrons are used to store water and slowly fill up under rain."),
|
||||
_doc_items_usagehelp = S("Place a water pucket into the cauldron to fill it with water. Place an empty bucket on a full cauldron to retrieve the water. Place a water bottle into the cauldron to fill the cauldron to one third with water. Place a glass bottle in a cauldron with water to retrieve one third of the water."),
|
||||
wield_image = "mcl_cauldrons_cauldron.png",
|
||||
inventory_image = "mcl_cauldrons_cauldron.png",
|
||||
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, deco_block=1, cauldron=1},
|
||||
node_box = mcl_cauldrons.cauldron_nodeboxes[0],
|
||||
selection_box = { type = "regular" },
|
||||
tiles = {
|
||||
"mcl_cauldrons_cauldron_inner.png^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(),
|
||||
_mcl_hardness = 2,
|
||||
_mcl_blast_resistance = 2,
|
||||
})
|
|
@ -75,61 +75,13 @@ minetest.register_craftitem("mcl_potions:glass_bottle", {
|
|||
from_liquid_source = true
|
||||
river_water = node.name == "mclx_core:river_water_source"
|
||||
-- Or reduce water level of cauldron by 1
|
||||
elseif string.sub(node.name, 1, 14) == "mcl_cauldrons:" then
|
||||
elseif mcl_cauldrons.is_cauldron(node.name) then
|
||||
local pname = placer:get_player_name()
|
||||
if minetest.is_protected(pointed_thing.under, pname) then
|
||||
minetest.record_protection_violation(pointed_thing.under, pname)
|
||||
return itemstack
|
||||
end
|
||||
if node.name == "mcl_cauldrons:cauldron_3" then
|
||||
get_water = true
|
||||
minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron_2"})
|
||||
elseif node.name == "mcl_cauldrons:cauldron_2" then
|
||||
get_water = true
|
||||
minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron_1"})
|
||||
elseif node.name == "mcl_cauldrons:cauldron_1" then
|
||||
get_water = true
|
||||
minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"})
|
||||
elseif node.name == "mcl_cauldrons:cauldron_3r" then
|
||||
get_water = true
|
||||
river_water = true
|
||||
minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron_2r"})
|
||||
elseif node.name == "mcl_cauldrons:cauldron_2r" then
|
||||
get_water = true
|
||||
river_water = true
|
||||
minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron_1r"})
|
||||
elseif node.name == "mcl_cauldrons:cauldron_1r" then
|
||||
get_water = true
|
||||
river_water = true
|
||||
minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"})
|
||||
end
|
||||
end
|
||||
if get_water then
|
||||
local water_bottle
|
||||
if river_water then
|
||||
water_bottle = ItemStack("mcl_potions:river_water")
|
||||
else
|
||||
water_bottle = ItemStack("mcl_potions:water")
|
||||
end
|
||||
-- Replace with water bottle, if possible, otherwise
|
||||
-- place the water potion at a place where's space
|
||||
local inv = placer:get_inventory()
|
||||
minetest.sound_play("mcl_potions_bottle_fill", {pos=pointed_thing.under, gain=0.5, max_hear_range=16}, true)
|
||||
if minetest.is_creative_enabled(placer:get_player_name()) then
|
||||
-- Don't replace empty bottle in creative for convenience reasons
|
||||
if not inv:contains_item("main", water_bottle) then
|
||||
inv:add_item("main", water_bottle)
|
||||
end
|
||||
elseif itemstack:get_count() == 1 then
|
||||
return water_bottle
|
||||
else
|
||||
if inv:room_for_item("main", water_bottle) then
|
||||
inv:add_item("main", water_bottle)
|
||||
else
|
||||
minetest.add_item(placer:get_pos(), water_bottle)
|
||||
end
|
||||
itemstack:take_item()
|
||||
end
|
||||
mcl_cauldrons.take_small_cauldron(pointed_thing.under, itemstack, placer, {dug = "mcl_potions_bottle_fill"})
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
|
@ -154,31 +106,6 @@ local potion_image = function(colorstring, opacity)
|
|||
return "mcl_potions_potion_overlay.png^[colorize:"..colorstring..":"..tostring(opacity).."^mcl_potions_potion_bottle.png"
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- Cauldron fill up rules:
|
||||
-- Adding any water increases the water level by 1, preserving the current water type
|
||||
local cauldron_levels = {
|
||||
-- start = { add water, add river water }
|
||||
{ "", "_1", "_1r" },
|
||||
{ "_1", "_2", "_2" },
|
||||
{ "_2", "_3", "_3" },
|
||||
{ "_1r", "_2r", "_2r" },
|
||||
{ "_2r", "_3r", "_3r" },
|
||||
}
|
||||
local fill_cauldron = function(cauldron, water_type)
|
||||
local base = "mcl_cauldrons:cauldron"
|
||||
for i=1, #cauldron_levels do
|
||||
if cauldron == base .. cauldron_levels[i][1] then
|
||||
if water_type == "mclx_core:river_water_source" then
|
||||
return base .. cauldron_levels[i][3]
|
||||
else
|
||||
return base .. cauldron_levels[i][2]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Itemstring of potions is “mcl_potions:<NBT Potion Tag>”
|
||||
|
||||
minetest.register_craftitem("mcl_potions:water", {
|
||||
|
|
Loading…
Reference in New Issue