diff --git a/CHANGELOG.md b/CHANGELOG.md index 57f3db8..af21550 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Notable Game Changes: - Add back the Rubies that were removed a while ago! - Replaced Spawnpoints with a item - Added Pigs +- Improved hudbars Other Game Changes: diff --git a/mods/ENTITIES/pyutest_entities/init.lua b/mods/ENTITIES/pyutest_entities/init.lua index d5edd74..dbe343f 100644 --- a/mods/ENTITIES/pyutest_entities/init.lua +++ b/mods/ENTITIES/pyutest_entities/init.lua @@ -51,3 +51,19 @@ PyuTest.make_mob("pyutest_entities:item_follower", { "pyutest_tools:coin" } }) + +PyuTest.make_mob("pyutest_entities:pig", { + hp_max = 10, + visual = "mesh", + mesh = "pyutest-pig.glb", + visual_size = {x = 6, y = 8, z = 8}, + textures = {"pyutest-pig.png"}, + nametag = "Pig", + collisionbox = PyuTest.BLOCK_SIZED_ANIMAL_CBOX, + selectionbox = PyuTest.NODEBOX_DEFAULT.fixed, +}, { + drops = {}, + follow_items = { + "pyutest_tools:carrot" + } +}) diff --git a/mods/ENTITIES/pyutest_mobs/basic.lua b/mods/ENTITIES/pyutest_mobs/basic.lua index a63c5a4..2c6c8c3 100644 --- a/mods/ENTITIES/pyutest_mobs/basic.lua +++ b/mods/ENTITIES/pyutest_mobs/basic.lua @@ -153,9 +153,8 @@ mobs:register_mob("pyutest_mobs:pig", { fear_height = 5, blood_amount = PyuTest.ENTITY_BLOOD_AMOUNT, makes_footstep_sound = true, - visual_size = {x = 6, y = 8, z = 8}, - collisionbox = PyuTest.BLOCK_SIZED_ANIMAL_CBOX, - selectionbox = PyuTest.NODEBOX_DEFAULT.fixed, + visual_size = {x = 9, y = 9, z = 9}, + collisionbox = {-0.45, -0.01, -0.45, 0.45, 0.865, 0.45}, can_leap = false, jump = false, pushable = false diff --git a/mods/ITEMS/pyutest_blocks/special.lua b/mods/ITEMS/pyutest_blocks/special.lua index 9ce2f50..eee9481 100644 --- a/mods/ITEMS/pyutest_blocks/special.lua +++ b/mods/ITEMS/pyutest_blocks/special.lua @@ -141,6 +141,7 @@ PyuTest.make_node("pyutest_blocks:workbench", "Workbench", { PyuTest.make_node("pyutest_blocks:ladder", "Ladder", { dig_immediate = 1, oddly_breakable_by_hand = PyuTest.BLOCK_FAST, + choppy = PyuTest.BLOCK_FAST, block = 1 }, { "pyutest-ladder.png" }, { drawtype = "signlike", diff --git a/mods/PLAYER/pyutest_hud/init.lua b/mods/PLAYER/pyutest_hud/init.lua index d82a500..1e9bb50 100644 --- a/mods/PLAYER/pyutest_hud/init.lua +++ b/mods/PLAYER/pyutest_hud/init.lua @@ -1,15 +1,69 @@ +core.hud_replace_builtin("health", {}) +core.hud_replace_builtin("breath", {}) + PyuTest.HUDBARS = { - + defs = {}, + defs_count = 0, + players = {} } +PyuTest.Hudbar = {} +local HudbarMeta = { __index = PyuTest.Hudbar, __newindex = PyuTest.Hudbar } -core.hud_replace_builtin("health", { - hud_elem_type = "statbar", - text = "pyutest-bar-health.png", - text2 = "pyutest-bar-empty.png", - number = core.PLAYER_MAX_HP_DEFAULT, - item = core.PLAYER_MAX_HP_DEFAULT, - position = {x = 0.5, y = 1}, - direction = 0, - size = {x = 24, y = 24}, - offset = {x = (-10 * 24) - 25, y = -(48 + 24 + 16)}, -}) +core.register_on_joinplayer(function(player) + for k, v in pairs(PyuTest.HUDBARS.defs) do + local key = player:get_player_name() + if PyuTest.HUDBARS.players[key] == nil then + PyuTest.HUDBARS.players[key] = {} + end + local ref = PyuTest.HUDBARS.players[key] + + ref[k] = {idx = player:hud_add(v.cfg), name = k} + end +end) + +core.register_globalstep(function(dtime) + for _, player in pairs(core.get_connected_players()) do + for _, v in pairs(PyuTest.HUDBARS.players[player:get_player_name()]) do + PyuTest.HUDBARS.defs[v.name].update(v.idx, player) + end + end +end) + +function PyuTest.Hudbar:add(name, def, update) + local cfg = def or {} + cfg.hud_elem_type = "statbar" + cfg.position = {x = 0.5, y = 0.925} + cfg.direction = 0 + cfg.size = {x = 24, y = 24} + cfg.offset = {x = (-10 * 24 - 25) * -(PyuTest.HUDBARS.defs_count - 1), y = (-48 + 24 + 16)} + cfg.text2 = cfg.text2 or "pyutest-bar-empty.png" + + local m = setmetatable({ + cfg = cfg, + update = update or function()end + }, HudbarMeta) + + PyuTest.HUDBARS.defs[name] = m + PyuTest.HUDBARS.defs_count = PyuTest.HUDBARS.defs_count + 1 +end + + +local enable_damage = core.settings:get_bool("enable_damage") + +if enable_damage then + PyuTest.Hudbar:add("health", { + text = "pyutest-bar-health.png", + number = core.PLAYER_MAX_HP_DEFAULT, + item = core.PLAYER_MAX_HP_DEFAULT, + }, function (idx, player) + player:hud_change(idx, "number", player:get_hp()) + end) + + PyuTest.Hudbar:add("breath", { + text = "pyutest-bar-breath.png", + number = core.PLAYER_MAX_BREATH_DEFAULT, + item = core.PLAYER_MAX_BREATH_DEFAULT, + }, function (idx, player) + player:hud_change(idx, "number", player:get_breath()) + end) +end diff --git a/mods/PLAYER/pyutest_hud/mod.conf b/mods/PLAYER/pyutest_hud/mod.conf new file mode 100644 index 0000000..e69de29