1
0
Fork 0

Add river water support for bottles and cauldrons

objects
Wuzzy 2017-11-30 19:27:57 +01:00
parent 99af7618ee
commit 142317c65a
5 changed files with 133 additions and 41 deletions

View File

@ -50,6 +50,7 @@ Please read <http://minecraft.gamepedia.com/Breaking> to learn how digging times
* `destroys_items=1`: If an item happens to be *inside* this node, the item will be destroyed * `destroys_items=1`: If an item happens to be *inside* this node, the item will be destroyed
* `no_eat_delay=1`: Only for foodstuffs. When eating this, all eating delays are ignored. * `no_eat_delay=1`: Only for foodstuffs. When eating this, all eating delays are ignored.
* `can_eat_when_full=1`: Only for foodstuffs. This item can be eaten when the user has a full hunger bar * `can_eat_when_full=1`: Only for foodstuffs. This item can be eaten when the user has a full hunger bar
* `cauldron`: Cauldron. 1: Empty. 2-4: Water height
#### Footnotes #### Footnotes

View File

@ -206,6 +206,13 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", {
new_bucket = ItemStack("mcl_buckets:bucket_water") new_bucket = ItemStack("mcl_buckets:bucket_water")
end end
sound_take("mcl_core:water_source", pointed_thing.under) 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.settings:get_bool("creative_mode") then
new_bucket = ItemStack("mcl_buckets:bucket_river_water")
end
sound_take("mclx_core:river_water_source", pointed_thing.under)
end end
-- Add liquid bucket and put it into inventory, if possible. -- Add liquid bucket and put it into inventory, if possible.
@ -260,14 +267,11 @@ if mod_mcl_core then
function(pos) function(pos)
local nn = minetest.get_node(pos).name local nn = minetest.get_node(pos).name
-- Pour water into cauldron -- Pour water into cauldron
if (nn == "mcl_cauldrons:cauldron" or if minetest.get_item_group(nn, "cauldron") ~= 0 then
nn == "mcl_cauldrons:cauldron_1" or
nn == "mcl_cauldrons:cauldron_2") then
-- Put water into cauldron -- Put water into cauldron
minetest.set_node(pos, {name="mcl_cauldrons:cauldron_3"}) if nn ~= "mcl_cauldrons:cauldron_3" then
sound_place("mcl_core:water_source", pos) minetest.set_node(pos, {name="mcl_cauldrons:cauldron_3"})
return false end
elseif nn == "mcl_cauldrons:cauldron_3" then
sound_place("mcl_core:water_source", pos) sound_place("mcl_core:water_source", pos)
return false return false
-- Evaporate water if used in Nether (except on cauldron) -- Evaporate water if used in Nether (except on cauldron)
@ -295,19 +299,21 @@ if mod_mclx_core then
"Right-click on any block to empty the bucket and put a river water source on this spot.", "Right-click on any block to empty the bucket and put a river water source on this spot.",
function(pos) function(pos)
local nn = minetest.get_node(pos).name local nn = minetest.get_node(pos).name
-- TODO: Implement cauldron support. -- Pour into cauldron
-- Ignore cauldron if minetest.get_item_group(nn, "cauldron") ~= 0 then
if (nn == "mcl_cauldrons:cauldron" or -- Put water into cauldron
nn == "mcl_cauldrons:cauldron_1" or if nn ~= "mcl_cauldrons:cauldron_3r" then
nn == "mcl_cauldrons:cauldron_2" or minetest.set_node(pos, {name="mcl_cauldrons:cauldron_3r"})
nn == "mcl_cauldrons:cauldron_3") then end
return false sound_place("mcl_core:water_source", pos)
end
-- Evaporate water if used in Nether (except on cauldron)
local dim = mcl_worlds.pos_to_dimension(pos)
if dim == "nether" then
minetest.sound_play("fire_extinguish_flame", {pos = pos, gain = 0.25, max_hear_distance = 16})
return false return false
else
-- Evaporate water if used in Nether (except on cauldron)
local dim = mcl_worlds.pos_to_dimension(pos)
if dim == "nether" then
minetest.sound_play("fire_extinguish_flame", {pos = pos, gain = 0.25, max_hear_distance = 16})
return false
end
end end
end, end,
{ water_bucket = 1 } { water_bucket = 1 }

View File

@ -1,3 +1,4 @@
mcl_core mcl_core
mclx_core?
mcl_sounds mcl_sounds
doc? doc?

View File

