From: Elias Fleckenstein Date: Tue, 9 Jun 2020 11:40:43 +0000 (+0200) Subject: Initial Commit X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=7acef39a284fa9b1fb784b47776bbf2436d7077c;p=mcl_wither_spawning.git Initial Commit --- 7acef39a284fa9b1fb784b47776bbf2436d7077c diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..3882f38 --- /dev/null +++ b/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 + +minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing) + if newnode.name == "mcl_heads:wither_skeleton" then + minetest.after(0, wither_spawn, pos) + end +end) diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..85a667d --- /dev/null +++ b/mod.conf @@ -0,0 +1,3 @@ +name = mcl_wither_spawning +description = Spawn a wither in MineClone2 +depends = mobs_mc, mcl_heads, mcl_nether diff --git a/schems/wither_spawn_x.we b/schems/wither_spawn_x.we new file mode 100644 index 0000000..6394bdc --- /dev/null +++ b/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/schems/wither_spawn_z.we b/schems/wither_spawn_z.we new file mode 100644 index 0000000..6b17757 --- /dev/null +++ b/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}}