From c05a2d3a9d7e88f9178f1356f016e973fb64324d Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 27 Apr 2022 12:15:07 +0200 Subject: [PATCH 1/2] Add wither spawning schems --- mods/ENTITIES/mcl_wither_spawning/schems/wither_spawn_x.we | 1 + mods/ENTITIES/mcl_wither_spawning/schems/wither_spawn_z.we | 1 + 2 files changed, 2 insertions(+) create mode 100644 mods/ENTITIES/mcl_wither_spawning/schems/wither_spawn_x.we create mode 100644 mods/ENTITIES/mcl_wither_spawning/schems/wither_spawn_z.we diff --git a/mods/ENTITIES/mcl_wither_spawning/schems/wither_spawn_x.we b/mods/ENTITIES/mcl_wither_spawning/schems/wither_spawn_x.we new file mode 100644 index 000000000..6394bdc3f --- /dev/null +++ b/mods/ENTITIES/mcl_wither_spawning/schems/wither_spawn_x.we @@ -0,0 +1 @@ +return {{["y"] = 1, ["x"] = 0, ["name"] = "mcl_nether:soul_sand", ["z"] = 0}, {["y"] = 2, ["x"] = 0, ["name"] = "mcl_heads:wither_skeleton", ["z"] = 0, ["param2"] = 2, ["param1"] = 15}, {["y"] = 0, ["x"] = 1, ["name"] = "mcl_nether:soul_sand", ["z"] = 0}, {["y"] = 1, ["x"] = 1, ["name"] = "mcl_nether:soul_sand", ["z"] = 0}, {["y"] = 2, ["x"] = 1, ["name"] = "mcl_heads:wither_skeleton", ["z"] = 0, ["param2"] = 2, ["param1"] = 15}, {["y"] = 1, ["x"] = 2, ["name"] = "mcl_nether:soul_sand", ["z"] = 0}, {["y"] = 2, ["x"] = 2, ["name"] = "mcl_heads:wither_skeleton", ["z"] = 0, ["param2"] = 2, ["param1"] = 15}} diff --git a/mods/ENTITIES/mcl_wither_spawning/schems/wither_spawn_z.we b/mods/ENTITIES/mcl_wither_spawning/schems/wither_spawn_z.we new file mode 100644 index 000000000..6b1775773 --- /dev/null +++ b/mods/ENTITIES/mcl_wither_spawning/schems/wither_spawn_z.we @@ -0,0 +1 @@ +return {{["y"] = 0, ["x"] = 0, ["name"] = "mcl_nether:soul_sand", ["z"] = 1}, {["y"] = 1, ["x"] = 0, ["name"] = "mcl_nether:soul_sand", ["z"] = 0}, {["y"] = 1, ["x"] = 0, ["name"] = "mcl_nether:soul_sand", ["z"] = 1}, {["y"] = 1, ["x"] = 0, ["name"] = "mcl_nether:soul_sand", ["z"] = 2}, {["y"] = 2, ["x"] = 0, ["name"] = "mcl_heads:wither_skeleton", ["z"] = 0, ["param2"] = 1, ["param1"] = 15}, {["y"] = 2, ["x"] = 0, ["name"] = "mcl_heads:wither_skeleton", ["z"] = 1, ["param2"] = 1, ["param1"] = 15}, {["y"] = 2, ["x"] = 0, ["name"] = "mcl_heads:wither_skeleton", ["z"] = 2, ["param2"] = 1, ["param1"] = 15}} From 34e5bb03346f4c87a9095b52d796c74f6922c84a Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 27 Apr 2022 12:21:20 +0200 Subject: [PATCH 2/2] Add Wither Spawning --- mods/ENTITIES/mcl_wither_spawning/init.lua | 50 ++++++++++++++++++++++ mods/ENTITIES/mcl_wither_spawning/mod.conf | 4 ++ 2 files changed, 54 insertions(+) create mode 100644 mods/ENTITIES/mcl_wither_spawning/init.lua create mode 100644 mods/ENTITIES/mcl_wither_spawning/mod.conf diff --git a/mods/ENTITIES/mcl_wither_spawning/init.lua b/mods/ENTITIES/mcl_wither_spawning/init.lua new file mode 100644 index 000000000..c89baccf7 --- /dev/null +++ b/mods/ENTITIES/mcl_wither_spawning/init.lua @@ -0,0 +1,50 @@ +local dim = {"x", "z"} + +local modpath = minetest.get_modpath(minetest.get_current_modname()) + +local function load_schem(filename) + local file = io.open(modpath .. "/schems/" .. filename, "r") + local data = minetest.deserialize(file:read()) + file:close() + return data +end + +local wither_spawn_schems = {} + +for _, d in pairs(dim) do + wither_spawn_schems[d] = load_schem("wither_spawn_" .. d .. ".we") +end + +local function check_schem(pos, schem) + for _, n in pairs(schem) do + if minetest.get_node(vector.add(pos, n)).name ~= n.name then + return false + end + end + return true +end + +local function remove_schem(pos, schem) + for _, n in pairs(schem) do + minetest.remove_node(vector.add(pos, n)) + end +end + +local function wither_spawn(pos) + for _, d in pairs(dim) do + for i = 0, 2 do + local p = vector.add(pos, {x = 0, y = -2, z = 0, [d] = -i}) + local schem = wither_spawn_schems[d] + if check_schem(p, schem) then + remove_schem(p, schem) + minetest.add_entity(vector.add(p, {x = 0, y = 1, z = 0, [d] = 1}), "mobs_mc:wither") + end + end + end +end + +local old_onplace=minetest.registered_nodes[mobs_mc.items.head_wither_skeleton].on_place +minetest.registered_nodes[mobs_mc.items.head_wither_skeleton].on_place=function(itemstack,placer,pointed) + minetest.after(0, wither_spawn, pointed.above) + old_onplace(itemstack,placer,pointed) +end diff --git a/mods/ENTITIES/mcl_wither_spawning/mod.conf b/mods/ENTITIES/mcl_wither_spawning/mod.conf new file mode 100644 index 000000000..d144bb1ea --- /dev/null +++ b/mods/ENTITIES/mcl_wither_spawning/mod.conf @@ -0,0 +1,4 @@ +name = mcl_wither_spawning +description = Wither Spawning for MineClone2 +author = Fleckenstein +depends = mobs_mc, mcl_heads