@ -51,7 +51,7 @@ minetest.register_node("mcl_cauldrons:cauldron", {
paramtype = "light", paramtype = "light",
is_ground_content = false, is_ground_content = false,
sunlight_propagates = true, sunlight_propagates = true,
groups = {pickaxey=1, deco_block=1}, groups = {pickaxey=1, deco_block=1, cauldron=1},
node_box = cauldron_nodeboxes[0], node_box = cauldron_nodeboxes[0],
selection_box = { type = "regular" }, selection_box = { type = "regular" },
tiles = { tiles = {
@ -65,20 +65,28 @@ minetest.register_node("mcl_cauldrons:cauldron", {
}) })
-- Template function for cauldrons with water -- Template function for cauldrons with water
local register_filled_cauldron = function(water_level, description) local register_filled_cauldron = function(water_level, description, river_water)
minetest.register_node("mcl_cauldrons:cauldron_"..water_level, { 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, description = description,
_doc_items_create_entry = false, _doc_items_create_entry = false,
drawtype = "nodebox", drawtype = "nodebox",
paramtype = "light", paramtype = "light",
is_ground_content = false, is_ground_content = false,
sunlight_propagates = true, sunlight_propagates = true,
groups = {pickaxey=1, not_in_creative_inventory=1}, groups = {pickaxey=1, not_in_creative_inventory=1, cauldron=(1+water_level)},
node_box = cauldron_nodeboxes[water_level], node_box = cauldron_nodeboxes[water_level],
collision_box = cauldron_nodeboxes[0], collision_box = cauldron_nodeboxes[0],
selection_box = { type = "regular" }, selection_box = { type = "regular" },
tiles = { tiles = {
"(default_water_source_animated.png^[verticalframe:16:0)^mcl_cauldrons_cauldron_top.png", "("..water_tex..")^mcl_cauldrons_cauldron_top.png",
"mcl_cauldrons_cauldron_inner.png^mcl_cauldrons_cauldron_bottom.png", "mcl_cauldrons_cauldron_inner.png^mcl_cauldrons_cauldron_bottom.png",
"mcl_cauldrons_cauldron_side.png" "mcl_cauldrons_cauldron_side.png"
}, },
@ -90,14 +98,20 @@ local register_filled_cauldron = function(water_level, description)
-- Add entry aliases for the Help -- Add entry aliases for the Help
if minetest.get_modpath("doc") then if minetest.get_modpath("doc") then
doc.add_entry_alias("nodes", "mcl_cauldrons:cauldron", "nodes", "mcl_cauldrons:cauldron_"..water_level) doc.add_entry_alias("nodes", "mcl_cauldrons:cauldron", "nodes", id)
end end
end end
-- Filled crauldrons (3 levels) -- Filled cauldrons (3 levels)
register_filled_cauldron(1, "Cauldron (One Third Full)") register_filled_cauldron(1, "Cauldron (1/3 Water)")
register_filled_cauldron(2, "Cauldron (Two Thirds Full)") register_filled_cauldron(2, "Cauldron (2/3 Water)")
register_filled_cauldron(3, "Cauldron (Full)") register_filled_cauldron(3, "Cauldron (3/3 Water)")
if minetest.get_modpath("mclx_core") then
register_filled_cauldron(1, "Cauldron (1/3 River Water)", true)
register_filled_cauldron(2, "Cauldron (2/3 River Water)", true)
register_filled_cauldron(3, "Cauldron (3/3 River Water)", true)
end
minetest.register_craft({ minetest.register_craft({
output = "mcl_cauldrons:cauldron", output = "mcl_cauldrons:cauldron",

View File

@ -37,11 +37,13 @@ minetest.register_craftitem("mcl_potions:glass_bottle", {
-- Try to fill glass bottle with water -- Try to fill glass bottle with water
local get_water = false local get_water = false
local river_water = false
if not def then if not def then
-- Unknown node: no-op -- Unknown node: no-op
elseif def.groups and def.groups.water and def.liquidtype == "source" then elseif def.groups and def.groups.water and def.liquidtype == "source" then
-- Water source -- Water source
get_water = true get_water = true
river_water = node.name == "mclx_core:river_water_source"
-- Or reduce water level of cauldron by 1 -- Or reduce water level of cauldron by 1
elseif node.name == "mcl_cauldrons:cauldron_3" then elseif node.name == "mcl_cauldrons:cauldron_3" then
get_water = true get_water = true
@ -52,11 +54,28 @@ minetest.register_craftitem("mcl_potions:glass_bottle", {
elseif node.name == "mcl_cauldrons:cauldron_1" then elseif node.name == "mcl_cauldrons:cauldron_1" then
get_water = true get_water = true
minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"}) 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 if get_water then
-- Replace with water bottle, if possible, otherwise -- Replace with water bottle, if possible, otherwise
-- place the water potion at a place where's space -- place the water potion at a place where's space
local water_bottle = ItemStack("mcl_potions:potion_water") local water_bottle
if river_water then
water_bottle = ItemStack("mcl_potions:potion_river_water")
else
water_bottle = ItemStack("mcl_potions:potion_water")
end
minetest.sound_play("mcl_potions_bottle_fill", {pos=pointed_thing.under, gain=0.5, max_hear_range=16}) minetest.sound_play("mcl_potions_bottle_fill", {pos=pointed_thing.under, gain=0.5, max_hear_range=16})
if itemstack:get_count() == 1 then if itemstack:get_count() == 1 then
return water_bottle return water_bottle
@ -93,6 +112,27 @@ local potion_image = function(colorstring, opacity)
return "mcl_potions_potion_bottle_drinkable.png^(mcl_potions_potion_overlay.png^[colorize:"..colorstring..":"..tostring(opacity)..")" return "mcl_potions_potion_bottle_drinkable.png^(mcl_potions_potion_overlay.png^[colorize:"..colorstring..":"..tostring(opacity)..")"
end end
local cauldron_levels = {
-- start = { add water, add river water, take }
{ "", "_1", "_1r", nil },
{ "_1", "_2", "_2", "" },
{ "_2", "_3", "_3", "_1" },
{ "_1r", "_2", "_2r", "" },
{ "_2r", "_3r", "_3r", "_1r" },
}
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:potion_<NBT Potion Tag>” -- Itemstring of potions is “mcl_potions:potion_<NBT Potion Tag>”
minetest.register_craftitem("mcl_potions:potion_water", { minetest.register_craftitem("mcl_potions:potion_water", {
@ -102,7 +142,7 @@ minetest.register_craftitem("mcl_potions:potion_water", {
stack_max = 1, stack_max = 1,
inventory_image = potion_image("#0000FF"), inventory_image = potion_image("#0000FF"),
wield_image = potion_image("#0000FF"), wield_image = potion_image("#0000FF"),
groups = {brewitem=1, food=3, can_eat_when_full=1}, groups = {brewitem=1, food=3, can_eat_when_full=1, water_bottle=1},
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type == "node" then if pointed_thing.type == "node" then
local node = minetest.get_node(pointed_thing.under) local node = minetest.get_node(pointed_thing.under)
@ -115,17 +155,10 @@ minetest.register_craftitem("mcl_potions:potion_water", {
end end
end end
local cauldron = fill_cauldron(node.name, "mcl_core:water_source")
if cauldron then
-- Increase water level of cauldron by 1 -- Increase water level of cauldron by 1
if node.name == "mcl_cauldrons:cauldron" then minetest.set_node(pointed_thing.under, {name=cauldron})
minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron_1"})
minetest.sound_play("mcl_potions_bottle_pour", {pos=pointed_thing.under, gain=0.5, max_hear_range=16})
return "mcl_potions:glass_bottle"
elseif node.name == "mcl_cauldrons:cauldron_1" then
minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron_2"})
minetest.sound_play("mcl_potions_bottle_pour", {pos=pointed_thing.under, gain=0.5, max_hear_range=16})
return "mcl_potions:glass_bottle"
elseif node.name == "mcl_cauldrons:cauldron_2" then
minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron_3"})
minetest.sound_play("mcl_potions_bottle_pour", {pos=pointed_thing.under, gain=0.5, max_hear_range=16}) minetest.sound_play("mcl_potions_bottle_pour", {pos=pointed_thing.under, gain=0.5, max_hear_range=16})
return "mcl_potions:glass_bottle" return "mcl_potions:glass_bottle"
end end
@ -137,6 +170,43 @@ minetest.register_craftitem("mcl_potions:potion_water", {
on_secondary_use = minetest.item_eat(0, "mcl_potions:glass_bottle"), on_secondary_use = minetest.item_eat(0, "mcl_potions:glass_bottle"),
}) })
minetest.register_craftitem("mcl_potions:potion_river_water", {
description = "River Water Bottle",
_doc_items_longdesc = "River water bottles can be used to brew potions and to fill cauldrons. Drinking it has no effect.",
_doc_items_usagehelp = "Wield it and rightclick to drink it. Rightclick a cauldron to put the river water into the cauldron.",
stack_max = 1,
inventory_image = potion_image("#0044FF"),
wield_image = potion_image("#0044FF"),
groups = {brewitem=1, food=3, can_eat_when_full=1, water_bottle=1},
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type == "node" then
local node = minetest.get_node(pointed_thing.under)
local def = minetest.registered_nodes[node.name]
-- Call on_rightclick if the pointed node defines it
if placer and not placer:get_player_control().sneak then
if def and def.on_rightclick then
return def.on_rightclick(pointed_thing.under, node, placer, itemstack) or itemstack
end
end
local cauldron = fill_cauldron(node.name, "mclx_core:river_water_source")
if cauldron then
-- Increase water level of cauldron by 1
minetest.set_node(pointed_thing.under, {name=cauldron})
minetest.sound_play("mcl_potions_bottle_pour", {pos=pointed_thing.under, gain=0.5, max_hear_range=16})
return "mcl_potions:glass_bottle"
end
end
-- Drink the water by default
return minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, placer, pointed_thing)
end,
on_secondary_use = minetest.item_eat(0, "mcl_potions:glass_bottle"),
})
local how_to_drink = "To drink it, wield it, then rightclick." local how_to_drink = "To drink it, wield it, then rightclick."
minetest.register_craftitem("mcl_potions:potion_awkward", { minetest.register_craftitem("mcl_potions:potion_awkward", {