From 00cd9d750f2ee5ce954426251ab97bb304d2e2a6 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Tue, 9 Jun 2020 17:44:13 +0200 Subject: Added Missing Files --- schems/wither_spawn_x.we | 1 + schems/wither_spawn_z.we | 1 + src/common/schems.lua | 42 ++++++++++++++++++++++++++++++++++++++++++ src/main/wither_spawn.lua | 21 +++++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 schems/wither_spawn_x.we create mode 100644 schems/wither_spawn_z.we create mode 100644 src/common/schems.lua create mode 100644 src/main/wither_spawn.lua diff --git a/schems/wither_spawn_x.we b/schems/wither_spawn_x.we new file mode 100644 index 0000000..7b8bc94 --- /dev/null +++ b/schems/wither_spawn_x.we @@ -0,0 +1 @@ +5: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}} \ No newline at end of file diff --git a/schems/wither_spawn_z.we b/schems/wither_spawn_z.we new file mode 100644 index 0000000..0c9973f --- /dev/null +++ b/schems/wither_spawn_z.we @@ -0,0 +1 @@ +5: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"] = 3, ["param1"] = 15}, {["y"] = 2, ["x"] = 0, ["name"] = "mcl_heads:wither_skeleton", ["z"] = 1, ["param2"] = 3, ["param1"] = 15}, {["y"] = 2, ["x"] = 0, ["name"] = "mcl_heads:wither_skeleton", ["z"] = 2, ["param2"] = 3, ["param1"] = 15}} \ No newline at end of file diff --git a/src/common/schems.lua b/src/common/schems.lua new file mode 100644 index 0000000..ace1637 --- /dev/null +++ b/src/common/schems.lua @@ -0,0 +1,42 @@ +skycraft.schems = {} + +function skycraft.get_schem(schemname) + return skycraft.schems[schemname].data +end + +function skycraft.get_schem_raw(schemname) + return skycraft.schems[schemname].raw +end + +function skycraft.load_schem(schemname) + local schem = {} + local file = io.open(skycraft.modpath .. "/schems/" .. schemname .. ".we", "r") + schem.raw = file:read() + file:seek("set") + local _, _, contents = file:read("*number", 1, "*all") + file:close() + schem.data = minetest.deserialize(contents) + skycraft.schems[schemname] = schem +end + +function skycraft.check_schem(pos, schemname) + local schem = skycraft.get_schem(schemname) + 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 + +function skycraft.remove_schem(pos, schemname) + local schem = skycraft.get_schem(schemname) + for _, n in pairs(schem) do + minetest.remove_node(vector.add(pos, n)) + end +end + +function skycraft.add_schem(pos, schemname) + local schem_raw = skycraft.get_schem_raw(schemname) + worldedit.deserialize(pos, schem_raw) +end diff --git a/src/main/wither_spawn.lua b/src/main/wither_spawn.lua new file mode 100644 index 0000000..e52a732 --- /dev/null +++ b/src/main/wither_spawn.lua @@ -0,0 +1,21 @@ +local dim = {"x", "z"} + +for _, d in pairs(dim) do + skycraft.load_schem("wither_spawn_" .. d) +end + +minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing) + if newnode.name == "mcl_heads:wither_skeleton" then + 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 schemname = "wither_spawn_" .. d + if skycraft.check_schem(p, schemname) then + skycraft.remove_schem(p, schemname) + minetest.add_entity(vector.add(p, {x = 0, y = 1, z = 0, [d] = 1}), "mobs_mc:wither") + end + end + end + end +end) + -- cgit v1.2.3