commit 033e85d534c58db121edf5a7dbdf440d3fb4df2d Author: OldCoder Date: Sun Sep 4 22:03:37 2022 -0700 Imported from trollstream "ContentDB" diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..3e2ba4d --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 ymte + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/__MACOSX/._LICENSE.txt b/__MACOSX/._LICENSE.txt new file mode 100644 index 0000000..3a4f326 Binary files /dev/null and b/__MACOSX/._LICENSE.txt differ diff --git a/__MACOSX/._depends.txt b/__MACOSX/._depends.txt new file mode 100644 index 0000000..75d981e Binary files /dev/null and b/__MACOSX/._depends.txt differ diff --git a/__MACOSX/._init.lua b/__MACOSX/._init.lua new file mode 100644 index 0000000..d08702d Binary files /dev/null and b/__MACOSX/._init.lua differ diff --git a/__MACOSX/._mod.conf b/__MACOSX/._mod.conf new file mode 100644 index 0000000..28446af Binary files /dev/null and b/__MACOSX/._mod.conf differ diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..d5e3ec7 --- /dev/null +++ b/depends.txt @@ -0,0 +1 @@ +mcl_init \ No newline at end of file diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..78125d7 --- /dev/null +++ b/init.lua @@ -0,0 +1,119 @@ +local minx, minz, maxx, maxz +local border_name = "mcl_core:obsidian" +local border_built = false + +function build_border() + if border_built then return end + border_built = true + + -- place border + for dx=-1,16 do + local x = minx + dx + do + local z = maxz + 1 + local y = minetest.get_spawn_level(x,z) + if y then + y = y - 2 + minetest.set_node({x=x, y=y, z=z}, {name=border_name}) + else + border_built = false + end + end + do + local z = minz - 1 + local y = minetest.get_spawn_level(x,z) + if y then + y = y - 2 + minetest.set_node({x=x, y=y, z=z}, {name=border_name}) + else + border_built = false + end + end + end + for dz=-1,16 do + local z = minz + dz + do + local x = maxx + 1 + local y = minetest.get_spawn_level(x,z) + if y then + y = y - 2 + minetest.set_node({x=x, y=y, z=z}, {name=border_name}) + else + border_built = false + end + end + do + local x = minx - 1 + local y = minetest.get_spawn_level(x,z) + if y then + y = y - 2 + minetest.set_node({x=x, y=y, z=z}, {name=border_name}) + else + border_built = false + end + end + end +end + +function gegenereerd() + if not minx or border_built then + return + end + + build_border() +end + +function join(player) + local startpos = player:get_pos() + if not minx then + minx = math.floor(startpos.x / 16) * 16 + minz = math.floor(startpos.z / 16) * 16 + maxx = minx + 15 + maxz = minz + 15 + + build_border() + end +end + +function mag(pos) + if pos.x < minx then return false end + if pos.z < minz then return false end + if pos.x > maxx then return false end + if pos.z > maxz then return false end + return true +end + +function inhoude(dtime) + local players = minetest.get_connected_players() + for _, player in pairs(players) do + local pos = player:get_pos() + if not mag(pos) then + if pos.x < minx then pos.x = minx end + if pos.z < minz then pos.z = minz end + if pos.x > maxx then pos.x = maxx end + if pos.z > maxz then pos.z = maxz end + player:set_pos(pos) + end + end +end + +function place(pos, newnode, placer, oldnode, stemstack, pointed_thing) + if not mag(pos) then + minetest.set_node(pos, oldnode) + return true + else + return false + end +end + +function dig(pos, oldnode, digger) + if not mag(pos) then + minetest.set_node(pos, oldnode) + end +end + +minetest.register_on_generated(gegenereerd) +minetest.register_globalstep(inhoude) +minetest.register_on_joinplayer(join) +minetest.register_on_placenode(place) +minetest.register_on_dignode(dig) \ No newline at end of file diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..e5c0ae3 --- /dev/null +++ b/mod.conf @@ -0,0 +1,9 @@ +name = spawn_chunk +title = Spawn Chunk +description = Limits the player and its actions to the spawn chunk. Works only for MineClone. Credits to MineClone 5 for the screenshot. +author = ymte +license = LICENSE.txt +forum = https://content.minetest.net/threads/2775/ +version = 1.0-RC3 +depends = mcl_init +optional_depends = diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..f4863fc Binary files /dev/null and b/screenshot.png differ