From 430f958faee13f9b9750f37b9a5189fe10a4f309 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Tue, 6 Apr 2021 20:08:20 +0200 Subject: [PATCH] Move end exit portal to 0, 0; Add end gateway portals (WIP) --- mods/ENTITIES/mobs_mc/ender_dragon.lua | 1 + mods/ITEMS/mcl_portals/init.lua | 6 ++- mods/ITEMS/mcl_portals/portal_gateway.lua | 45 ++++++++++++++++++ mods/ITEMS/mcl_portals/portal_nether.lua | 4 +- mods/MAPGEN/mcl_end_island/init.lua | 8 ++-- mods/MAPGEN/mcl_mapgen_core/init.lua | 5 +- mods/MAPGEN/mcl_structures/init.lua | 9 ++++ .../mcl_structures_end_gateway_portal.mts | Bin 0 -> 109 bytes 8 files changed, 66 insertions(+), 12 deletions(-) create mode 100644 mods/ITEMS/mcl_portals/portal_gateway.lua create mode 100644 mods/MAPGEN/mcl_structures/schematics/mcl_structures_end_gateway_portal.mts diff --git a/mods/ENTITIES/mobs_mc/ender_dragon.lua b/mods/ENTITIES/mobs_mc/ender_dragon.lua index fbdaf2bc..92806d87 100644 --- a/mods/ENTITIES/mobs_mc/ender_dragon.lua +++ b/mods/ENTITIES/mobs_mc/ender_dragon.lua @@ -77,6 +77,7 @@ mobs:register_mob("mobs_mc:enderdragon", { end, on_die = function(self, pos) if self._portal_pos then + mcl_portals.spawn_gateway_portal() mcl_structures.call_struct(self._portal_pos, "end_exit_portal_open") if self._initial then mcl_experience.throw_experience(pos, 11500) -- 500 + 11500 = 12000 diff --git a/mods/ITEMS/mcl_portals/init.lua b/mods/ITEMS/mcl_portals/init.lua index 2fd96afa..080051ff 100644 --- a/mods/ITEMS/mcl_portals/init.lua +++ b/mods/ITEMS/mcl_portals/init.lua @@ -1,6 +1,8 @@ -- Load files -mcl_portals = {} +mcl_portals = { + storage = minetest.get_mod_storage(), +} -- Nether portal: -- Obsidian frame, activated by flint and steel @@ -10,3 +12,5 @@ dofile(minetest.get_modpath("mcl_portals").."/portal_nether.lua") -- Red nether brick block frame, activated by an eye of ender dofile(minetest.get_modpath("mcl_portals").."/portal_end.lua") +dofile(minetest.get_modpath("mcl_portals").."/portal_gateway.lua") + diff --git a/mods/ITEMS/mcl_portals/portal_gateway.lua b/mods/ITEMS/mcl_portals/portal_gateway.lua new file mode 100644 index 00000000..cae6fce4 --- /dev/null +++ b/mods/ITEMS/mcl_portals/portal_gateway.lua @@ -0,0 +1,45 @@ +local S = minetest.get_translator("mcl_portals") +local storage = mcl_portals.storage + +local gateway_positions = { + {x = 96, y = -26925, z = 0}, + {x = 91, y = -26925, z = 29}, + {x = 77, y = -26925, z = 56}, + {x = 56, y = -26925, z = 77}, + {x = 29, y = -26925, z = 91}, + {x = 0, y = -26925, z = 96}, + {x = -29, y = -26925, z = 91}, + {x = -56, y = -26925, z = 77}, + {x = -77, y = -26925, z = 56}, + {x = -91, y = -26925, z = 29}, + {x = -96, y = -26925, z = 0}, + {x = -91, y = -26925, z = -29}, + {x = -77, y = -26925, z = -56}, + {x = -56, y = -26925, z = -77}, + {x = -29, y = -26925, z = -91}, + {x = 0, y = -26925, z = -96}, + {x = 29, y = -26925, z = -91}, + {x = 56, y = -26925, z = -77}, + {x = 77, y = -26925, z = -56}, + {x = 91, y = -26925, z = -29}, +} + +function mcl_portals.spawn_gateway_portal() + local id = storage:get_int("gateway_last_id") + 1 + local pos = gateway_positions[id] + if not pos then return end + storage:set_int("gateway_last_id", id) + mcl_structures.call_struct(vector.add(pos, vector.new(-1, -2, -1)), "end_gateway_portal") +end + +local gateway_def = table.copy(minetest.registered_nodes["mcl_portals:portal_end"]) +gateway_def.description = S("End Gateway Portal") +gateway_def._tt_help = S("Used to construct end gateway portals") +gateway_def._doc_items_longdesc = S("An End gateway portal teleports creatures and objects to the outer End (and back!).") +gateway_def._doc_items_usagehelp = S("Throw an ender pearl into the portal to teleport. Entering an Gateway portal near the Overworld teleports you to the outer End. At this destination another gateway portal will be constructed, which you can use to get back.") +gateway_def.after_destruct = nil +gateway_def.drawtype = "normal" +gateway_def.node_box = nil +gateway_def.walkable = true +gateway_def.tiles[3] = nil +minetest.register_node("mcl_portals:portal_gateway", gateway_def) diff --git a/mods/ITEMS/mcl_portals/portal_nether.lua b/mods/ITEMS/mcl_portals/portal_nether.lua index 50a3bde3..9ac569dd 100644 --- a/mods/ITEMS/mcl_portals/portal_nether.lua +++ b/mods/ITEMS/mcl_portals/portal_nether.lua @@ -47,7 +47,7 @@ local chatter = {} local queue = {} local chunks = {} -local storage = minetest.get_mod_storage() +local storage = mcl_portals.storage local exits = {} local keys = minetest.deserialize(storage:get_string("nether_exits_keys") or "return {}") or {} for _, key in pairs(keys) do @@ -193,7 +193,7 @@ end local function destroy_nether_portal(pos, node) if not node then return end local nn, orientation = node.name, node.param2 - local obsidian = nn == OBSIDIAN + local obsidian = nn == OBSIDIAN local check_remove = function(pos, orientation) local node = get_node(pos) diff --git a/mods/MAPGEN/mcl_end_island/init.lua b/mods/MAPGEN/mcl_end_island/init.lua index fb062bf7..73017625 100644 --- a/mods/MAPGEN/mcl_end_island/init.lua +++ b/mods/MAPGEN/mcl_end_island/init.lua @@ -8,12 +8,10 @@ local noisemap = PerlinNoiseMap({ }, {x = 151, y = 30, z = 151}):get_3d_map({x = 0, y = 0, z = 0}) local c_end_stone = minetest.get_content_id("mcl_end:end_stone") - -local x_offset = mcl_vars.mg_end_platform_pos.x - 27 local y_offset = -2 minetest.register_on_generated(function(minp, maxp) - if maxp.y < (-27025 + y_offset) or minp.y > (-27000 + y_offset + 4) or maxp.x < (-75 + x_offset) or minp.x > (75 + x_offset) or maxp.z < -75 or minp.z > 75 then + if maxp.y < (-27025 + y_offset) or minp.y > (-27000 + y_offset + 4) or maxp.x < -75 or minp.x > 75 or maxp.z < -75 or minp.z > 75 then return end @@ -21,10 +19,10 @@ minetest.register_on_generated(function(minp, maxp) local data = vm:get_data() local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax}) - for idx in area:iter(math.max(minp.x, -75 + x_offset), math.max(minp.y, -27025 + y_offset + 4), math.max(minp.z, -75), math.min(maxp.x, 75 + x_offset), math.min(maxp.y, -27000 + y_offset), math.min(maxp.z, 75)) do + for idx in area:iter(math.max(minp.x, -75), math.max(minp.y, -27025 + y_offset + 4), math.max(minp.z, -75), math.min(maxp.x, 75), math.min(maxp.y, -27000 + y_offset), math.min(maxp.z, 75)) do local pos = area:position(idx) local y = 27025 + pos.y - y_offset - if noisemap[pos.x + 75 - x_offset + 1][y + 1][pos.z + 75 + 1] > (math.abs(1 - y / 25) ^ 2 + math.abs((pos.x - x_offset) / 75) ^ 2 + math.abs(pos.z / 75) ^ 2) then + if noisemap[pos.x + 75 + 1][y + 1][pos.z + 75 + 1] > (math.abs(1 - y / 25) ^ 2 + math.abs(pos.x / 75) ^ 2 + math.abs(pos.z / 75) ^ 2) then data[idx] = c_end_stone end end diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index e9d9368a..1ee861e4 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -55,10 +55,7 @@ local superflat = mg_name == "flat" and minetest.get_mapgen_setting("mcl_superfl local WITCH_HUT_HEIGHT = 3 -- Exact Y level to spawn witch huts at. This height refers to the height of the floor -- End exit portal position -local END_EXIT_PORTAL_POS = table.copy(mcl_vars.mg_end_platform_pos) -END_EXIT_PORTAL_POS.x = END_EXIT_PORTAL_POS.x - 30 -END_EXIT_PORTAL_POS.z = END_EXIT_PORTAL_POS.z - 3 -END_EXIT_PORTAL_POS.y = END_EXIT_PORTAL_POS.y - 3 +local END_EXIT_PORTAL_POS = vector.new(-3, -27003, -3) -- Content IDs local c_bedrock = minetest.get_content_id("mcl_core:bedrock") diff --git a/mods/MAPGEN/mcl_structures/init.lua b/mods/MAPGEN/mcl_structures/init.lua index d7585435..00efeca1 100644 --- a/mods/MAPGEN/mcl_structures/init.lua +++ b/mods/MAPGEN/mcl_structures/init.lua @@ -89,6 +89,8 @@ mcl_structures.call_struct = function(pos, struct_style, rotation, pr) return mcl_structures.generate_end_exit_portal(pos, rotation) elseif struct_style == "end_exit_portal_open" then return mcl_structures.generate_end_exit_portal_open(pos, rotation) + elseif struct_style == "end_gateway_portal" then + return mcl_structures.generate_end_gateway_portal(pos, rotation) elseif struct_style == "end_portal_shrine" then return mcl_structures.generate_end_portal_shrine(pos, rotation, pr) end @@ -324,6 +326,11 @@ mcl_structures.generate_end_exit_portal_open = function(pos, rot) return mcl_structures.place_schematic(pos, path, rot or "0", nil, true) end +mcl_structures.generate_end_gateway_portal = function(pos, rot) + local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_gateway_portal.mts" + return mcl_structures.place_schematic(pos, path, rot or "0", nil, true) +end + local function shrine_placement_callback(p1, p2, size, rotation, pr) -- Find and setup spawner with silverfish local spawners = minetest.find_nodes_in_area(p1, p2, "mcl_mobspawners:spawner") @@ -575,6 +582,8 @@ minetest.register_chatcommand("spawnstruct", { mcl_structures.generate_end_exit_portal(pos, rot, pr) elseif param == "end_exit_portal_open" then mcl_structures.generate_end_exit_portal_open(pos, rot, pr) + elseif param == "end_gateway_portal" then + mcl_structures.generate_end_gateway_portal(pos, rot, pr) elseif param == "end_portal_shrine" then mcl_structures.generate_end_portal_shrine(pos, rot, pr) elseif param == "dungeon" and mcl_dungeons and mcl_dungeons.spawn_dungeon then diff --git a/mods/MAPGEN/mcl_structures/schematics/mcl_structures_end_gateway_portal.mts b/mods/MAPGEN/mcl_structures/schematics/mcl_structures_end_gateway_portal.mts new file mode 100644 index 0000000000000000000000000000000000000000..24b06a1c8feb879c7480ccaacebb07c0fa405ac6 GIT binary patch literal 109 zcmeYb3HD`RVPIxpWniuc0U(n(F|&w4AU8QDJ~_WA)ha19r6@l+n?VXBQjlL%l9*F$ z1)<~96H8Ld6Dup`Bqua5xv{Z0q#HLWGBXPcNzbpcSmCbt`t|FFD!X(v85s6$WNQKd D{xKuw literal 0 HcmV?d00001