1
0
Fork 0

Add multiplayer support for pumpkin hud

This commit is contained in:
NO11 2021-05-23 22:31:13 +00:00
parent 9b9ec13967
commit 8b11e2fec8
1 changed files with 27 additions and 19 deletions

View File

@ -124,26 +124,32 @@ pumpkin_face_base_def._mcl_armor_preview = "mcl_farming_pumpkin_face_preview.png
if minetest.get_modpath("mcl_armor") then if minetest.get_modpath("mcl_armor") then
local pumpkin_hud = {} local pumpkin_hud = {}
local add_pumpkin_hud = function(player) local add_pumpkin_hud = function(player)
pumpkin_hud = player:hud_add({ local name = player:get_player_name()
hud_elem_type = "image", pumpkin_hud[name] = {
position = {x = 0.5, y = 0.5}, pumpkin_blur = player:hud_add({
scale = {x = -100, y = -100}, hud_elem_type = "image",
text = "mcl_farming_pumpkin_hud.png", position = {x = 0.5, y = 0.5},
z_index = -200 scale = {x = -100, y = -100},
}) text = "mcl_farming_pumpkin_hud.png",
--this is a fake crosshair, because hotbar and crosshair doesn't support z_index z_index = -200
--TODO: remove this and add correct z_index values when this is fixed: https://github.com/minetest/minetest/issues/9270 }),
player:hud_add({ --this is a fake crosshair, because hotbar and crosshair doesn't support z_index
hud_elem_type = "image", --TODO: remove this and add correct z_index values
position = {x = 0.5, y = 0.5}, fake_crosshair = player:hud_add({
scale = {x = 1, y = 1}, hud_elem_type = "image",
text = "crosshair.png", position = {x = 0.5, y = 0.5},
z_index = -100 scale = {x = 1, y = 1},
}) text = "crosshair.png",
z_index = -100
})
}
end end
local remove_pumpkin_hud = function(player) local remove_pumpkin_hud = function(player)
if pumpkin_hud then local name = player:get_player_name()
player:hud_remove(pumpkin_hud) if pumpkin_hud[name] then
player:hud_remove(pumpkin_hud[name].pumpkin_blur)
player:hud_remove(pumpkin_hud[name].fake_crosshair)
pumpkin_hud[name] = nil
end end
end end
@ -157,10 +163,12 @@ if minetest.get_modpath("mcl_armor") then
add_pumpkin_hud(player) add_pumpkin_hud(player)
end end
end) end)
minetest.register_on_dieplayer(function(player) minetest.register_on_dieplayer(function(player)
remove_pumpkin_hud(player) remove_pumpkin_hud(player)
end) end)
minetest.register_on_leaveplayer(function(player)
remove_pumpkin_hud(player)
end)
end end
-- Register stem growth -- Register stem growth