forked from MineClone5/MineClone5
Lava produce sparks
This commit is contained in:
parent
d0fcab11e9
commit
f0b8e8ea11
|
@ -21,6 +21,14 @@ MIT License.
|
|||
The textures are taken from the Minecraft resource pack “Faithful 1.11” by Vattic and
|
||||
xMrVizzy and contributers.
|
||||
|
||||
|
||||
CC BY-SA 4.0
|
||||
|
||||
mcl_core_lava_spark.png is based on the Pixel Perfection resource pack for Minecraft 1.11,
|
||||
authored by XSSheep.
|
||||
Source: <https://www.planetminecraft.com/texture_pack/131pixel-perfection/>
|
||||
License: [CC BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/)
|
||||
|
||||
Sounds
|
||||
======
|
||||
All sounds included in this mod are under the MIT License.
|
||||
|
|
|
@ -54,6 +54,95 @@ minetest.register_abm({
|
|||
end,
|
||||
})
|
||||
|
||||
-- Production of sparks from lava
|
||||
minetest.register_abm({
|
||||
label = "Lava produce sparks",
|
||||
nodenames = {"group:lava"},
|
||||
neighbors = {"air"},
|
||||
interval = 1,
|
||||
chance = 100,
|
||||
action = function(pos, node)
|
||||
local above = minetest.get_node(vector.new(pos.x, pos.y + 1, pos.z))
|
||||
if above.name ~= "air" then return end
|
||||
|
||||
local pos_addend = vector.new(
|
||||
(math.random() - 0.5) * 0.8,
|
||||
(math.random() - 0.5) * 0.8,
|
||||
(math.random() - 0.5) * 0.8
|
||||
)
|
||||
local spark_pos = vector.add(pos, pos_addend)
|
||||
local spark = minetest.add_entity(spark_pos, "mcl_core:lava_spark")
|
||||
if not spark then return end
|
||||
|
||||
local velocity = vector.new(
|
||||
(math.random() - 0.5) * 3,
|
||||
(math.random() + 2) * 2,
|
||||
(math.random() - 0.5) * 3
|
||||
)
|
||||
spark:set_velocity(velocity)
|
||||
|
||||
spark:set_acceleration(vector.new(0, -9, 0))
|
||||
|
||||
-- Set a random size
|
||||
local size = 0.2 + math.random() * 0.2
|
||||
local props = spark:get_properties()
|
||||
if not props then return end
|
||||
props.visual_size = vector.new(size, size, size)
|
||||
spark:set_properties(props)
|
||||
|
||||
local luaentity = spark:get_luaentity()
|
||||
if not luaentity then return end
|
||||
luaentity._life_timer = 0.4 + math.random()
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_entity("mcl_core:lava_spark", {
|
||||
physical = true,
|
||||
visual = "sprite",
|
||||
collide_with_objects = true,
|
||||
textures = {"mcl_core_lava_spark.png"},
|
||||
glow = 10,
|
||||
static_save = false,
|
||||
_smoke_timer = 0.1,
|
||||
_life_timer = 1,
|
||||
on_step = function(self, dtime)
|
||||
if not self or not self.object then return end
|
||||
|
||||
self._life_timer = self._life_timer - dtime
|
||||
if self._life_timer <= 0 then
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
self._smoke_timer = self._smoke_timer - dtime
|
||||
if self._smoke_timer > 0 then return end
|
||||
self._smoke_timer = math.random() * 0.4
|
||||
|
||||
local pos = self.object:get_pos()
|
||||
|
||||
-- Add smoke
|
||||
minetest.add_particlespawner({
|
||||
amount = 3,
|
||||
time = 0.001,
|
||||
minpos = pos,
|
||||
maxpos = pos,
|
||||
minvel = vector.new(-0.1, 1, -0.1),
|
||||
maxvel = vector.new(0.1, 1.5, 0.1),
|
||||
minexptime = 0.1,
|
||||
maxexptime = 0.6,
|
||||
minsize = 0.5,
|
||||
maxsize = 1.5,
|
||||
texture = "mcl_particles_smoke_anim.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 8,
|
||||
aspect_h = 8,
|
||||
}
|
||||
})
|
||||
end
|
||||
})
|
||||
|
||||
--
|
||||
-- Papyrus and cactus growing
|
||||
--
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
Loading…
Reference in New Issue