Compare commits

..

16 Commits

Author SHA1 Message Date
Mikita Wiśniewski 41b188caea Remove "double drop" mechanics for bamboo (fixes #4514) (#4642)
Reviewed-on: VoxeLibre/VoxeLibre#4642
Reviewed-by: the-real-herowl <the-real-herowl@noreply.git.minetest.land>
Co-authored-by: Mikita Wiśniewski <rudzik8@protonmail.com>
Co-committed-by: Mikita Wiśniewski <rudzik8@protonmail.com>
2024-10-27 14:16:06 +01:00
kno10 ae7995d195 Fix axolotl attacking water mobs (#4675)
Also avoid jumping out of the water closes #4644

Reviewed-on: VoxeLibre/VoxeLibre#4675
Reviewed-by: the-real-herowl <the-real-herowl@noreply.git.minetest.land>
Co-authored-by: kno10 <kno10@noreply.git.minetest.land>
Co-committed-by: kno10 <kno10@noreply.git.minetest.land>
2024-10-27 14:10:11 +01:00
kno10 e293cbe631 Better handling of touching_ground for bouncing on beds (#4689)
Reviewed-on: VoxeLibre/VoxeLibre#4689
Reviewed-by: the-real-herowl <the-real-herowl@noreply.git.minetest.land>
Co-authored-by: kno10 <erich.schubert@gmail.com>
Co-committed-by: kno10 <erich.schubert@gmail.com>
2024-10-27 14:03:50 +01:00
the-real-herowl fd6cac5f0c Merge pull request 'Fix fog tint in overworld, apply memory leak fix, fix rain->clear clouds' (#4669) from weather-fixes into master
Reviewed-on: VoxeLibre/VoxeLibre#4669
Reviewed-by: kno10 <kno10@noreply.git.minetest.land>
2024-10-11 07:14:01 +02:00
teknomunk e864cc19ed Make fog_tint_type = "default" when weather is present to match behavior at 0.87.2 2024-10-09 01:05:20 +02:00
teknomunk 66c3c014a1 Make sure fog tints are preserved during weather is present 2024-10-09 01:05:20 +02:00
teknomunk 7807093b50 Another correction to color interpolation, change day color from layer position 0.15 to 0.50 2024-10-09 01:05:20 +02:00
teknomunk f6c3f4bd16 Correct value clamping 2024-10-09 01:05:20 +02:00
teknomunk 96a03b1923 Remove posibility of nil sky colors in overworld, add line break 2024-10-09 01:05:20 +02:00
teknomunk 2145470f63 Fix clouds during rain->clear weather transition 2024-10-09 01:05:20 +02:00
teknomunk 2ca0ccd8fe Fix fog tint in overworld, apply memory leak fix from rain.lua to snow.lua and thunder.lua 2024-10-09 01:05:20 +02:00
teknomunk 614518c6cd Revert minetest.add_entity() -> mcl_mobs.spawn() from #4445 (#4679)
Reviewed-on: VoxeLibre/VoxeLibre#4679
Reviewed-by: kno10 <kno10@noreply.git.minetest.land>
Co-authored-by: teknomunk <teknomunk@protonmail.com>
Co-committed-by: teknomunk <teknomunk@protonmail.com>
2024-10-08 15:34:30 +02:00
kno10 253a06fa08 Fix mob egg double-spawns (#4657)
If you spawn a mob clicking on a wall, two mobs will be spawned.

To reproduce: face a stack of stones, with a spawn egg click on the side of a stone. It does not happen when you click the top of a node, because spawning below fails and only the second one succeeds.

Reviewed-on: VoxeLibre/VoxeLibre#4657
Reviewed-by: the-real-herowl <the-real-herowl@noreply.git.minetest.land>
Co-authored-by: kno10 <kno10@noreply.git.minetest.land>
Co-committed-by: kno10 <kno10@noreply.git.minetest.land>
2024-09-30 19:21:40 +02:00
kno10 dcfd31d17a Avoid random jumps when standing due to gravity (fewer villagers on the roofs) (#4547)
Reviewed-on: VoxeLibre/VoxeLibre#4547
Reviewed-by: the-real-herowl <the-real-herowl@noreply.git.minetest.land>
Co-authored-by: kno10 <erich.schubert@gmail.com>
Co-committed-by: kno10 <erich.schubert@gmail.com>
2024-09-30 11:22:31 +02:00
teknomunk c34aecfcab Don't make 'ignore' nodes break bamboo or kelp (#4551)
This modifies the behavior of kelp and bamboo so that neither breaks when an unloaded node is encountered.

Reviewed-on: VoxeLibre/VoxeLibre#4551
Reviewed-by: the-real-herowl <the-real-herowl@noreply.git.minetest.land>
Co-authored-by: teknomunk <teknomunk@protonmail.com>
Co-committed-by: teknomunk <teknomunk@protonmail.com>
2024-09-29 13:57:52 +02:00
Mikita Wiśniewski 9cb4f51468 Fix invalid global call in mcl_chests LBM (#4667)
Reviewed-on: VoxeLibre/VoxeLibre#4667
Reviewed-by: the-real-herowl <the-real-herowl@noreply.git.minetest.land>
Co-authored-by: Mikita Wiśniewski <rudzik8@protonmail.com>
Co-committed-by: Mikita Wiśniewski <rudzik8@protonmail.com>
2024-09-29 13:34:20 +02:00
20 changed files with 109 additions and 333 deletions

View File

@ -388,7 +388,7 @@ end
local function on_step_work (self, dtime) local function on_step_work(self, dtime, moveresult)
local pos = self.object:get_pos() local pos = self.object:get_pos()
if not pos then return end if not pos then return end
@ -402,7 +402,7 @@ local function on_step_work (self, dtime)
-- Do we abandon out of here now? -- Do we abandon out of here now?
end end
if self:falling(pos) then return end if self:falling(pos, moveresult) then return end
if self:step_damage (dtime, pos) then return end if self:step_damage (dtime, pos) then return end
if self.state == "die" then return end if self.state == "die" then return end
@ -502,11 +502,11 @@ end
-- main mob function -- main mob function
function mob_class:on_step(dtime) function mob_class:on_step(dtime, moveresult)
if not DEVELOPMENT then if not DEVELOPMENT then
-- Removed as bundled Lua (5.1 doesn't support xpcall) -- Removed as bundled Lua (5.1 doesn't support xpcall)
--local status, retVal = xpcall(on_step_work, on_step_error_handler, self, dtime) --local status, retVal = xpcall(on_step_work, on_step_error_handler, self, dtime)
local status, retVal = pcall(on_step_work, self, dtime) local status, retVal = pcall(on_step_work, self, dtime, moveresult)
if status then if status then
return retVal return retVal
else else
@ -521,7 +521,7 @@ function mob_class:on_step(dtime)
log_error (dump(retVal), dump(pos), dump(self)) log_error (dump(retVal), dump(pos), dump(self))
end end
else else
return on_step_work (self, dtime) return on_step_work (self, dtime, moveresult)
end end
end end

View File

@ -105,7 +105,7 @@ end
-- Spawn a child -- Spawn a child
function mcl_mobs.spawn_child(pos, mob_type) function mcl_mobs.spawn_child(pos, mob_type)
local child = mcl_mobs.spawn(pos, mob_type) local child = minetest.add_entity(pos, mob_type)
if not child then if not child then
return return
end end

View File

@ -615,7 +615,7 @@ function mcl_mobs.register_egg(mob_id, desc, background_color, overlay_color, ad
pos.y = pos.y - 1 pos.y = pos.y - 1
local mob = mcl_mobs.spawn(pos, mob_name) local mob = mcl_mobs.spawn(pos, mob_name)
if not object then if not mob then
pos.y = pos.y + 1 pos.y = pos.y + 1
mob = mcl_mobs.spawn(pos, mob_name) mob = mcl_mobs.spawn(pos, mob_name)
if not mob then return end if not mob then return end

View File

@ -927,8 +927,7 @@ end
-- falling and fall damage -- falling and fall damage
-- returns true if mob died -- returns true if mob died
function mob_class:falling(pos) function mob_class:falling(pos, moveresult)
if self.fly and self.state ~= "die" then if self.fly and self.state ~= "die" then
return return
end end
@ -951,7 +950,13 @@ function mob_class:falling(pos)
new_acceleration = vector.new(0, DEFAULT_FALL_SPEED, 0) new_acceleration = vector.new(0, DEFAULT_FALL_SPEED, 0)
elseif v.y <= 0 and v.y > self.fall_speed then elseif v.y <= 0 and v.y > self.fall_speed then
-- fall downwards at set speed -- fall downwards at set speed
new_acceleration = vector.new(0, self.fall_speed, 0) if moveresult and moveresult.touching_ground then
-- when touching ground, retain a minimal gravity to keep the touching_ground flag
-- but also to not get upwards acceleration with large dtime when on bouncy ground
new_acceleration = vector.new(0, self.fall_speed * 0.01, 0)
else
new_acceleration = vector.new(0, self.fall_speed, 0)
end
else else
-- stop accelerating once max fall speed hit -- stop accelerating once max fall speed hit
new_acceleration =vector.zero() new_acceleration =vector.zero()

View File

@ -72,18 +72,24 @@ local axolotl = {
fly = true, fly = true,
fly_in = { "mcl_core:water_source", "mclx_core:river_water_source" }, fly_in = { "mcl_core:water_source", "mclx_core:river_water_source" },
breathes_in_water = true, breathes_in_water = true,
jump = true, jump = false, -- would get them out of the water too often
damage = 2, damage = 2,
reach = 2, reach = 2,
attack_type = "dogfight", attack_type = "dogfight",
attack_animals = true, attack_animals = true,
specific_attack = { specific_attack = {
"extra_mobs_cod", "mobs_mc:cod",
"extra_mobs_glow_squid", "mobs_mc:glow_squid",
"extra_mobs_salmon", "mobs_mc:salmon",
"extra_mobs_tropical_fish", "mobs_mc:tropical_fish",
"mobs_mc_squid" "mobs_mc:squid",
}, "mobs_mc:zombie", -- todo: only drowned?
"mobs_mc:baby_zombie",
"mobs_mc:husk",
"mobs_mc:baby_husk",
"mobs_mc:guardian_elder",
"mobs_mc:guardian",
},
runaway = true, runaway = true,
} }

View File

@ -157,6 +157,7 @@ function mcl_weather.rain.clear()
mcl_weather.rain.remove_sound(player) mcl_weather.rain.remove_sound(player)
mcl_weather.rain.remove_player(player) mcl_weather.rain.remove_player(player)
mcl_weather.remove_spawners_player(player) mcl_weather.remove_spawners_player(player)
player:set_clouds({color="#FFF0EF"})
end end
end end

View File

@ -2,6 +2,7 @@
local modname = minetest.get_current_modname() local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname) local modpath = minetest.get_modpath(modname)
local NIGHT_VISION_RATIO = 0.45 local NIGHT_VISION_RATIO = 0.45
local DEBUG = false
-- Settings -- Settings
local minimum_update_interval = { 250e3 } local minimum_update_interval = { 250e3 }
@ -190,8 +191,8 @@ end
function skycolor_utils.convert_to_rgb(minval, maxval, current_val, colors) function skycolor_utils.convert_to_rgb(minval, maxval, current_val, colors)
-- Clamp current_val to valid range -- Clamp current_val to valid range
current_val = math.min(minval, current_val) current_val = math.max(minval, current_val)
current_val = math.max(maxval, current_val) current_val = math.min(maxval, current_val)
-- Rescale current_val from a number between minval and maxval to a number between 1 and #colors -- Rescale current_val from a number between minval and maxval to a number between 1 and #colors
local scaled_value = (current_val - minval) / (maxval - minval) * (#colors - 1) + 1.0 local scaled_value = (current_val - minval) / (maxval - minval) * (#colors - 1) + 1.0
@ -199,7 +200,7 @@ function skycolor_utils.convert_to_rgb(minval, maxval, current_val, colors)
-- Get the first color's values -- Get the first color's values
local index1 = math.floor(scaled_value) local index1 = math.floor(scaled_value)
local color1 = colors[index1] local color1 = colors[index1]
local frac1 = scaled_value - index1 local frac1 = 1.0 - (scaled_value - index1)
-- Get the second color's values -- Get the second color's values
local index2 = math.min(index1 + 1, #colors) -- clamp to maximum color index (will occur if index1 == #colors) local index2 = math.min(index1 + 1, #colors) -- clamp to maximum color index (will occur if index1 == #colors)
@ -207,11 +208,32 @@ function skycolor_utils.convert_to_rgb(minval, maxval, current_val, colors)
local color2 = colors[index2] local color2 = colors[index2]
-- Interpolate between color1 and color2 -- Interpolate between color1 and color2
return { local res = {
r = math.floor(frac1 * color1.r + frac2 * color2.r), r = math.floor(frac1 * color1.r + frac2 * color2.r),
g = math.floor(frac1 * color1.g + frac2 * color2.g), g = math.floor(frac1 * color1.g + frac2 * color2.g),
b = math.floor(frac1 * color1.b + frac2 * color2.b), b = math.floor(frac1 * color1.b + frac2 * color2.b),
} }
if DEBUG then
minetest.log(dump({
minval = minval,
maxval = maxval,
current_val = current_val,
colors = colors,
res = res,
scaled_value = scaled_value,
frac1 = frac1,
index1 = index1,
color1 = color1,
frac2 = frac2,
index2 = index2,
color2 = color2,
}))
end
return res
end end
-- Simple getter. Either returns user given players list or get all connected players if none provided -- Simple getter. Either returns user given players list or get all connected players if none provided

View File

@ -40,18 +40,21 @@ function dimension_handlers.overworld(player, sky_data)
end end
-- Use overworld defaults -- Use overworld defaults
local day_color = mcl_weather.skycolor.get_sky_layer_color(0.15) local day_color = mcl_weather.skycolor.get_sky_layer_color(0.5)
local dawn_color = mcl_weather.skycolor.get_sky_layer_color(0.27) local dawn_color = mcl_weather.skycolor.get_sky_layer_color(0.27)
local night_color = mcl_weather.skycolor.get_sky_layer_color(0.1) local night_color = mcl_weather.skycolor.get_sky_layer_color(0.1)
sky_data.sky = { sky_data.sky = {
type = "regular", type = "regular",
sky_color = { sky_color = {
day_sky = day_color, day_sky = day_color or "#7BA4FF",
day_horizon = day_color, day_horizon = day_color or "#C0D8FF",
dawn_sky = dawn_color, dawn_sky = dawn_color or "7BA4FF",
dawn_horizon = dawn_color, dawn_horizon = dawn_color or "#C0D8FF",
night_sky = night_color, night_sky = night_color or "000000",
night_horizon = night_color, night_horizon = night_color or "4A6790",
fog_sun_tint = "#ff5f33",
fog_moon_tint = nil,
fog_tint_type = "custom",
}, },
clouds = true, clouds = true,
} }
@ -75,18 +78,15 @@ function dimension_handlers.overworld(player, sky_data)
local day_color = mcl_weather.skycolor.get_sky_layer_color(0.5) local day_color = mcl_weather.skycolor.get_sky_layer_color(0.5)
local dawn_color = mcl_weather.skycolor.get_sky_layer_color(0.75) local dawn_color = mcl_weather.skycolor.get_sky_layer_color(0.75)
local night_color = mcl_weather.skycolor.get_sky_layer_color(0) local night_color = mcl_weather.skycolor.get_sky_layer_color(0)
sky_data.sky = { table.update(sky_data.sky.sky_color,{
type = "regular", day_sky = day_color or "#7BA4FF",
sky_color = { day_horizon = day_color or "#C0D8FF",
day_sky = day_color, dawn_sky = dawn_color or "7BA4FF",
day_horizon = day_color, dawn_horizon = dawn_color or "#C0D8FF",
dawn_sky = dawn_color, night_sky = night_color or "000000",
dawn_horizon = dawn_color, night_horizon = night_color or "4A6790",
night_sky = night_color, fog_tint_type = "default",
night_horizon = night_color, })
},
clouds = true,
}
sky_data.sun = {visible = false, sunrise_visible = false} sky_data.sun = {visible = false, sunrise_visible = false}
sky_data.moon = {visible = false} sky_data.moon = {visible = false}
sky_data.stars = {visible = false} sky_data.stars = {visible = false}
@ -164,7 +164,8 @@ function dimension_handlers.nether(player, sky_data)
end end
function dimension_handlers.void(player, sky_data) function dimension_handlers.void(player, sky_data)
sky_data.sky = { type = "plain", sky_data.sky = {
type = "plain",
base_color = "#000000", base_color = "#000000",
clouds = false, clouds = false,
} }

View File

@ -75,13 +75,15 @@ function mcl_weather.has_snow(pos)
end end
function mcl_weather.snow.set_sky_box() function mcl_weather.snow.set_sky_box()
mcl_weather.skycolor.add_layer( if mcl_weather.skycolor.current_layer_name() ~= "weather-pack-snow-sky" then
"weather-pack-snow-sky", mcl_weather.skycolor.add_layer(
{{r=0, g=0, b=0}, "weather-pack-snow-sky",
{r=85, g=86, b=86}, {{r=0, g=0, b=0},
{r=135, g=135, b=135}, {r=85, g=86, b=86},
{r=85, g=86, b=86}, {r=135, g=135, b=135},
{r=0, g=0, b=0}}) {r=85, g=86, b=86},
{r=0, g=0, b=0}})
end
mcl_weather.skycolor.active = true mcl_weather.skycolor.active = true
for _, player in pairs(get_connected_players()) do for _, player in pairs(get_connected_players()) do
player:set_clouds({color="#ADADADE8"}) player:set_clouds({color="#ADADADE8"})

View File

@ -23,13 +23,15 @@ minetest.register_globalstep(function(dtime)
mcl_weather.rain.make_weather() mcl_weather.rain.make_weather()
if mcl_weather.thunder.init_done == false then if mcl_weather.thunder.init_done == false then
mcl_weather.skycolor.add_layer("weather-pack-thunder-sky", { if mcl_weather.skycolor.current_layer_name() ~= "weather-pack-thunder-sky" then
{r=0, g=0, b=0}, mcl_weather.skycolor.add_layer("weather-pack-thunder-sky", {
{r=40, g=40, b=40}, {r=0, g=0, b=0},
{r=85, g=86, b=86}, {r=40, g=40, b=40},
{r=40, g=40, b=40}, {r=85, g=86, b=86},
{r=0, g=0, b=0}, {r=40, g=40, b=40},
}) {r=0, g=0, b=0},
})
end
mcl_weather.skycolor.active = true mcl_weather.skycolor.active = true
for _, player in pairs(get_connected_players()) do for _, player in pairs(get_connected_players()) do
player:set_clouds({color="#3D3D3FE8"}) player:set_clouds({color="#3D3D3FE8"})

View File

@ -5,9 +5,6 @@
--- Copyright (C) 2022 - 2023, Michieal. See License.txt --- Copyright (C) 2022 - 2023, Michieal. See License.txt
-- CONSTS -- CONSTS
local DOUBLE_DROP_CHANCE = 8
-- Used everywhere. Often this is just the name, but it makes sense to me as BAMBOO, because that's how I think of it...
-- "BAMBOO" goes here.
local BAMBOO = "mcl_bamboo:bamboo" local BAMBOO = "mcl_bamboo:bamboo"
local BAMBOO_ENDCAP_NAME = "mcl_bamboo:bamboo_endcap" local BAMBOO_ENDCAP_NAME = "mcl_bamboo:bamboo_endcap"
local BAMBOO_PLANK = BAMBOO .. "_plank" local BAMBOO_PLANK = BAMBOO .. "_plank"
@ -16,7 +13,7 @@ local BAMBOO_PLANK = BAMBOO .. "_plank"
local modname = minetest.get_current_modname() local modname = minetest.get_current_modname()
local S = minetest.get_translator(modname) local S = minetest.get_translator(modname)
local node_sound = mcl_sounds.node_sound_wood_defaults() local node_sound = mcl_sounds.node_sound_wood_defaults()
local pr = PseudoRandom((os.time() + 15766) * 12) -- switched from math.random() to PseudoRandom because the random wasn't very random. local pr = PseudoRandom((os.time() + 15766) * 12)
local on_rotate local on_rotate
if minetest.get_modpath("screwdriver") then if minetest.get_modpath("screwdriver") then
@ -31,33 +28,7 @@ local bamboo_def = {
paramtype = "light", paramtype = "light",
groups = {handy = 1, axey = 1, choppy = 1, dig_by_piston = 1, plant = 1, non_mycelium_plant = 1, flammable = 3}, groups = {handy = 1, axey = 1, choppy = 1, dig_by_piston = 1, plant = 1, non_mycelium_plant = 1, flammable = 3},
sounds = node_sound, sounds = node_sound,
drop = BAMBOO,
drop = {
max_items = 1,
-- From the API:
-- max_items: Maximum number of item lists to drop.
-- The entries in 'items' are processed in order. For each:
-- Item filtering is applied, chance of drop is applied, if both are
-- successful the entire item list is dropped.
-- Entry processing continues until the number of dropped item lists
-- equals 'max_items'.
-- Therefore, entries should progress from low to high drop chance.
items = {
-- Examples:
{
-- 1 in DOUBLE_DROP_CHANCE chance of dropping.
-- Default rarity is '1'.
rarity = DOUBLE_DROP_CHANCE,
items = {BAMBOO .. " 2"},
},
{
-- 1 in 1 chance of dropping. (Note: this means that it will drop 100% of the time.)
-- Default rarity is '1'.
rarity = 1,
items = {BAMBOO},
},
},
},
inventory_image = "mcl_bamboo_bamboo_shoot.png", inventory_image = "mcl_bamboo_bamboo_shoot.png",
wield_image = "mcl_bamboo_bamboo_shoot.png", wield_image = "mcl_bamboo_bamboo_shoot.png",
@ -86,7 +57,6 @@ local bamboo_def = {
on_rotate = on_rotate, on_rotate = on_rotate,
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
if not pointed_thing then if not pointed_thing then
return itemstack return itemstack
end end
@ -241,9 +211,6 @@ local bamboo_def = {
if node_above and ((bamboo_node and bamboo_node > 0) or node_above.name == BAMBOO_ENDCAP_NAME) then if node_above and ((bamboo_node and bamboo_node > 0) or node_above.name == BAMBOO_ENDCAP_NAME) then
minetest.remove_node(new_pos) minetest.remove_node(new_pos)
minetest.sound_play(node_sound.dug, sound_params, true) minetest.sound_play(node_sound.dug, sound_params, true)
if pr:next(1, DOUBLE_DROP_CHANCE) == 1 then
minetest.add_item(new_pos, istack)
end
minetest.add_item(new_pos, istack) minetest.add_item(new_pos, istack)
end end
end, end,

View File

@ -9,8 +9,6 @@ local SIDE_SCAFFOLDING = false
local SIDE_SCAFFOLD_NAME = "mcl_bamboo:scaffolding_horizontal" local SIDE_SCAFFOLD_NAME = "mcl_bamboo:scaffolding_horizontal"
-- --------------------------------------------------------------------------- -- ---------------------------------------------------------------------------
local SCAFFOLDING_NAME = "mcl_bamboo:scaffolding" local SCAFFOLDING_NAME = "mcl_bamboo:scaffolding"
-- Used everywhere. Often this is just the name, but it makes sense to me as BAMBOO, because that's how I think of it...
-- "BAMBOO" goes here.
local BAMBOO = "mcl_bamboo:bamboo" local BAMBOO = "mcl_bamboo:bamboo"
local BAMBOO_PLANK = BAMBOO .. "_plank" local BAMBOO_PLANK = BAMBOO .. "_plank"

View File

@ -74,7 +74,7 @@ function mcl_bamboo.break_orphaned(pos)
local node_name = node_below.name local node_name = node_below.name
-- short circuit checks. -- short circuit checks.
if mcl_bamboo.is_dirt(node_name) or mcl_bamboo.is_bamboo(node_name) or mcl_bamboo.is_bamboo(minetest.get_node(pos).name) == false then if node_name == "ignore" or mcl_bamboo.is_dirt(node_name) or mcl_bamboo.is_bamboo(node_name) or mcl_bamboo.is_bamboo(minetest.get_node(pos).name) == false then
return return
end end

View File

@ -7,8 +7,6 @@
-- LOCALS -- LOCALS
local modname = minetest.get_current_modname() local modname = minetest.get_current_modname()
-- Used everywhere. Often this is just the name, but it makes sense to me as BAMBOO, because that's how I think of it...
-- "BAMBOO" goes here.
local BAMBOO = "mcl_bamboo:bamboo" local BAMBOO = "mcl_bamboo:bamboo"
mcl_bamboo = {} mcl_bamboo = {}

View File

@ -5,8 +5,6 @@
--- These are all of the fuel recipes and all of the crafting recipes, consolidated into one place. --- These are all of the fuel recipes and all of the crafting recipes, consolidated into one place.
--- Copyright (C) 2022 - 2023, Michieal. See License.txt --- Copyright (C) 2022 - 2023, Michieal. See License.txt
-- Used everywhere. Often this is just the name, but it makes sense to me as BAMBOO, because that's how I think of it...
-- "BAMBOO" goes here.
local BAMBOO = "mcl_bamboo:bamboo" local BAMBOO = "mcl_bamboo:bamboo"
local BAMBOO_PLANK = BAMBOO .. "_plank" local BAMBOO_PLANK = BAMBOO .. "_plank"
-- Craftings -- Craftings

View File

@ -79,7 +79,7 @@ minetest.register_lbm({
local node_name = node.name local node_name = node.name
node.name = node_name .. "_small" node.name = node_name .. "_small"
minetest.swap_node(pos, node) minetest.swap_node(pos, node)
select_and_spawn_entity(pos, node) mcl_chests.select_and_spawn_entity(pos, node)
if node_name == "mcl_chests:trapped_chest_on" then if node_name == "mcl_chests:trapped_chest_on" then
minetest.log("action", "[mcl_chests] Disabled active trapped chest on load: " .. minetest.pos_to_string(pos)) minetest.log("action", "[mcl_chests] Disabled active trapped chest on load: " .. minetest.pos_to_string(pos))
mcl_chests.chest_update_after_close(pos) mcl_chests.chest_update_after_close(pos)

View File

@ -1,194 +0,0 @@
local storage = minetest.get_mod_storage()
local mod = mcl_lightning_rods
local BLOCK_SIZE = 64
-- Helper functions
function vector_floor(v)
return vector.new( math.floor(v.x), math.floor(v.y), math.floor(v.z) )
end
function vector_min(a,b)
return vector.new( math.min(a.x,b.x), math.min(a.y,b.y), math.min(a.z,b.z) )
end
function vector_max(a,b)
return vector.new( math.max(a.x,b.x), math.max(a.y,b.y), math.max(a.z,b.z) )
end
local function read_voxel_area(pos1, pos2)
local vm = minetest.get_voxel_manip()
local minp, maxp = vm:read_from_map(pos1, pos2)
local data = vm:get_data()
local area = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
return vm,data,area
end
local function load_index(x,y,z)
local idx_key = string.format("%d-%d,%d,%d",BLOCK_SIZE,x,y,z)
local idx_str = storage:get_string(idx_key)
if idx_str and idx_str ~= "" then
local idx = minetest.deserialize(idx_str)
return idx
end
return {}
end
local function load_index_vector(pos)
return load_index(pos.x,pos.y,pos.z)
end
local function save_index(x,y,z, idx)
local idx_str = minetest.serialize(idx)
local idx_key = string.format("%d-%d,%d,%d",BLOCK_SIZE,x,y,z)
storage:set_string(idx_key, idx_str)
end
local function save_index_vector(pos, idx)
return save_index(pos.x,pos.y,pos.z, idx)
end
-- Remove duplicates and verify all locations have a lightning attractor present
local function clean_index(idx, drop)
local new_idx = {}
local exists = {}
for _,p in ipairs(idx) do
local key = string.format("%d,%d,%d",p.x,p.y,p.z)
if not exists[key] then
exists[key] = true
local node = minetest.get_node(p)
if minetest.get_item_group(node.name, "attracts_lightning") ~= 0 or (drop and vector.distance(p,drop) < 0.1 ) then
new_idx[#new_idx + 1] = p
end
end
end
return new_idx
end
function mod.find_attractors_in_area(pos1, pos2)
-- Normalize the search area into large, regular blocks
local pos1_r = vector_floor(pos1 / BLOCK_SIZE)
local pos2_r = vector_floor(pos2 / BLOCK_SIZE)
local min = vector_min(pos1_r, pos2_r)
local max = vector_max(pos1_r, pos2_r)
local results = {}
for z = min.z,max.z do
for y = min.y,max.y do
for x = min.x,max.x do
local idx = load_index(x,y,z)
-- Make sure every indexed position actually has a lightning attractor present
for _,pos in ipairs(idx) do
local node = minetest.get_node(pos)
if minetest.get_item_group(node.name, "attracts_lightning") ~= 0 then
results[#results + 1] = pos
end
end
end
end
end
return results
end
local function find_closest_position_in_list(pos, list)
local dist = nil
local best = nil
for _,p in ipairs(list) do
local p_dist = vector.distance(p,pos)
if not dist or p_dist < dist then
dist = p_dist
best = p
end
end
return best
end
function mod.find_closest_attractor(pos, search_size)
local attractor_positions = mod.find_attractors_in_area(
vector.offset(pos, -search_size, -search_size, -search_size),
vector.offset(pos, search_size, search_size, search_size)
)
return find_closest_position_in_list(pos, attractor_positions)
end
function mod.unregister_lightning_attractor(pos)
-- Verify the node no longer attracts lightning
local node = minetest.get_node(pos)
if minetest.get_item_group(node.name, "attracts_lightning") ~= 0 then return end
-- Get the existing index data (if any)
local pos_r = vector_floor(pos / BLOCK_SIZE)
local idx = load_index_vector(pos_r)
-- Clean the index and drop this node
idx = clean_index(idx, pos)
save_index_vector(pos_r, idx)
end
function mod.register_lightning_attractor(pos)
-- Verify the node attracts lightning
local node = minetest.get_node(pos)
if minetest.get_item_group(node.name, "attracts_lightning") == 0 then return end
-- Get the existing index data (if any)
local pos_r = vector_floor(pos / BLOCK_SIZE)
local idx = load_index_vector(pos_r)
for _,p in ipairs(idx) do
-- Don't need to change anything if the rod is already registered
if vector.distance(p,pos) < 0.1 then return end
end
-- Add and save the rod position
idx[#idx + 1] = pos
-- Clean and save the index data
clean_index(idx)
save_index_vector(pos_r, idx)
end
-- Constants used for content id index
local IS_ATTRACTOR = {}
local IS_NOT_ATTRACTOR = {}
function mod.index_block(pos)
local pos_r = vector_floor(pos1 / BLOCK_SIZE)
local pos1 = vector.multiply(pos_r,BLOCK_SIZE)
local pos2 = vector.offset(pos,BLOCK_SIZE - 1,BLOCK_SIZE - 1,BLOCK_SIZE - 1)
-- We are completely rebuilding the index data so there is no nead to load
-- the existing data
local idx = {}
-- Setup voxel manipulator
local vm,data,area = read_voxel_area()
-- Indexes to speed things up
local cid_attractors = {}
-- Iterate over the area and look for lightning attractors
local minx = pos1.x
local maxx = pos1.x
for z = pos1.z,pos2.z do
for y = pos1.y,pos2.y do
for x = minx,maxx do
local vi = area:index(x,y,z)
local cid = data[vi]
local attr = cid_attractors[cid]
if attr then
if attr == IS_ATTRACTOR then
idx[#idx + 1] = vector.new(x,y,z)
end
else
-- Lookup data and cache for later
local name = minetest.get_name_from_content_id(cid)
if minetest.get_item_group(name, "attracts_lightning") then
cid_attractors = IS_ATTRACTOR
idx[#idx + 1] = vector.new(x,y,z)
else
cid_attractors = IS_NOT_ATTRACTOR
end
end
end
end
end
-- Save for later use
save_index_vector(pos_r, idx)
end

View File

@ -1,12 +1,5 @@
local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname)
local S = minetest.get_translator("mcl_lightning_rods") local S = minetest.get_translator("mcl_lightning_rods")
mcl_lightning_rods = {}
local mod = mcl_lightning_rods
dofile(modpath.."/api.lua")
---@type nodebox ---@type nodebox
local cbox = { local cbox = {
type = "fixed", type = "fixed",
@ -66,17 +59,6 @@ local rod_def = {
return minetest.item_place(itemstack, placer, pointed_thing, param2) return minetest.item_place(itemstack, placer, pointed_thing, param2)
end, end,
after_place_node = function(pos, placer, itemstack, pointed_thing)
mod.register_lightning_attractor(pos)
end,
after_destruct = function(pos, oldnode)
mod.unregister_lightning_attractor(pos)
end,
_on_lightning_strike = function(pos, node)
minetest.set_node(pos, { name = "mcl_lightning_rods:rod_powered", param2 = node.param2 })
mesecon.receptor_on(pos, mesecon.rules.alldirs)
minetest.get_node_timer(pos):start(0.4)
end,
_mcl_blast_resistance = 6, _mcl_blast_resistance = 6,
_mcl_hardness = 3, _mcl_hardness = 3,
@ -110,21 +92,21 @@ end
minetest.register_node("mcl_lightning_rods:rod_powered", rod_def_a) minetest.register_node("mcl_lightning_rods:rod_powered", rod_def_a)
lightning.register_on_strike(function(pos, pos2, objects) lightning.register_on_strike(function(pos, pos2, objects)
local lr = mod.find_closest_attractor(pos, 64) local lr = minetest.find_node_near(pos, 128, { "group:attracts_lightning" }, true)
if not lr then return end
-- Make sure this possition attracts lightning if lr then
local node = minetest.get_node(lr) local node = minetest.get_node(lr)
if minetest.get_item_group(node.name, "attracts_lightning") == 0 then return end
-- Allow the node to process a lightning strike if node.name == "mcl_lightning_rods:rod" then
local nodedef = minetest.registered_nodes[node.name] minetest.set_node(lr, { name = "mcl_lightning_rods:rod_powered", param2 = node.param2 })
if nodedef and nodedef._on_lightning_strike then mesecon.receptor_on(lr, mesecon.rules.alldirs)
nodedef._on_lightning_strike(lr, node) minetest.get_node_timer(lr):start(0.4)
end
end end
return lr return lr, nil
end) end)
minetest.register_craft({ minetest.register_craft({
@ -135,10 +117,3 @@ minetest.register_craft({
{ "", "mcl_copper:copper_ingot", "" }, { "", "mcl_copper:copper_ingot", "" },
}, },
}) })
minetest.register_lbm({
name = "mcl_lightning_rods:index_rods",
nodenames = {"mcl_lightning_rods:rod","mcl_lightning_rods:rod_powered"},
action = function(pos, node)
mod.register_lightning_attractor(pos)
end
})

View File

@ -196,7 +196,7 @@ function kelp.find_unsubmerged(pos, node, height)
for i=1,height do for i=1,height do
walk_pos.y = y + i walk_pos.y = y + i
local walk_node = mt_get_node(walk_pos) local walk_node = mt_get_node(walk_pos)
if not kelp.is_submerged(walk_node) then if walk_node.name ~= "ignore" and not kelp.is_submerged(walk_node) then
return walk_pos, walk_node, height, i return walk_pos, walk_node, height, i
end end
end end

View File

@ -213,11 +213,6 @@ local player_attached = mcl_player.player_attached
-- Check each player and apply animations -- Check each player and apply animations
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
-- Track server lag greater than 110ms
if dtime > 0.11 then
minetest.log("warning", "Timestep greater than 110ms("..tostring(math.floor(dtime*1000)).." ms), server lag detected")
end
for _, player in pairs(minetest.get_connected_players()) do for _, player in pairs(minetest.get_connected_players()) do
local name = player:get_player_name() local name = player:get_player_name()
local model_name = player_model[name] local model_name = player_model[name]