From cbd3a491f6d23e0e74bb66861038cc7340ff05a9 Mon Sep 17 00:00:00 2001 From: MysticTempest Date: Mon, 25 Jan 2021 20:23:38 -0600 Subject: [PATCH 1/2] Add support for mcimported worlds by clearing out singlenode mapgen, and adding a toggleable fix for converted double_plants. --- mods/CORE/mcl_init/init.lua | 12 +++++++++- mods/ITEMS/mcl_flowers/init.lua | 31 ++++++++++++++++++++++++++ mods/MAPGEN/mcl_dungeons/init.lua | 2 ++ mods/MAPGEN/tsm_railcorridors/init.lua | 6 ++++- settingtypes.txt | 4 ++++ 5 files changed, 53 insertions(+), 2 deletions(-) diff --git a/mods/CORE/mcl_init/init.lua b/mods/CORE/mcl_init/init.lua index a1346f50..ebbfd559 100644 --- a/mods/CORE/mcl_init/init.lua +++ b/mods/CORE/mcl_init/init.lua @@ -25,6 +25,7 @@ mcl_vars.inventory_header = "" local mg_name = minetest.get_mapgen_setting("mg_name") local minecraft_height_limit = 256 local superflat = mg_name == "flat" and minetest.get_mapgen_setting("mcl_superflat_classic") == "true" +local singlenode = mg_name == "singlenode" -- Calculate mapgen_edge_min/mapgen_edge_max mcl_vars.chunksize = math.max(1, tonumber(minetest.get_mapgen_setting("chunksize")) or 5) @@ -45,7 +46,7 @@ local numcmax = math.max(math.floor((mapgen_limit_max - ccfmax) / chunk_size_in_ mcl_vars.mapgen_edge_min = central_chunk_min_pos - numcmin * chunk_size_in_nodes mcl_vars.mapgen_edge_max = central_chunk_max_pos + numcmax * chunk_size_in_nodes -if not superflat then +if not superflat and not singlenode then -- Normal mode --[[ Realm stacking (h is for height) - Overworld (h>=256) @@ -66,6 +67,14 @@ if not superflat then mcl_vars.mg_lava = true mcl_vars.mg_bedrock_is_rough = true +elseif singlenode then + mcl_vars.mg_overworld_min = -66 + mcl_vars.mg_overworld_max_official = mcl_vars.mg_overworld_min + minecraft_height_limit + mcl_vars.mg_bedrock_overworld_min = mcl_vars.mg_overworld_min + mcl_vars.mg_bedrock_overworld_max = mcl_vars.mg_bedrock_overworld_min + mcl_vars.mg_lava = false + mcl_vars.mg_lava_overworld_max = mcl_vars.mg_overworld_min + mcl_vars.mg_bedrock_is_rough = false else -- Classic superflat local ground = minetest.get_mapgen_setting("mgflat_ground_level") @@ -128,3 +137,4 @@ minetest.craftitemdef_default.stack_max = 64 -- Set random seed for all other mods (Remember to make sure no other mod calls this function) math.randomseed(os.time()) + diff --git a/mods/ITEMS/mcl_flowers/init.lua b/mods/ITEMS/mcl_flowers/init.lua index 42deede2..af892bfa 100644 --- a/mods/ITEMS/mcl_flowers/init.lua +++ b/mods/ITEMS/mcl_flowers/init.lua @@ -448,3 +448,34 @@ minetest.register_node("mcl_flowers:waterlily", { -- Legacy support minetest.register_alias("mcl_core:tallgrass", "mcl_flowers:tallgrass") + +-- mcimport support: re-adds missing double_plant tops in mcimported worlds. +local mg_name = minetest.get_mapgen_setting("mg_name") +local mod_mcimport = minetest.get_modpath("mcimport") ~= nil +local fix_doubleplants = minetest.settings:get_bool("fix_doubleplants", true) + + + if mod_mcimport and mg_name == "singlenode" and fix_doubleplants == true then + local flowernames = { "peony", "rose_bush", "lilac", "sunflower", "double_fern", "double_grass" } + for c=1, 6 do + local flowername = flowernames[c] + end + + minetest.register_lbm({ + label = "Add double plant tops.", + name = "mcl_flowers:double_plant_topper", + run_at_every_load = true, + nodenames = { "mcl_flowers:peony", "mcl_flowers:rose_bush", "mcl_flowers:lilac", "mcl_flowers:sunflower", "mcl_flowers:double_fern", "mcl_flowers:double_grass" }, + action = function(pos, node) + for c=1, 6 do + local flowername = flowernames[c] + local bottom = pos + local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z } + if node.name == "mcl_flowers:"..flowername then + minetest.set_node(top, {name = "mcl_flowers:"..flowername.."_top"}) + end + end + end, + }) + end + diff --git a/mods/MAPGEN/mcl_dungeons/init.lua b/mods/MAPGEN/mcl_dungeons/init.lua index e1218c0b..1ce1556b 100644 --- a/mods/MAPGEN/mcl_dungeons/init.lua +++ b/mods/MAPGEN/mcl_dungeons/init.lua @@ -8,6 +8,7 @@ if mcl_vars.mg_dungeons == false then return end +if mg_name ~= "singlenode" then -- Get loot for dungeon chests local get_loot = function() local loottable = { @@ -396,3 +397,4 @@ minetest.register_on_generated(function(minp, maxp) end end) +end diff --git a/mods/MAPGEN/tsm_railcorridors/init.lua b/mods/MAPGEN/tsm_railcorridors/init.lua index 3cc0d75d..f2e02d99 100644 --- a/mods/MAPGEN/tsm_railcorridors/init.lua +++ b/mods/MAPGEN/tsm_railcorridors/init.lua @@ -15,7 +15,11 @@ end -- Probability for every newly generated mapchunk to get corridors local probability_railcaves_in_mapchunk = P(0.33333) setting = tonumber(minetest.settings:get("tsm_railcorridors_probability_railcaves_in_mapchunk")) -if setting then +-- Extra check to prevent mod griefing in singlenode, mcimported worlds. +local mg_name = minetest.get_mapgen_setting("mg_name") +if mg_name == "singlenode" then + probability_railcaves_in_mapchunk = P(0) +elseif setting then probability_railcaves_in_mapchunk = P(setting) end diff --git a/settingtypes.txt b/settingtypes.txt index 49274244..b7a75e52 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -126,3 +126,7 @@ mcl_superflat_classic (Classic superflat map generation) bool false # WARNING: This setting has quite poor performance and can slow down your # game by a lot. mcl_node_particles (Block particles detail level) enum none high,medium,low,none + + +# If enabled, will run an LBM to fix the top 1/2 of double plants in mcimported worlds; defaults to true. +fix_doubleplants (Mcimport double plant fixes) bool true From 174a3a29681e43230edc51a8fb918784bbe2d9b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20=C3=85str=C3=B6m?= Date: Tue, 26 Jan 2021 14:13:21 +0100 Subject: [PATCH 2/2] Fix creeper explosions only doing 1/2 heart damage The solution was to move the creeper explosions to originate from the center of the creepers collisionbox and not its entity position. --- mods/CORE/mcl_util/init.lua | 11 ++++++++++- mods/ENTITIES/mcl_mobs/api.lua | 3 +-- mods/ENTITIES/mobs_mc/creeper.lua | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index 7e851336..6c63c21a 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -395,4 +395,13 @@ function mcl_util.generate_on_place_plant_function(condition) end end - +-- adjust the y level of an object to the center of its collisionbox +-- used to get the origin position of entity explosions +function mcl_util.get_object_center(obj) + local collisionbox = obj:get_properties().collisionbox + local pos = obj:get_pos() + local ymin = collisionbox[2] + local ymax = collisionbox[5] + pos.y = pos.y + (ymax - ymin) / 2.0 + return pos +end diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 821dbc0e..33e049a8 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -2258,7 +2258,6 @@ local dogswitch = function(self, dtime) return self.dogshoot_switch end - -- execute current state (stand, walk, run, attacks) -- returns true if mob has died local do_states = function(self, dtime) @@ -2550,7 +2549,7 @@ local do_states = function(self, dtime) if mod_explosions then if mobs_griefing and not minetest.is_protected(pos, "") then - mcl_explosions.explode(self.object:get_pos(), self.explosion_strength, { drop_chance = 1.0 }, self.object) + mcl_explosions.explode(mcl_util.get_object_center(self.object), self.explosion_strength, { drop_chance = 1.0 }, self.object) else minetest.sound_play(self.sounds.explode, { pos = pos, diff --git a/mods/ENTITIES/mobs_mc/creeper.lua b/mods/ENTITIES/mobs_mc/creeper.lua index 2beffcf8..f1648525 100644 --- a/mods/ENTITIES/mobs_mc/creeper.lua +++ b/mods/ENTITIES/mobs_mc/creeper.lua @@ -71,7 +71,7 @@ mobs:register_mob("mobs_mc:creeper", { if self._forced_explosion_countdown_timer ~= nil then self._forced_explosion_countdown_timer = self._forced_explosion_countdown_timer - dtime if self._forced_explosion_countdown_timer <= 0 then - mobs:boom(self, self.object:get_pos(), self.explosion_strength) + mobs:boom(self, mcl_util.get_object_center(self.object), self.explosion_strength) self.object:remove() end end