MineClone2/mods/ITEMS/mcl_beds/respawn_anchor.lua

105 lines
3.6 KiB
Lua
Raw Normal View History

2022-04-25 16:02:36 +02:00
--TODO: Add sounds for the respawn anchor (charge sounds etc.)
--Nether ends at y -29077
--Nether roof at y -28933
local S = minetest.get_translator(minetest.get_current_modname())
--local mod_doc = minetest.get_modpath("doc") -> maybe add documentation ?
for i=0,4 do
local nodebox_uncharged = { --Reused the composter nodebox, since it is basicly the same
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, -0.375, 0.5, 0.5}, -- Left wall
{ 0.375, -0.5, -0.5, 0.5, 0.5, 0.5}, -- Right wall
{-0.375, -0.5, 0.375, 0.375, 0.5, 0.5}, -- Back wall
{-0.375, -0.5, -0.5, 0.375, 0.5, -0.375}, -- Front wall
{-0.5, -0.5, -0.5, 0.5, -0.47, 0.5}, -- Bottom level, -0.47 because -0.5 is so low that you can see the texture of the block below through
}
}
local nodebox_charged = { --Reused the composter nodebox, since it is basicly the same
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, -0.375, 0.5, 0.5}, -- Left wall
{ 0.375, -0.5, -0.5, 0.5, 0.5, 0.5}, -- Right wall
{-0.375, -0.5, 0.375, 0.375, 0.5, 0.5}, -- Back wall
{-0.375, -0.5, -0.5, 0.375, 0.5, -0.375}, -- Front wall
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, -- Bottom level
}
}
local function rightclick(pos, node, player, itemstack)
if itemstack.get_name(itemstack) == "mcl_nether:glowstone" and i ~= 4 then
minetest.set_node(pos, {name="mcl_beds:respawn_anchor_charged_" .. i+1})
itemstack:take_item()
elseif mcl_worlds.pos_to_dimension(pos) ~= "nether" then
if node.name ~= "mcl_beds:respawn_anchor" then --only charged respawn anchors are exploding in the overworld & end in minecraft
mcl_explosions.explode(pos, 5, {drop_chance = 0, fire = true})
end
elseif string.match(node.name, "mcl_beds:respawn_anchor_charged_") then
minetest.chat_send_player(player.get_player_name(player), S"New respawn position set!")
mcl_spawn.set_spawn_pos(player, pos, nil)
2022-07-01 21:11:26 +02:00
if i == 4 then
awards.unlock(player:get_player_name(), "mcl:notQuiteNineLives")
end
2022-04-25 16:02:36 +02:00
end
end
if i == 0 then
minetest.register_node("mcl_beds:respawn_anchor",{
description=S("Respawn Anchor"),
tiles = {
"respawn_anchor_top_off.png",
"respawn_anchor_bottom.png",
"respawn_anchor_side0.png"
},
drawtype = "nodebox",
node_box = nodebox_uncharged,
on_rightclick = rightclick,
groups = {pickaxey=1, material_stone=1},
_mcl_hardness = 22.5,
sounds= mcl_sounds.node_sound_stone_defaults(),
2022-05-25 19:37:36 +02:00
use_texture_alpha = "blend",
2022-04-25 16:02:36 +02:00
})
mesecon.register_mvps_stopper("mcl_beds:respawn_anchor")
2022-04-25 16:02:36 +02:00
else
minetest.register_node("mcl_beds:respawn_anchor_charged_"..i,{
description=S("Respawn Anchor"),
tiles = {
2022-11-18 09:11:39 +01:00
{
image="respawn_anchor_top_on.png",
animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.0}
},
2022-04-25 16:02:36 +02:00
"respawn_anchor_bottom.png",
"respawn_anchor_side"..i ..".png"
},
drawtype = "nodebox",
node_box = nodebox_charged,
on_rightclick = rightclick,
groups = {pickaxey=1, material_stone=1, not_in_creative_inventory=1},
_mcl_hardness = 22.5,
sounds= mcl_sounds.node_sound_stone_defaults(),
drop = {
max_items = 1,
items = {
{items = {"mcl_beds:respawn_anchor"}},
}
},
2022-05-25 19:37:36 +02:00
light_source = math.min((4 * i) - 1, minetest.LIGHT_MAX),
use_texture_alpha = "blend",
2022-04-25 16:02:36 +02:00
})
mesecon.register_mvps_stopper("mcl_beds:respawn_anchor_charged_"..i)
2022-04-25 16:02:36 +02:00
end
end
2022-06-30 14:00:55 +02:00
minetest.register_craft({
2022-04-25 16:02:36 +02:00
output = "mcl_beds:respawn_anchor",
2022-05-26 07:29:28 +02:00
recipe = {
2022-06-30 14:00:55 +02:00
{"mcl_core:crying_obsidian", "mcl_core:crying_obsidian", "mcl_core:crying_obsidian"},
2022-04-25 16:02:36 +02:00
{"mcl_nether:glowstone", "mcl_nether:glowstone", "mcl_nether:glowstone"},
2022-06-30 14:00:55 +02:00
{"mcl_core:crying_obsidian", "mcl_core:crying_obsidian", "mcl_core:crying_obsidian"}
2022-05-26 07:29:28 +02:00
}
})