From cfcf22f0de1aeb85b02f8af225bb3d0f6221524d Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 22 May 2017 22:04:42 +0200 Subject: [PATCH] Add bubble particles for players being underwater --- mods/CORE/mcl_particles/description.txt | 1 + mods/CORE/mcl_particles/init.lua | 0 mods/CORE/mcl_particles/mod.conf | 1 + .../textures/mcl_particles_bubble.png | Bin 0 -> 165 bytes mods/PLAYER/mcl_player/depends.txt | 1 + mods/PLAYER/mcl_player/init.lua | 28 ++++++++++++++++++ 6 files changed, 31 insertions(+) create mode 100644 mods/CORE/mcl_particles/description.txt create mode 100644 mods/CORE/mcl_particles/init.lua create mode 100644 mods/CORE/mcl_particles/mod.conf create mode 100644 mods/CORE/mcl_particles/textures/mcl_particles_bubble.png create mode 100644 mods/PLAYER/mcl_player/depends.txt diff --git a/mods/CORE/mcl_particles/description.txt b/mods/CORE/mcl_particles/description.txt new file mode 100644 index 000000000..62d5cd61a --- /dev/null +++ b/mods/CORE/mcl_particles/description.txt @@ -0,0 +1 @@ +Contains particle images of MineClone 2. No code. diff --git a/mods/CORE/mcl_particles/init.lua b/mods/CORE/mcl_particles/init.lua new file mode 100644 index 000000000..e69de29bb diff --git a/mods/CORE/mcl_particles/mod.conf b/mods/CORE/mcl_particles/mod.conf new file mode 100644 index 000000000..f7be80395 --- /dev/null +++ b/mods/CORE/mcl_particles/mod.conf @@ -0,0 +1 @@ +name = mcl_particles diff --git a/mods/CORE/mcl_particles/textures/mcl_particles_bubble.png b/mods/CORE/mcl_particles/textures/mcl_particles_bubble.png new file mode 100644 index 0000000000000000000000000000000000000000..063489d3799ad60f925d3d6c193ce470de347e6d GIT binary patch literal 165 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|Y$ZW{!9W@a@|Lkr1X59+E{-7; zj7KMI6l^fyVYcNy!*$YWgRc<_H-~JdhKQ-&r|(n!?^}dzi2WhWw(~}Qz}`N~t%q6p z9bz9`Z@#3!wD+5%k47wO+bph4`BxkF1l5bk@P7Ftv)<<;(}u+f%RF{FVdQ I&MBb@0Ic~megFUf literal 0 HcmV?d00001 diff --git a/mods/PLAYER/mcl_player/depends.txt b/mods/PLAYER/mcl_player/depends.txt new file mode 100644 index 000000000..746a634e0 --- /dev/null +++ b/mods/PLAYER/mcl_player/depends.txt @@ -0,0 +1 @@ +mcl_particles diff --git a/mods/PLAYER/mcl_player/init.lua b/mods/PLAYER/mcl_player/init.lua index bef53c087..567216cb7 100644 --- a/mods/PLAYER/mcl_player/init.lua +++ b/mods/PLAYER/mcl_player/init.lua @@ -201,6 +201,34 @@ minetest.register_globalstep(function(dtime) else player_set_animation(player, "stand", animation_speed_mod) end + + -- Spawn bubble particles when underwater + + local pos = player:getpos() + local head_pos = { + x = math.floor(pos.x+0.5), + y = math.ceil(pos.y+1.0), + z = math.floor(pos.z+0.5) + } + + if minetest.get_item_group(minetest.get_node(head_pos).name, "water") ~= 0 then + minetest.add_particlespawner({ + amount = 2, + time = 0.15, + minpos = { x = -0.25, y = 0.3, z = -0.25 }, + maxpos = { x = 0.25, y = 0.7, z = 0.75 }, + attached = player, + minvel = {x = -0.2, y = 0, z = -0.2}, + maxvel = {x = 0.5, y = 0, z = 0.5}, + minacc = {x = -0.4, y = 4, z = -0.4}, + maxacc = {x = 0.5, y = 1, z = 0.5}, + minexptime = 0.3, + maxexptime = 0.8, + minsize = 0.7, + maxsize = 2.4, + texture = "mcl_particles_bubble.png" + }) + end end end end)