]> git.lizzy.rs Git - crafter_client.git/commitdiff
Add in nether weather
authoroilboi <47129783+oilboi@users.noreply.github.com>
Sat, 18 Apr 2020 11:23:05 +0000 (07:23 -0400)
committeroilboi <47129783+oilboi@users.noreply.github.com>
Sat, 18 Apr 2020 11:23:05 +0000 (07:23 -0400)
weather_handling.lua

index 5f39c628df70fbefcae698e6055142c033258b43..6d8600ccea9b86e31058e8385dad8dceebf94789 100644 (file)
@@ -62,6 +62,58 @@ local spawn_snow = function(player)
        end
 end
 
+local spawn_ichor = function(player)
+       local pos = player:get_pos()
+       local radius = 10
+       local particle_table = {}
+       
+       local area = vector.new(10,10,10)
+       
+       local min = vector.subtract(pos, area)
+       local max = vector.add(pos, area)
+       
+       
+       local area_index = minetest.find_nodes_in_area_under_air(min, max, all_nodes)
+       
+       local spawn_table = {}
+       --find the highest y value
+       for _,index in pairs(area_index) do
+               if not spawn_table[index.x] then spawn_table[index.x] = {} end
+               if not spawn_table[index.x][index.z] then
+                       spawn_table[index.x][index.z] = index.y
+               elseif spawn_table[index.x][index.z] < index.y then
+                       spawn_table[index.x][index.z] = index.y
+               end
+       end
+       
+       for x,x_index in pairs(spawn_table) do
+               for z,y in pairs(x_index) do
+                       if minetest.get_node_or_nil(vector.new(x,y+1,z)) ~= nil then
+                               local pos = vector.new(x,y+1,z)
+                               minetest.add_particlespawner({
+                                       amount = 1,
+                                       time = 0.5,
+                                       minpos = vector.new(x-0.5,y,z-0.5),
+                                       maxpos = vector.new(x+0.5,y+20,z+0.5),
+                                       minvel = {x=-0.2, y=0.2, z=-0.2},
+                                       maxvel = {x=0.2, y=0.5, z=0.2},
+                                       minacc = {x=0, y=0, z=0},
+                                       maxacc = {x=0, y=0, z=0},
+                                       minexptime = 1,
+                                       maxexptime = 1,
+                                       minsize = 1,
+                                       maxsize = 1,
+                                       collisiondetection = true,
+                                       collision_removal = true,
+                                       object_collision = false,
+                                       texture = "ichor_"..math.random(1,2)..".png",
+                                       playername = player:get_name(),
+                               })
+                       end
+               end
+       end
+end
+
 local spawn_rain = function(player)
        local pos = player:get_pos()
        local radius = 10
@@ -119,17 +171,33 @@ local spawn_rain = function(player)
 end
 
 --client runs through spawning weather particles
+local player_pos
 minetest.register_globalstep(function(dtime)
+       player_pos = minetest.localplayer:get_pos()
        if do_effects then
                if snow or rain then
                        weather_update_timer = weather_update_timer + dtime
                        if weather_update_timer >= 0.5 then
                                weather_update_timer = 0
-                               local player = minetest.localplayer
-                               if snow == true then
-                                       spawn_snow(minetest.localplayer)
-                               elseif rain == true then
-                                       spawn_rain(minetest.localplayer)
+                               --do normal weather
+                               if player_pos.y > -10033 then
+                                       if snow == true then
+                                               spawn_snow(minetest.localplayer)
+                                       elseif rain == true then
+                                               spawn_rain(minetest.localplayer)
+                                       end
+                               --rain blood upwards in the nether
+                               else
+                                       print("ichor")
+                                       if snow == true or rain == true then
+                                               spawn_ichor(minetest.localplayer)
+                                       end
+                               
+                                       --stop the rain sound effect
+                                       if rain_sound_handle then
+                                               minetest.sound_fade(rain_sound_handle, -0.5, 0)
+                                               rain_sound_handle = nil
+                                       end
                                end
                        end
                end