From 113d9abbb528a452690b7c62f30be692a427ef8e Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 20 Aug 2024 06:38:55 +0200 Subject: [PATCH] Make occurences in code that obv want floating p results use mcl_util.float_random --- mods/ENTITIES/mcl_charges/init.lua | 2 +- mods/ENTITIES/mcl_charges/mod.conf | 5 ++--- mods/ENTITIES/mcl_mobs/movement.lua | 4 ++-- mods/ENTITIES/mobs_mc/blaze.lua | 21 ++++++++++++--------- mods/ITEMS/mcl_core/functions.lua | 2 +- mods/ITEMS/mcl_core/mod.conf | 3 +-- mods/ITEMS/mcl_mobspawners/init.lua | 2 +- mods/ITEMS/mcl_mobspawners/mod.conf | 2 +- mods/PLAYER/playerphysics/elytra.lua | 4 ++-- mods/PLAYER/playerphysics/mod.conf | 2 +- 10 files changed, 24 insertions(+), 23 deletions(-) diff --git a/mods/ENTITIES/mcl_charges/init.lua b/mods/ENTITIES/mcl_charges/init.lua index be51c33a9..0d9b5637b 100644 --- a/mods/ENTITIES/mcl_charges/init.lua +++ b/mods/ENTITIES/mcl_charges/init.lua @@ -92,7 +92,7 @@ function mcl_charges.wind_burst(pos, radius) local dist = math.max(1, vector.distance(pos, obj_pos)) if obj:is_player() then - obj:add_velocity(vector.multiply(vector.normalize(vector.subtract(obj_pos, pos)), math.random(1.8, 2.0) / dist * RADIUS)) + obj:add_velocity(vector.multiply(vector.normalize(vector.subtract(obj_pos, pos)), mcl_util.float_random(1.8, 2.0) / dist * RADIUS)) else local luaobj = obj:get_luaentity() if luaobj then diff --git a/mods/ENTITIES/mcl_charges/mod.conf b/mods/ENTITIES/mcl_charges/mod.conf index 6a65be99f..e2628f98c 100644 --- a/mods/ENTITIES/mcl_charges/mod.conf +++ b/mods/ENTITIES/mcl_charges/mod.conf @@ -1,5 +1,4 @@ name = mcl_charges description = Adds Code to easily register throwable charges like the wind charge -depends = mcl_mobs, mcl_doors, mcl_fences -optional_depends = mobs_mc -title = MCL Charges \ No newline at end of file +depends = mcl_util, mcl_mobs, mcl_doors, mcl_fences, mobs_mc +title = MCL Charges diff --git a/mods/ENTITIES/mcl_mobs/movement.lua b/mods/ENTITIES/mcl_mobs/movement.lua index 762633663..2e23d26bf 100644 --- a/mods/ENTITIES/mcl_mobs/movement.lua +++ b/mods/ENTITIES/mcl_mobs/movement.lua @@ -899,7 +899,7 @@ function mob_class:do_states_stand() yaw = yaw + math.pi end else - yaw = yaw + math.random(-YAW_RAD, YAW_RAD) + yaw = yaw + mcl_util.float_random(-YAW_RAD, YAW_RAD) end self:set_yaw(yaw, 8) --[[ else @@ -1161,7 +1161,7 @@ function mob_class:turn_away(delay) end local yaw = self.object:get_yaw() or 0 - local turn = math.random(YAW_RAD / 2, YAW_RAD) + local turn = mcl_util.float_random(YAW_RAD / 2, YAW_RAD) if math.random() < 0.5 then turn = -turn end diff --git a/mods/ENTITIES/mobs_mc/blaze.lua b/mods/ENTITIES/mobs_mc/blaze.lua index eca8a1233..f22d850de 100644 --- a/mods/ENTITIES/mobs_mc/blaze.lua +++ b/mods/ENTITIES/mobs_mc/blaze.lua @@ -97,11 +97,14 @@ mcl_mobs.register_mob("mobs_mc:blaze", { mcl_burning.set_on_fire(self.attack, 5) end local pos = self.object:get_pos() + + if not self:check_timer("blaze_particles", mcl_util.float_random(0.5, 2)) then return end + minetest.add_particle({ - pos = {x=pos.x+math.random(-0.7,0.7)*math.random()/2,y=pos.y+math.random(0.7,1.2),z=pos.z+math.random(-0.7,0.7)*math.random()/2}, - velocity = {x=0, y=math.random(1,1), z=0}, + pos = {x = pos.x+mcl_util.float_random(-0.7,0.7) * math.random()/2, y = pos.y+mcl_util.float_random(0.7,1.2), z = pos.z+mcl_util.float_random(-0.7,0.7) * math.random()/2}, + velocity = {x=0, y = mcl_util.float_random(0.5, 2), z=0}, expirationtime = math.random(), - size = math.random(1, 4), + size = mcl_util.float_random(1, 4), collisiondetection = true, vertical = false, texture = "mcl_particles_smoke_anim.png^[colorize:#2c2c2c:255", @@ -113,10 +116,10 @@ mcl_mobs.register_mob("mobs_mc:blaze", { }, }) minetest.add_particle({ - pos = {x=pos.x+math.random(-0.7,0.7)*math.random()/2,y=pos.y+math.random(0.7,1.2),z=pos.z+math.random(-0.7,0.7)*math.random()/2}, - velocity = {x=0, y=math.random(1,1), z=0}, + pos = {x = pos.x+mcl_util.float_random(-0.7,0.7)* math.random()/2, y = pos.y+mcl_util.float_random(0.7,1.2), z = pos.z+mcl_util.float_random(-0.7,0.7) * math.random()/2}, + velocity = {x=0, y = mcl_util.float_random(0.5, 2), z=0}, expirationtime = math.random(), - size = math.random(1, 4), + size = mcl_util.float_random(1, 4), collisiondetection = true, vertical = false, texture = "mcl_particles_smoke_anim.png^[colorize:#424242:255", @@ -128,10 +131,10 @@ mcl_mobs.register_mob("mobs_mc:blaze", { }, }) minetest.add_particle({ - pos = {x=pos.x+math.random(-0.7,0.7)*math.random()/2,y=pos.y+math.random(0.7,1.2),z=pos.z+math.random(-0.7,0.7)*math.random()/2}, - velocity = {x=0, y=math.random(1,1), z=0}, + pos = {x = pos.x+mcl_util.float_random(-0.7,0.7)*math.random()/2, y = pos.y+mcl_util.float_random(0.7,1.2), z = pos.z+mcl_util.float_random(-0.7,0.7)*math.random()/2}, + velocity = {x=0, y = mcl_util.float_random(0.5,2), z=0}, expirationtime = math.random(), - size = math.random(1, 4), + size = mcl_util.float_random(1, 4), collisiondetection = true, vertical = false, texture = "mcl_particles_smoke_anim.png^[colorize:#0f0f0f:255", diff --git a/mods/ITEMS/mcl_core/functions.lua b/mods/ITEMS/mcl_core/functions.lua index b90f5e0d7..64d59b223 100644 --- a/mods/ITEMS/mcl_core/functions.lua +++ b/mods/ITEMS/mcl_core/functions.lua @@ -208,7 +208,7 @@ minetest.register_abm({ while minetest.get_node(vector.new(pos.x, posy, pos.z)).name == "mcl_core:cactus" do local pos = vector.new(pos.x, posy, pos.z) minetest.remove_node(pos) - minetest.add_item(vector.offset(pos, math.random(-0.5, 0.5), 0, math.random(-0.5, 0.5)), "mcl_core:cactus") + minetest.add_item(vector.offset(pos, mcl_util.float_random(-0.5, 0.5), 0, mcl_util.float_random(-0.5, 0.5)), "mcl_core:cactus") posy = posy + 1 end break diff --git a/mods/ITEMS/mcl_core/mod.conf b/mods/ITEMS/mcl_core/mod.conf index 18e93abf2..e17e7720c 100644 --- a/mods/ITEMS/mcl_core/mod.conf +++ b/mods/ITEMS/mcl_core/mod.conf @@ -1,4 +1,3 @@ name = mcl_core description = Core items of MineClone 2: Basic biome blocks (dirt, sand, stones, etc.), derived items, glass, sugar cane, cactus, barrier, mining tools, hand, craftitems, and misc. items which don't really fit anywhere else. -depends = mcl_autogroup, mcl_init, mcl_sounds, mcl_util, mcl_worlds, doc_items, mcl_enchanting, mcl_colors, mcl_stairs, mcl_fences, mcl_flowerpots, mcl_trees, mcl_dyes, mcl_player -optional_depends = doc +depends = mcl_autogroup, mcl_init, mcl_sounds, mcl_util, mcl_worlds, doc_items, mcl_enchanting, mcl_colors, mcl_stairs, mcl_fences, mcl_flowerpots, mcl_trees, mcl_dyes, mcl_player, doc diff --git a/mods/ITEMS/mcl_mobspawners/init.lua b/mods/ITEMS/mcl_mobspawners/init.lua index 2b412bf03..10d6eb9d7 100644 --- a/mods/ITEMS/mcl_mobspawners/init.lua +++ b/mods/ITEMS/mcl_mobspawners/init.lua @@ -243,7 +243,7 @@ local function spawn_mobs(pos) end -- Spawn attempt done. Next spawn attempt much later - timer:start(math.random(10, 39.95)) + timer:start(mcl_util.float_random(10, 39.95)) end diff --git a/mods/ITEMS/mcl_mobspawners/mod.conf b/mods/ITEMS/mcl_mobspawners/mod.conf index 1759e3408..2ab2db509 100644 --- a/mods/ITEMS/mcl_mobspawners/mod.conf +++ b/mods/ITEMS/mcl_mobspawners/mod.conf @@ -1,2 +1,2 @@ name = mcl_mobspawners -depends = mcl_sounds, mcl_mobs +depends = mcl_sounds, mcl_mobs, mcl_util diff --git a/mods/PLAYER/playerphysics/elytra.lua b/mods/PLAYER/playerphysics/elytra.lua index bf1072d71..3c22261a3 100644 --- a/mods/PLAYER/playerphysics/elytra.lua +++ b/mods/PLAYER/playerphysics/elytra.lua @@ -76,8 +76,8 @@ mcl_player.register_globalstep(function(player, dtime) pos = fly_pos, velocity = {x = 0, y = 0, z = 0}, acceleration = {x = 0, y = 0, z = 0}, - expirationtime = math.random(0.3, 0.5), - size = math.random(1, 2), + expirationtime = mcl_util.float_random(0.3, 0.5), + size = mcl_util.float_random(1, 2), collisiondetection = false, vertical = false, texture = "mcl_particles_bonemeal.png^[colorize:#bc7a57:127", diff --git a/mods/PLAYER/playerphysics/mod.conf b/mods/PLAYER/playerphysics/mod.conf index d24943bf5..cdf424a58 100644 --- a/mods/PLAYER/playerphysics/mod.conf +++ b/mods/PLAYER/playerphysics/mod.conf @@ -2,4 +2,4 @@ name = playerphysics author = Wuzzy title = Player Physics API description = This mod makes it possible for multiple mods to modify player physics (speed, jumping strength, gravity) without conflict. -depends = mcl_player +depends = mcl_player, mcl_util