forked from MineClone5/MineClone5
291 lines
11 KiB
Lua
291 lines
11 KiB
Lua
-- Nodes
|
|
|
|
local S = minetest.get_translator("mcl_ocean")
|
|
|
|
minetest.register_node("mcl_ocean:sea_lantern", {
|
|
description = S("Sea Lantern"),
|
|
_doc_items_longdesc = S("Sea lanterns are decorative light sources which look great underwater but can be placed anywhere."),
|
|
paramtype2 = "facedir",
|
|
is_ground_content = false,
|
|
stack_max = 64,
|
|
light_source = minetest.LIGHT_MAX,
|
|
drop = {
|
|
max_items = 1,
|
|
items = {
|
|
{ items = {'mcl_ocean:prismarine_crystals 3'}, rarity = 2 },
|
|
{ items = {'mcl_ocean:prismarine_crystals 2'}}
|
|
}
|
|
},
|
|
tiles = {{name="mcl_ocean_sea_lantern.png", animation={type="vertical_frames", aspect_w=32, aspect_h=32, length=1.25}}},
|
|
groups = {handy=1, building_block=1, material_glass=1},
|
|
sounds = mcl_sounds.node_sound_glass_defaults(),
|
|
_mcl_blast_resistance = 1.5,
|
|
_mcl_hardness = 0.3,
|
|
})
|
|
|
|
minetest.register_node("mcl_ocean:prismarine", {
|
|
description = S("Prismarine"),
|
|
_doc_items_longdesc = S("Prismarine is used as a building block. It slowly changes its color."),
|
|
stack_max = 64,
|
|
is_ground_content = false,
|
|
-- Texture should have 22 frames for smooth transitions.
|
|
tiles = {{name="mcl_ocean_prismarine_anim.png", animation={type="vertical_frames", aspect_w=32, aspect_h=32, length=45.0}}},
|
|
groups = {pickaxey=1, building_block=1, material_stone=1},
|
|
sounds = mcl_sounds.node_sound_stone_defaults(),
|
|
_mcl_blast_resistance = 30,
|
|
_mcl_hardness = 1.5,
|
|
})
|
|
|
|
minetest.register_node("mcl_ocean:prismarine_brick", {
|
|
description = S("Prismarine Bricks"),
|
|
_doc_items_longdesc = doc.sub.items.temp.build,
|
|
stack_max = 64,
|
|
is_ground_content = false,
|
|
tiles = {"mcl_ocean_prismarine_bricks.png"},
|
|
groups = {pickaxey=1, building_block=1, material_stone=1},
|
|
sounds = mcl_sounds.node_sound_stone_defaults(),
|
|
_mcl_blast_resistance = 30,
|
|
_mcl_hardness = 1.5,
|
|
})
|
|
|
|
minetest.register_node("mcl_ocean:prismarine_dark", {
|
|
description = S("Dark Prismarine"),
|
|
_doc_items_longdesc = doc.sub.items.temp.build,
|
|
stack_max = 64,
|
|
is_ground_content = false,
|
|
tiles = {"mcl_ocean_prismarine_dark.png"},
|
|
groups = {pickaxey=1, building_block=1, material_stone=1},
|
|
sounds = mcl_sounds.node_sound_stone_defaults(),
|
|
_mcl_blast_resistance = 30,
|
|
_mcl_hardness = 1.5,
|
|
})
|
|
|
|
-- Craftitems
|
|
|
|
minetest.register_craftitem("mcl_ocean:prismarine_crystals", {
|
|
description = S("Prismarine Crystals"),
|
|
_doc_items_longdesc = doc.sub.items.temp.craftitem,
|
|
inventory_image = "mcl_ocean_prismarine_crystals.png",
|
|
stack_max = 64,
|
|
groups = { craftitem = 1 },
|
|
})
|
|
|
|
minetest.register_craftitem("mcl_ocean:prismarine_shard", {
|
|
description = S("Prismarine Shard"),
|
|
_doc_items_longdesc = doc.sub.items.temp.craftitem,
|
|
inventory_image = "mcl_ocean_prismarine_shard.png",
|
|
stack_max = 64,
|
|
groups = { craftitem = 1 },
|
|
})
|
|
|
|
-- Crafting
|
|
|
|
minetest.register_craft({
|
|
output = 'mcl_ocean:sea_lantern',
|
|
recipe = {
|
|
{'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_crystals', 'mcl_ocean:prismarine_shard'},
|
|
{'mcl_ocean:prismarine_crystals', 'mcl_ocean:prismarine_crystals', 'mcl_ocean:prismarine_crystals'},
|
|
{'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_crystals', 'mcl_ocean:prismarine_shard'},
|
|
}
|
|
})
|
|
|
|
minetest.register_craft({
|
|
output = 'mcl_ocean:prismarine',
|
|
recipe = {
|
|
{'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard'},
|
|
{'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard'},
|
|
}
|
|
})
|
|
|
|
minetest.register_craft({
|
|
output = 'mcl_ocean:prismarine_brick',
|
|
recipe = {
|
|
{'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard'},
|
|
{'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard'},
|
|
{'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard'},
|
|
}
|
|
})
|
|
|
|
minetest.register_craft({
|
|
output = 'mcl_ocean:prismarine_dark',
|
|
recipe = {
|
|
{'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard'},
|
|
{'mcl_ocean:prismarine_shard', 'mcl_dye:black', 'mcl_ocean:prismarine_shard'},
|
|
{'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard', 'mcl_ocean:prismarine_shard'},
|
|
}
|
|
})
|
|
|
|
local corals = {
|
|
{ "tube", S("Tube Coral Block"), S("Dead Tube Coral Block"), S("Tube Coral"), S("Dead Tube Coral"), S("Tube Coral Fan"), S("Dead Tube Coral Fan") },
|
|
{ "brain", S("Brain Coral Block"), S("Dead Brain Coral Block"), S("Brain Coral"), S("Dead Brain Coral"), S("Brain Coral Fan"), S("Dead Brain Coral Fan") },
|
|
{ "bubble", S("Bubble Coral Block"), S("Dead Bubble Coral Block"), S("Bubble Coral"), S("Dead Bubble Coral"), S("Bubble Coral Fan"), S("Dead Bubble Coral Fan")},
|
|
{ "fire", S("Fire Coral Block"), S("Dead Fire Coral Block"), S("Fire Coral"), S("Dead Fire Coral"), S("Fire Coral Fan"), S("Dead Fire Coral Fan") },
|
|
{ "horn", S("Horn Coral Block"), S("Dead Horn Coral Block"), S("Horn Coral"), S("Dead Horn Coral"), S("Horn Coral Fan"), S("Dead Horn Coral Fan") },
|
|
}
|
|
|
|
local function coral_on_place(itemstack, placer, pointed_thing)
|
|
if pointed_thing.type ~= "node" or not placer then
|
|
return itemstack
|
|
end
|
|
|
|
local player_name = placer:get_player_name()
|
|
local pos_under = pointed_thing.under
|
|
local pos_above = pointed_thing.above
|
|
local node_under = minetest.get_node(pos_under)
|
|
local def_under = minetest.registered_nodes[node_under.name]
|
|
|
|
if def_under and def_under.on_rightclick and not placer:get_player_control().sneak then
|
|
return def_under.on_rightclick(pos_under, node_under.name,
|
|
placer, itemstack, pointed_thing) or itemstack
|
|
end
|
|
|
|
local g_block = minetest.get_item_group(node_under.name, "coral_block")
|
|
local g_coral = minetest.get_item_group(itemstack:get_name(), "coral")
|
|
local g_species_block = minetest.get_item_group(node_under.name, "coral_species")
|
|
local g_species_plant = minetest.get_item_group(itemstack:get_name(), "coral_species")
|
|
|
|
-- Placement rules:
|
|
-- Coral plant can only be placed on top of a matching coral block.
|
|
-- If alive, it must also be inside a water source.
|
|
-- Note: It's intentional that it works only for normal water (not river water). Corals are
|
|
-- for the ocean, after all.
|
|
if g_block == 0 or (g_coral ~= g_block) or (g_species_block ~= g_species_plant) or
|
|
(g_coral == 1 and minetest.get_node(pos_above).name ~= "mcl_core:water_source") then
|
|
return itemstack
|
|
end
|
|
|
|
if minetest.is_protected(pos_under, player_name) or
|
|
minetest.is_protected(pos_above, player_name) then
|
|
minetest.log("action", player_name
|
|
.. " tried to place " .. itemstack:get_name()
|
|
.. " at protected position "
|
|
.. minetest.pos_to_string(pos_under))
|
|
minetest.record_protection_violation(pos_under, player_name)
|
|
return itemstack
|
|
end
|
|
|
|
node_under.name = itemstack:get_name()
|
|
node_under.param2 = minetest.registered_items[itemstack:get_name()].place_param2 or 1
|
|
if node_under.param2 < 8 and math.random(1,2) == 1 then
|
|
-- Random horizontal displacement
|
|
node_under.param2 = node_under.param2 + 8
|
|
end
|
|
minetest.set_node(pos_under, node_under)
|
|
if not (minetest.settings:get_bool("creative_mode")) then
|
|
itemstack:take_item()
|
|
end
|
|
|
|
return itemstack
|
|
end
|
|
|
|
-- Sound for non-block corals
|
|
local sounds_coral_plant = mcl_sounds.node_sound_leaves_defaults({footstep = mcl_sounds.node_sound_dirt_defaults().footstep})
|
|
|
|
for c=1, #corals do
|
|
local id = corals[c][1]
|
|
-- Coral Block
|
|
minetest.register_node("mcl_ocean:"..id.."_coral_block", {
|
|
description = corals[c][2],
|
|
tiles = { "mcl_ocean_"..id.."_coral_block.png" },
|
|
groups = { pickaxey = 1, building_block = 1, coral=1, coral_block=1, coral_species=c, },
|
|
sounds = mcl_sounds.node_sound_dirt_defaults(),
|
|
drop = "mcl_ocean:dead_"..id.."_coral_block",
|
|
_mcl_hardness = 1.5,
|
|
_mcl_blast_resistance = 30,
|
|
})
|
|
minetest.register_node("mcl_ocean:dead_"..id.."_coral_block", {
|
|
description = corals[c][3],
|
|
tiles = { "mcl_ocean_dead_"..id.."_coral_block.png" },
|
|
groups = { pickaxey = 1, building_block = 1, coral=2, coral_block=2, coral_species=c, },
|
|
sounds = mcl_sounds.node_sound_dirt_defaults(),
|
|
_mcl_hardness = 1.5,
|
|
_mcl_blast_resistance = 30,
|
|
})
|
|
|
|
-- Coral
|
|
minetest.register_node("mcl_ocean:"..id.."_coral", {
|
|
description = corals[c][4],
|
|
drawtype = "plantlike_rooted",
|
|
paramtype = "light",
|
|
paramtype2 = "meshoptions",
|
|
place_param2 = 1,
|
|
tiles = { "mcl_ocean_"..id.."_coral_block.png" },
|
|
special_tiles = { { name = "mcl_ocean_"..id.."_coral.png" } },
|
|
inventory_image = "mcl_ocean_"..id.."_coral.png",
|
|
groups = { dig_immediate = 3, deco_block = 1, coral=1, coral_plant=1, coral_species=c, },
|
|
sounds = sounds_coral_plant,
|
|
drop = "mcl_ocean:dead_"..id.."_coral",
|
|
node_placement_prediction = "",
|
|
node_dig_prediction = "mcl_ocean:"..id.."_coral_block",
|
|
on_place = coral_on_place,
|
|
after_destruct = function(pos)
|
|
minetest.set_node(pos, {name="mcl_ocean:"..id.."_coral_block"})
|
|
end,
|
|
_mcl_hardness = 0,
|
|
_mcl_blast_resistance = 0,
|
|
})
|
|
minetest.register_node("mcl_ocean:dead_"..id.."_coral", {
|
|
description = corals[c][5],
|
|
drawtype = "plantlike_rooted",
|
|
paramtype = "light",
|
|
paramtype2 = "meshoptions",
|
|
place_param2 = 1,
|
|
tiles = { "mcl_ocean_dead_"..id.."_coral_block.png" },
|
|
special_tiles = { { name = "mcl_ocean_dead_"..id.."_coral.png" } },
|
|
inventory_image = "mcl_ocean_dead_"..id.."_coral.png",
|
|
groups = { dig_immediate = 3, deco_block = 1, coral=2, coral_plant=2, coral_species=c, },
|
|
sounds = sounds_coral_plant,
|
|
node_placement_prediction = "",
|
|
node_dig_prediction = "mcl_ocean:dead_"..id.."_coral_block",
|
|
on_place = coral_on_place,
|
|
after_destruct = function(pos)
|
|
minetest.set_node(pos, {name="mcl_ocean:dead_"..id.."_coral_block"})
|
|
end,
|
|
_mcl_hardness = 0,
|
|
_mcl_blast_resistance = 0,
|
|
})
|
|
|
|
-- Coral Fan
|
|
minetest.register_node("mcl_ocean:"..id.."_coral_fan", {
|
|
description = corals[c][6],
|
|
drawtype = "plantlike_rooted",
|
|
paramtype = "light",
|
|
paramtype2 = "meshoptions",
|
|
place_param2 = 4,
|
|
tiles = { "mcl_ocean_"..id.."_coral_block.png" },
|
|
special_tiles = { { name = "mcl_ocean_"..id.."_coral_fan.png" } },
|
|
inventory_image = "mcl_ocean_"..id.."_coral_fan.png",
|
|
groups = { dig_immediate = 3, deco_block = 1, coral=1, coral_fan=1, coral_species=c, },
|
|
sounds = sounds_coral_plant,
|
|
drop = "mcl_ocean:dead_"..id.."_coral_fan",
|
|
node_placement_prediction = "",
|
|
node_dig_prediction = "mcl_ocean:"..id.."_coral_block",
|
|
on_place = coral_on_place,
|
|
after_destruct = function(pos)
|
|
minetest.set_node(pos, {name="mcl_ocean:"..id.."_coral_block"})
|
|
end,
|
|
_mcl_hardness = 0,
|
|
_mcl_blast_resistance = 0,
|
|
})
|
|
minetest.register_node("mcl_ocean:dead_"..id.."_coral_fan", {
|
|
description = corals[c][7],
|
|
drawtype = "plantlike_rooted",
|
|
paramtype = "light",
|
|
paramtype2 = "meshoptions",
|
|
place_param2 = 4,
|
|
tiles = { "mcl_ocean_dead_"..id.."_coral_block.png" },
|
|
special_tiles = { { name = "mcl_ocean_dead_"..id.."_coral_fan.png" } },
|
|
inventory_image = "mcl_ocean_dead_"..id.."_coral_fan.png",
|
|
groups = { dig_immediate = 3, deco_block = 1, coral=2, coral_fan=2, coral_species=c, },
|
|
sounds = sounds_coral_plant,
|
|
node_placement_prediction = "",
|
|
node_dig_prediction = "mcl_ocean:dead_"..id.."_coral_block",
|
|
on_place = coral_on_place,
|
|
after_destruct = function(pos)
|
|
minetest.set_node(pos, {name="mcl_ocean:dead_"..id.."_coral_block"})
|
|
end,
|
|
_mcl_hardness = 0,
|
|
_mcl_blast_resistance = 0,
|
|
})
|
|
end
|