Compare commits

..

6 Commits

14 changed files with 109 additions and 125 deletions

View File

@ -14,7 +14,8 @@ function mcl_burning.is_burning(obj)
end end
function mcl_burning.is_affected_by_rain(obj) function mcl_burning.is_affected_by_rain(obj)
return mcl_weather.get_weather() == "rain" and mcl_weather.is_outdoor(obj:get_pos()) local pos = obj:get_pos()
return mcl_weather.rain.raining and mcl_weather.is_outdoor(pos) and mcl_weather.has_rain(pos)
end end
function mcl_burning.get_collisionbox(obj, smaller, storage) function mcl_burning.get_collisionbox(obj, smaller, storage)

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 = minetest.add_entity(pos, mob_type) local child = mcl_mobs.spawn(pos, mob_type)
if not child then if not child then
return return
end end

View File

@ -653,8 +653,10 @@ function mob_class:do_env_damage()
local _, dim = mcl_worlds.y_to_layer(pos.y) local _, dim = mcl_worlds.y_to_layer(pos.y)
if (self.sunlight_damage ~= 0 or self.ignited_by_sunlight) and (sunlight or 0) >= minetest.LIGHT_MAX and dim == "overworld" then if (self.sunlight_damage ~= 0 or self.ignited_by_sunlight) and (sunlight or 0) >= minetest.LIGHT_MAX and dim == "overworld" then
if self.armor_list and not self.armor_list.helmet or not self.armor_list or self.armor_list and self.armor_list.helmet and self.armor_list.helmet == "" then if self.armor_list and not self.armor_list.helmet or not self.armor_list or self.armor_list and self.armor_list.helmet and self.armor_list.helmet == "" then
if self.ignited_by_sunlight then if self.ignited_by_sunlight and (not mcl_weather.rain.raining or not mcl_weather.has_rain(pos)) then
mcl_burning.set_on_fire(self.object, 10) if (#mcl_burning.get_touching_nodes(self.object, "group:puts_out_fire", self) == 0) then
mcl_burning.set_on_fire(self.object, 10)
end
else else
self:deal_light_damage(pos, self.sunlight_damage) self:deal_light_damage(pos, self.sunlight_damage)
return true return true
@ -692,9 +694,11 @@ function mob_class:do_env_damage()
local nodef3 = minetest.registered_nodes[self.standing_under] local nodef3 = minetest.registered_nodes[self.standing_under]
-- rain -- rain
if self.rain_damage > 0 and mcl_weather.rain.raining and mcl_weather.is_outdoor(pos) then if self.rain_damage > 0 and mcl_burning.is_affected_by_rain(self.object) then
self.health = self.health - self.rain_damage self.health = self.health - self.rain_damage
if self:check_for_death("rain", {type = "environment", pos = pos, node = self.standing_in}) then
if self:check_for_death("rain", {type = "environment",
pos = pos, node = self.standing_in}) then
return true return true
end end
end end
@ -928,6 +932,8 @@ end
-- falling and fall damage -- falling and fall damage
-- returns true if mob died -- returns true if mob died
function mob_class:falling(pos, moveresult) function mob_class:falling(pos, moveresult)
if moveresult and moveresult.touching_ground then return false end
if self.fly and self.state ~= "die" then if self.fly and self.state ~= "die" then
return return
end end
@ -950,13 +956,7 @@ function mob_class:falling(pos, moveresult)
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
if moveresult and moveresult.touching_ground then new_acceleration = vector.new(0, self.fall_speed, 0)
-- 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,24 +72,18 @@ 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 = false, -- would get them out of the water too often jump = true,
damage = 2, damage = 2,
reach = 2, reach = 2,
attack_type = "dogfight", attack_type = "dogfight",
attack_animals = true, attack_animals = true,
specific_attack = { specific_attack = {
"mobs_mc:cod", "extra_mobs_cod",
"mobs_mc:glow_squid", "extra_mobs_glow_squid",
"mobs_mc:salmon", "extra_mobs_salmon",
"mobs_mc:tropical_fish", "extra_mobs_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

@ -156,37 +156,15 @@ mcl_mobs.register_mob("mobs_mc:rover", {
-- RAIN DAMAGE / EVASIVE WARP BEHAVIOUR HERE. -- RAIN DAMAGE / EVASIVE WARP BEHAVIOUR HERE.
local enderpos = self.object:get_pos() local enderpos = self.object:get_pos()
local dim = mcl_worlds.pos_to_dimension(enderpos) local dim = mcl_worlds.pos_to_dimension(enderpos)
if dim == "overworld" then if dim == "overworld" and mcl_burning.is_affected_by_rain(self.object) then
if mcl_weather.state == "rain" or mcl_weather.state == "lightning" then self.state = ""
local damage = true --rain hurts enderman
local enderpos = self.object:get_pos() self.object:punch(self.object, 1.0, {
enderpos.y = enderpos.y+2.89 full_punch_interval=1.0,
local height = {x=enderpos.x, y=enderpos.y+512,z=enderpos.z} damage_groups={fleshy=self._damage},
local ray = minetest.raycast(enderpos, height, true) }, nil)
-- Check for blocks above enderman. --randomly teleport hopefully under something.
for pointed_thing in ray do self:teleport(nil)
if pointed_thing.type == "node" then
local nn = minetest.get_node(minetest.get_pointed_thing_position(pointed_thing)).name
local def = minetest.registered_nodes[nn]
if (not def) or def.walkable then
-- There's a node in the way. Delete arrow without damage
damage = false
break
end
end
end
if damage == true then
self.state = ""
--rain hurts enderman
self.object:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=self._damage},
}, nil)
--randomly teleport hopefully under something.
self:teleport(nil)
end
end
end end
-- AGRESSIVELY WARP/CHASE PLAYER BEHAVIOUR HERE. -- AGRESSIVELY WARP/CHASE PLAYER BEHAVIOUR HERE.

View File

@ -157,7 +157,6 @@ 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,7 +2,6 @@
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 }
@ -191,8 +190,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.max(minval, current_val) current_val = math.min(minval, current_val)
current_val = math.min(maxval, current_val) current_val = math.max(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
@ -200,7 +199,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 = 1.0 - (scaled_value - index1) local frac1 = 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)
@ -208,32 +207,11 @@ 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
local res = { return {
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,21 +40,18 @@ 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.5) local day_color = mcl_weather.skycolor.get_sky_layer_color(0.15)
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 or "#7BA4FF", day_sky = day_color,
day_horizon = day_color or "#C0D8FF", day_horizon = day_color,
dawn_sky = dawn_color or "7BA4FF", dawn_sky = dawn_color,
dawn_horizon = dawn_color or "#C0D8FF", dawn_horizon = dawn_color,
night_sky = night_color or "000000", night_sky = night_color,
night_horizon = night_color or "4A6790", night_horizon = night_color,
fog_sun_tint = "#ff5f33",
fog_moon_tint = nil,
fog_tint_type = "custom",
}, },
clouds = true, clouds = true,
} }
@ -78,15 +75,18 @@ 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)
table.update(sky_data.sky.sky_color,{ sky_data.sky = {
day_sky = day_color or "#7BA4FF", type = "regular",
day_horizon = day_color or "#C0D8FF", sky_color = {
dawn_sky = dawn_color or "7BA4FF", day_sky = day_color,
dawn_horizon = dawn_color or "#C0D8FF", day_horizon = day_color,
night_sky = night_color or "000000", dawn_sky = dawn_color,
night_horizon = night_color or "4A6790", dawn_horizon = dawn_color,
fog_tint_type = "default", night_sky = night_color,
}) 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,8 +164,7 @@ 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 = { sky_data.sky = { type = "plain",
type = "plain",
base_color = "#000000", base_color = "#000000",
clouds = false, clouds = false,
} }

View File

@ -75,15 +75,13 @@ function mcl_weather.has_snow(pos)
end end
function mcl_weather.snow.set_sky_box() function mcl_weather.snow.set_sky_box()
if mcl_weather.skycolor.current_layer_name() ~= "weather-pack-snow-sky" then mcl_weather.skycolor.add_layer(
mcl_weather.skycolor.add_layer( "weather-pack-snow-sky",
"weather-pack-snow-sky", {{r=0, g=0, b=0},
{{r=0, g=0, b=0}, {r=85, g=86, b=86},
{r=85, g=86, b=86}, {r=135, g=135, b=135},
{r=135, g=135, b=135}, {r=85, g=86, b=86},
{r=85, g=86, b=86}, {r=0, g=0, b=0}})
{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,15 +23,13 @@ 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
if mcl_weather.skycolor.current_layer_name() ~= "weather-pack-thunder-sky" then mcl_weather.skycolor.add_layer("weather-pack-thunder-sky", {
mcl_weather.skycolor.add_layer("weather-pack-thunder-sky", { {r=0, g=0, b=0},
{r=0, g=0, b=0}, {r=40, g=40, b=40},
{r=40, g=40, b=40}, {r=85, g=86, b=86},
{r=85, g=86, b=86}, {r=40, g=40, b=40},
{r=40, g=40, b=40}, {r=0, g=0, b=0},
{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,6 +5,9 @@
--- 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"
@ -13,7 +16,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) local pr = PseudoRandom((os.time() + 15766) * 12) -- switched from math.random() to PseudoRandom because the random wasn't very random.
local on_rotate local on_rotate
if minetest.get_modpath("screwdriver") then if minetest.get_modpath("screwdriver") then
@ -28,7 +31,33 @@ 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",
@ -57,6 +86,7 @@ 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
@ -211,6 +241,9 @@ 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,6 +9,8 @@ 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

@ -7,6 +7,8 @@
-- 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,6 +5,8 @@
--- 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