1
0
Fork 0

code from inital PR

This commit is contained in:
chmodsayshello 2022-04-25 14:02:36 +00:00 committed by Gitea
parent ea2b53b231
commit 6806ea311d
16 changed files with 119 additions and 6 deletions

View File

@ -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")

View File

@ -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

View File

@ -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=

View File

@ -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"}
}
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@ -452,12 +452,33 @@ 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:
local dir = minetest.facedir_to_dir(minetest.get_node(pos).param2)

View File

@ -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!

View File

@ -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!=