1
0
Fork 0

Add riverwaterlogged sponge, rename wet sponge

This commit is contained in:
Wuzzy 2017-11-30 17:36:08 +01:00
parent 2093a6b5c2
commit 443fb284cb
3 changed files with 55 additions and 10 deletions

View File

@ -193,10 +193,13 @@ local function furnace_node_timer(pos, elapsed)
inv:add_item("dst", cooked.item) inv:add_item("dst", cooked.item)
inv:set_stack("src", 1, aftercooked.items[1]) inv:set_stack("src", 1, aftercooked.items[1])
-- Unique recipe: Put water into empty bucket after cooking wet sponge successfully -- Unique recipe: Pour water into empty bucket after cooking wet sponge successfully
if srclist[1]:get_name() == "mcl_sponges:sponge_wet" then if inv:get_stack("fuel", 1):get_name() == "mcl_buckets:bucket_empty" then
if inv:get_stack("fuel", 1):get_name() == "mcl_buckets:bucket_empty" then if srclist[1]:get_name() == "mcl_sponges:sponge_wet" then
inv:set_stack("fuel", 1, "mcl_buckets:bucket_water") inv:set_stack("fuel", 1, "mcl_buckets:bucket_water")
-- Also for river water
elseif srclist[1]:get_name() == "mcl_sponges:sponge_wet_river_water" then
inv:set_stack("fuel", 1, "mcl_buckets:bucket_river_water")
end end
end end

View File

@ -1,5 +1,9 @@
local absorb = function(pos) local absorb = function(pos)
local change = false local change = false
-- Count number of absorbed river water vs other nodes
-- to determine the wet sponge type.
local river_water = 0
local non_river_water = 0
local p, n local p, n
for i=-3,3 do for i=-3,3 do
for j=-3,3 do for j=-3,3 do
@ -9,11 +13,24 @@ local absorb = function(pos)
if minetest.get_item_group(n.name, "water") ~= 0 then if minetest.get_item_group(n.name, "water") ~= 0 then
minetest.add_node(p, {name="air"}) minetest.add_node(p, {name="air"})
change = true change = true
if n.name == "mclx_core:river_water_source" or n.name == "mclx_core:river_water_flowing" then
river_water = river_water + 1
else
non_river_water = non_river_water + 1
end
end end
end end
end end
end end
return change -- The dominant water type wins. In case of a tie, normal water wins.
-- This slight bias is intentional.
local sponge_type
if river_water > non_river_water then
sponge_type = "mcl_sponges:sponge_wet_river_water"
else
sponge_type = "mcl_sponges:sponge_wet"
end
return change, sponge_type
end end
minetest.register_node("mcl_sponges:sponge", { minetest.register_node("mcl_sponges:sponge", {
@ -59,8 +76,9 @@ minetest.register_node("mcl_sponges:sponge", {
if on_water then if on_water then
-- Absorb water -- Absorb water
-- FIXME: pos is not always the right placement position because of pointed_thing -- FIXME: pos is not always the right placement position because of pointed_thing
if absorb(pos) then local absorbed, wet_sponge = absorb(pos)
minetest.item_place_node(ItemStack("mcl_sponges:sponge_wet"), placer, pointed_thing) if absorbed then
minetest.item_place_node(ItemStack(wet_sponge), placer, pointed_thing)
if not minetest.settings:get_bool("creative_mode") then if not minetest.settings:get_bool("creative_mode") then
itemstack:take_item() itemstack:take_item()
end end
@ -74,8 +92,8 @@ minetest.register_node("mcl_sponges:sponge", {
}) })
minetest.register_node("mcl_sponges:sponge_wet", { minetest.register_node("mcl_sponges:sponge_wet", {
description = "Wet Sponge", description = "Waterlogged Sponge",
_doc_items_longdesc = "Wet sponges can be dried in the furnace to turn it into (dry) sponge. When there's an empty bucket in the fuel slot of a furnace, water will pour into the bucket.", _doc_items_longdesc = "A waterlogged sponge can be dried in the furnace to turn it into (dry) sponge. When there's an empty bucket in the fuel slot of a furnace, the water will pour into the bucket.",
drawtype = "normal", drawtype = "normal",
is_ground_content = false, is_ground_content = false,
tiles = {"mcl_sponges_sponge_wet.png"}, tiles = {"mcl_sponges_sponge_wet.png"},
@ -90,6 +108,29 @@ minetest.register_node("mcl_sponges:sponge_wet", {
_mcl_hardness = 0.6, _mcl_hardness = 0.6,
}) })
minetest.register_node("mcl_sponges:sponge_wet_river_water", {
description = "Riverwaterlogged Sponge",
_doc_items_longdesc = "A sponge full of river water. It can be dried in the furnace to turn it into (dry) sponge. When there's an empty bucket in the fuel slot of the furnace, the river water will pour into the bucket.",
drawtype = "normal",
is_ground_content = false,
tiles = {"mcl_sponges_sponge_wet_river_water.png"},
walkable = true,
pointable = true,
diggable = true,
buildable_to = false,
stack_max = 64,
sounds = mcl_sounds.node_sound_dirt_defaults(),
groups = {handy=1, building_block=1},
_mcl_blast_resistance = 3,
_mcl_hardness = 0.6,
})
minetest.register_craft({
type = "cooking",
output = "mcl_sponges:sponge",
recipe = "mcl_sponges:sponge_wet_river_water",
cooktime = 10,
})
minetest.register_craft({ minetest.register_craft({
type = "cooking", type = "cooking",
output = "mcl_sponges:sponge", output = "mcl_sponges:sponge",
@ -104,8 +145,9 @@ minetest.register_abm({
interval = 1, interval = 1,
chance = 1, chance = 1,
action = function(pos) action = function(pos)
if absorb(pos) then local absorbed, wet_sponge = absorb(pos)
minetest.add_node(pos, {name = "mcl_sponges:sponge_wet"}) if absorbed then
minetest.add_node(pos, {name = wet_sponge})
end end
end, end,
}) })

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 B