Skip to content

Commit 5a4818a

Browse files
committed
Set blend = "clip" on spawned particles
1 parent 692ac2d commit 5a4818a

File tree

2 files changed

+39
-21
lines changed

2 files changed

+39
-21
lines changed

mods/default/item_entity.lua

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,28 @@ if not builtin_item or type(builtin_item.set_item) ~= "function" or type(builtin
99
return
1010
end
1111

12+
local smoke_particles = {
13+
amount = 3,
14+
time = 0.1,
15+
minpos = vector.new(-0.1, -0.1, -0.1),
16+
maxpos = vector.new(0.1, 0.1, 0.1),
17+
minvel = vector.new(0, 2.5, 0),
18+
maxvel = vector.new(0, 2.5, 0),
19+
minacc = vector.new(-0.15, -0.02, -0.15),
20+
maxacc = vector.new(0.15, -0.01, 0.15),
21+
minexptime = 4,
22+
maxexptime = 6,
23+
minsize = 5,
24+
maxsize = 5,
25+
collisiondetection = true,
26+
texture = {
27+
name = "default_item_smoke.png"
28+
}
29+
}
30+
if minetest.features.particle_blend_clip then
31+
smoke_particles.texture.blend = "clip"
32+
end
33+
1234
local item = {
1335
set_item = function(self, itemstring, ...)
1436
builtin_item.set_item(self, itemstring, ...)
@@ -29,22 +51,10 @@ local item = {
2951
gain = 1.0,
3052
max_hear_distance = 8,
3153
}, true)
32-
minetest.add_particlespawner({
33-
amount = 3,
34-
time = 0.1,
35-
minpos = {x = p.x - 0.1, y = p.y + 0.1, z = p.z - 0.1 },
36-
maxpos = {x = p.x + 0.1, y = p.y + 0.2, z = p.z + 0.1 },
37-
minvel = {x = 0, y = 2.5, z = 0},
38-
maxvel = {x = 0, y = 2.5, z = 0},
39-
minacc = {x = -0.15, y = -0.02, z = -0.15},
40-
maxacc = {x = 0.15, y = -0.01, z = 0.15},
41-
minexptime = 4,
42-
maxexptime = 6,
43-
minsize = 5,
44-
maxsize = 5,
45-
collisiondetection = true,
46-
texture = "default_item_smoke.png"
47-
})
54+
local ps = table.copy(smoke_particles)
55+
ps.minpos = vector.add(ps.minpos, p)
56+
ps.maxpos = vector.add(ps.maxpos, p)
57+
minetest.add_particlespawner(ps)
4858
end,
4959

5060
on_step = function(self, dtime, ...)

mods/tnt/init.lua

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ minetest.register_on_mods_loaded(function()
2727
end
2828
end)
2929

30+
local function particle_texture(name)
31+
local ret = {name = name}
32+
if minetest.features.particle_blend_clip then
33+
ret.blend = "clip"
34+
end
35+
return ret
36+
end
37+
3038
local function rand_pos(center, pos, radius)
3139
local def
3240
local reg_nodes = minetest.registered_nodes
@@ -211,7 +219,7 @@ local function add_effects(pos, radius, drops)
211219
size = radius * 10,
212220
collisiondetection = false,
213221
vertical = false,
214-
texture = "tnt_boom.png",
222+
texture = particle_texture("tnt_boom.png"),
215223
glow = 15,
216224
})
217225
minetest.add_particlespawner({
@@ -227,12 +235,12 @@ local function add_effects(pos, radius, drops)
227235
maxexptime = 2.5,
228236
minsize = radius * 3,
229237
maxsize = radius * 5,
230-
texture = "tnt_smoke.png",
238+
texture = particle_texture("tnt_smoke.png"),
231239
})
232240

233-
-- we just dropped some items. Look at the items entities and pick
234-
-- one of them to use as texture
235-
local texture = "tnt_blast.png" --fallback texture
241+
-- we just dropped some items. Look at the items and pick
242+
-- one of them to use as texture.
243+
local texture = "tnt_blast.png" -- fallback
236244
local node
237245
local most = 0
238246
for name, stack in pairs(drops) do

0 commit comments

Comments
 (0)