diff --git a/mods/ITEMS/mcl_beds/init.lua b/mods/ITEMS/mcl_beds/init.lua index 4c25b5390..ad9dbdded 100644 --- a/mods/ITEMS/mcl_beds/init.lua +++ b/mods/ITEMS/mcl_beds/init.lua @@ -10,3 +10,4 @@ local modpath = minetest.get_modpath("mcl_beds") dofile(modpath .. "/functions.lua") dofile(modpath .. "/api.lua") dofile(modpath .. "/beds.lua") +dofile(modpath .. "/respawn_anchor.lua") \ No newline at end of file diff --git a/mods/ITEMS/mcl_beds/locale/mcl_beds.de.tr b/mods/ITEMS/mcl_beds/locale/mcl_beds.de.tr index eb6967941..7fe400b7f 100644 --- a/mods/ITEMS/mcl_beds/locale/mcl_beds.de.tr +++ b/mods/ITEMS/mcl_beds/locale/mcl_beds.de.tr @@ -40,3 +40,4 @@ You will fall asleep when all players are in bed.=Sie werden einschlafen, wenn a You will fall asleep when @1% of all players are in bed.=Sie werden einschlafen, wenn @1% der Spieler im Bett sind. You're in bed.=Sie sind im Bett. Allows you to sleep=Zum Einschafen +Respawn Anchor=Seelenanker \ No newline at end of file diff --git a/mods/ITEMS/mcl_beds/locale/template.txt b/mods/ITEMS/mcl_beds/locale/template.txt index 5525bd91b..69c493880 100644 --- a/mods/ITEMS/mcl_beds/locale/template.txt +++ b/mods/ITEMS/mcl_beds/locale/template.txt @@ -40,3 +40,4 @@ You will fall asleep when all players are in bed.= You will fall asleep when @1% of all players are in bed.= You're in bed.= Allows you to sleep= +Respawn Anchor= diff --git a/mods/ITEMS/mcl_beds/mod.conf b/mods/ITEMS/mcl_beds/mod.conf index c3378d1f0..83295a658 100644 --- a/mods/ITEMS/mcl_beds/mod.conf +++ b/mods/ITEMS/mcl_beds/mod.conf @@ -2,4 +2,4 @@ name = mcl_beds author = BlockMen description = depends = playerphysics -optional_depends = mcl_sounds, mcl_worlds, mcl_wool, mcl_dye, mcl_explosions, mcl_weather, mcl_spawn, doc +optional_depends = mcl_sounds, mcl_worlds, mcl_wool, mcl_dye, mcl_explosions, mcl_weather, mcl_spawn, doc \ No newline at end of file diff --git a/mods/ITEMS/mcl_beds/respawn_anchor.lua b/mods/ITEMS/mcl_beds/respawn_anchor.lua new file mode 100644 index 000000000..8bf680882 --- /dev/null +++ b/mods/ITEMS/mcl_beds/respawn_anchor.lua @@ -0,0 +1,87 @@ +--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) + 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() + }) + else + minetest.register_node("mcl_beds:respawn_anchor_charged_"..i,{ + description=S("Respawn Anchor"), + tiles = { + "portal.png", + "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() + }) + end + end + + +minetest.register_craft({ --TODO: Please change this crafting recipe once crying obsidian is implemented! + output = "mcl_beds:respawn_anchor", + recipe = { + {"mcl_core:obsidian", "mcl_core:obsidian", "mcl_core:obsidian"}, + {"mcl_nether:glowstone", "mcl_nether:glowstone", "mcl_nether:glowstone"}, + {"mcl_core:obsidian", "mcl_core:obsidian", "mcl_core:obsidian"} + } + }) \ No newline at end of file diff --git a/mods/ITEMS/mcl_beds/textures/portal.png b/mods/ITEMS/mcl_beds/textures/portal.png new file mode 100644 index 000000000..160ad95f3 Binary files /dev/null and b/mods/ITEMS/mcl_beds/textures/portal.png differ diff --git a/mods/ITEMS/mcl_beds/textures/respawn_anchor_bottom.png b/mods/ITEMS/mcl_beds/textures/respawn_anchor_bottom.png new file mode 100644 index 000000000..d5d332c15 Binary files /dev/null and b/mods/ITEMS/mcl_beds/textures/respawn_anchor_bottom.png differ diff --git a/mods/ITEMS/mcl_beds/textures/respawn_anchor_side0.png b/mods/ITEMS/mcl_beds/textures/respawn_anchor_side0.png new file mode 100644 index 000000000..31a6e58f3 Binary files /dev/null and b/mods/ITEMS/mcl_beds/textures/respawn_anchor_side0.png differ diff --git a/mods/ITEMS/mcl_beds/textures/respawn_anchor_side1.png b/mods/ITEMS/mcl_beds/textures/respawn_anchor_side1.png new file mode 100644 index 000000000..ed4667a2e Binary files /dev/null and b/mods/ITEMS/mcl_beds/textures/respawn_anchor_side1.png differ diff --git a/mods/ITEMS/mcl_beds/textures/respawn_anchor_side2.png b/mods/ITEMS/mcl_beds/textures/respawn_anchor_side2.png new file mode 100644 index 000000000..996042015 Binary files /dev/null and b/mods/ITEMS/mcl_beds/textures/respawn_anchor_side2.png differ diff --git a/mods/ITEMS/mcl_beds/textures/respawn_anchor_side3.png b/mods/ITEMS/mcl_beds/textures/respawn_anchor_side3.png new file mode 100644 index 000000000..f0728943c Binary files /dev/null and b/mods/ITEMS/mcl_beds/textures/respawn_anchor_side3.png differ diff --git a/mods/ITEMS/mcl_beds/textures/respawn_anchor_side4.png b/mods/ITEMS/mcl_beds/textures/respawn_anchor_side4.png new file mode 100644 index 000000000..e9bea5371 Binary files /dev/null and b/mods/ITEMS/mcl_beds/textures/respawn_anchor_side4.png differ diff --git a/mods/ITEMS/mcl_beds/textures/respawn_anchor_top_off.png b/mods/ITEMS/mcl_beds/textures/respawn_anchor_top_off.png new file mode 100644 index 000000000..a180e96e7 Binary files /dev/null and b/mods/ITEMS/mcl_beds/textures/respawn_anchor_top_off.png differ diff --git a/mods/PLAYER/mcl_spawn/init.lua b/mods/PLAYER/mcl_spawn/init.lua index 113a4d27f..9d11df705 100644 --- a/mods/PLAYER/mcl_spawn/init.lua +++ b/mods/PLAYER/mcl_spawn/init.lua @@ -452,11 +452,32 @@ function mcl_spawn.get_player_spawn_pos(player) if bgroup ~= 1 and bgroup ~= 2 then -- Bed is destroyed: if player and player:is_player() then - player:get_meta():set_string("mcl_beds:spawn", "") + local checkpos = minetest.string_to_pos(player:get_meta():get_string("mcl_beds:spawn")) + local checknode = minetest.get_node(checkpos) + + if(string.match(checknode.name, "mcl_beds:respawn_anchor_charged_")) then + local charge_level = tonumber(string.sub(checknode.name, -1)) + if not charge_level then + minetest.log("warning","could not get level of players respawn anchor, sending him back to spawn!") + player:get_meta():set_string("mcl_beds:spawn", "") + minetest.chat_send_player(player:get_player_name(), S("Couldn't get level of your respawn anchor!")) + return mcl_spawn.get_world_spawn_pos(), false + elseif charge_level ~= 1 then + minetest.set_node(checkpos, {name="mcl_beds:respawn_anchor_charged_".. charge_level-1}) + return checkpos, false + else + minetest.set_node(checkpos, {name="mcl_beds:respawn_anchor"}) + return checkpos, false + end + else + player:get_meta():set_string("mcl_beds:spawn", "") + minetest.chat_send_player(player:get_player_name(), S("Your spawn bed was missing or blocked, and you had no charged respawn anchor!")) + return mcl_spawn.get_world_spawn_pos(), false + end end - minetest.chat_send_player(player:get_player_name(), S("Your spawn bed was missing or blocked.")) - return mcl_spawn.get_world_spawn_pos(), false end + + -- Find spawning position on/near the bed free of solid or damaging blocks iterating a square spiral 15x15: diff --git a/mods/PLAYER/mcl_spawn/locale/mcl_spawn.de.tr b/mods/PLAYER/mcl_spawn/locale/mcl_spawn.de.tr index e30a71650..57d32a5f7 100644 --- a/mods/PLAYER/mcl_spawn/locale/mcl_spawn.de.tr +++ b/mods/PLAYER/mcl_spawn/locale/mcl_spawn.de.tr @@ -1,4 +1,5 @@ # textdomain: mcl_spawn New respawn position set!=Neue Wiedereinstiegsposition gesetzt! Respawn position cleared!=Wiedereinstiegsposition gelöscht! -Your spawn bed was missing or blocked.=Ihr Startbett fehlte oder war blockiert. +Your spawn bed was missing or blocked, and you had no charged respawn anchor!=Ihr Startbett fehlte oder war blockiert, und Sie hatten keinen geladenen Seelenanker! +Couldn't get level of your respawn anchor!=Das Füllstand ihres Seelenankers konnte nicht erkannt werden! \ No newline at end of file diff --git a/mods/PLAYER/mcl_spawn/locale/template.txt b/mods/PLAYER/mcl_spawn/locale/template.txt index 8906d18f9..aa8aafe8d 100644 --- a/mods/PLAYER/mcl_spawn/locale/template.txt +++ b/mods/PLAYER/mcl_spawn/locale/template.txt @@ -1,4 +1,5 @@ # textdomain: mcl_spawn New respawn position set!= Respawn position cleared!= -Your spawn bed was missing or blocked.= +Couldn't get level of your respawn anchor!= +Your spawn bed was missing or blocked, and you had no charged respawn anchor!= \ No newline at end of file