From 902393926f035cab026b4b181503b878f02fec9e Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Sun, 1 Dec 2024 03:05:28 +0100 Subject: [PATCH 01/25] Initial firework projectile --- mods/ITEMS/mcl_fireworks/mod.conf | 3 +- mods/ITEMS/mcl_fireworks/register.lua | 124 ++++++++++++++++++++++++++ 2 files changed, 126 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_fireworks/mod.conf b/mods/ITEMS/mcl_fireworks/mod.conf index cf9e34e91..6c0971176 100644 --- a/mods/ITEMS/mcl_fireworks/mod.conf +++ b/mods/ITEMS/mcl_fireworks/mod.conf @@ -1,2 +1,3 @@ name = mcl_fireworks -description = Adds fun fireworks to the game which players can use. \ No newline at end of file +description = Adds fun fireworks to the game which players can use. +depends = vl_projectile diff --git a/mods/ITEMS/mcl_fireworks/register.lua b/mods/ITEMS/mcl_fireworks/register.lua index 23066b663..0ccf5ab32 100644 --- a/mods/ITEMS/mcl_fireworks/register.lua +++ b/mods/ITEMS/mcl_fireworks/register.lua @@ -3,7 +3,123 @@ local S = minetest.get_translator(minetest.get_current_modname()) local tt_help = S("Flight Duration:") local description = S("Firework Rocket") +local function explode(self, pos) + -- temp code + mcl_mobs.mob_class.boom(self, pos, 1) +end + +local firework_entity = { + physical = true, + pointable = false, + visual = "mesh", + mesh = "mcl_bows_arrow.obj", + visual_size = {x=-1, y=1}, + textures = {"mcl_fireworks_rocket.png"}, + collisionbox = {-0.19, -0.125, -0.19, 0.19, 0.125, 0.19}, + collide_with_objects = false, + liquid_drag = true, + _fire_damage_resistant = true, + + _save_fields = { + "last_pos", "startpos", "damage", "is_critical", "time_in_air", "vl_projectile", "arrow_item"--[[???]], "itemstring" + }, + + _damage=1, -- Damage on impact + _is_critical=false, -- Whether this arrow would deal critical damage + _blocked = false, + _viscosity=0, -- Viscosity of node the arrow is currently in + _deflection_cooloff=0, -- Cooloff timer after an arrow deflection, to prevent many deflections in quick succession + + _vl_projectile = { + ignore_gravity = true, + survive_collision = true, + damages_players = true, + maximum_time = 60, + damage_groups = function(self) + return { fleshy = self.object:get_velocity() } + end, + tracer_texture = "mobs_mc_arrow_particle.png", + behaviors = { + vl_projectile.burns, + vl_projectile.has_tracer, + + function(self, dtime) + self.object:add_velocity(vector.new(0, dtime, 0)) + end, + + vl_projectile.collides_with_solids, + vl_projectile.raycast_collides_with_entities, + }, + allow_punching = function(self, entity_def, projectile_def, object) + local lua = object:get_luaentity() + if lua and lua.name == "mobs_mc:rover" then return false end + --if (self.object:get_velocity() + object:get_velocity()).length() < 5 then return end + + minetest.log("allow punching") + + return true + end, + on_collide_with_entity = function(self, pos, obj) + if self.object == obj then return end + --if (self.object:get_velocity() + obj:get_velocity()).lenght() < 5 then return end + + minetest.log("entity collision") + + explode(self, pos) + + mcl_util.remove_entity(self) + end, + on_collide_with_solid = function(self, pos, node) + explode(self, pos) + + minetest.log("solid collision") + + mcl_util.remove_entity(self) + end + }, + + get_staticdata = function(self) + local out = {} + local save_fields = self._save_fields + for i = 1,#save_fields do + local field = save_fields[i] + out[field] = self["_"..field] + end + + -- Preserve entity properties + out.properties = self.object:get_properties() + + return minetest.serialize(out) + end, + on_activate = function(self, staticdata, dtime_s) + self.object:set_armor_groups({ immortal = 1 }) + + self._time_in_air = 1.0 + local data = minetest.deserialize(staticdata) + if not data then return end + + -- Restore entity properties + if data.properties then + self.object:set_properties(data.properties) + data.properties = nil + end + + -- Restore arrow state + local save_fields = self._save_fields + for i = 1,#save_fields do + local field = save_fields[i] + self["_"..field] = data[field] + end + + if not self._vl_projectile then + self._vl_projetile = {} + end + end, +} + local function register_rocket(n, duration, force) + def = table.copy(firework_entity) + vl_projectile.register("mcl_fireworks:rocket_" .. n, def) minetest.register_craftitem("mcl_fireworks:rocket_" .. n, { description = description, _tt_help = tt_help .. " " .. duration, @@ -20,6 +136,14 @@ local function register_rocket(n, duration, force) end return itemstack end, + on_place = function(itemstack, user, pointed_thing) + local pos = pointed_thing.above + pos.y = pos.y + 1 + vl_projectile.create("mcl_fireworks:rocket_" .. n, { + pos=pos, + velocity=vector.new(0,1,0) + }) + end, }) end From 326ad65158a2c3830662712364bb06fa12d856c4 Mon Sep 17 00:00:00 2001 From: teknomunk Date: Sat, 30 Nov 2024 20:24:51 -0600 Subject: [PATCH 02/25] Correct damage_groups return (ObjectRef:get_velocity() returns a vector not the required number) --- mods/ITEMS/mcl_fireworks/register.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_fireworks/register.lua b/mods/ITEMS/mcl_fireworks/register.lua index 0ccf5ab32..e8c6badc7 100644 --- a/mods/ITEMS/mcl_fireworks/register.lua +++ b/mods/ITEMS/mcl_fireworks/register.lua @@ -36,7 +36,7 @@ local firework_entity = { damages_players = true, maximum_time = 60, damage_groups = function(self) - return { fleshy = self.object:get_velocity() } + return { fleshy = vector.length(self.object:get_velocity()) } end, tracer_texture = "mobs_mc_arrow_particle.png", behaviors = { From 00ef72c6467f9862315dffd3f02636f8df0d2431 Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Sat, 14 Dec 2024 01:11:30 +0100 Subject: [PATCH 03/25] Graphical changes and preparations - added mesh - added adjusted texture - marked lines in need of attention --- .../models/mcl_fireworks_rocket.obj | 30 ++++++++++++++++++ mods/ITEMS/mcl_fireworks/register.lua | 17 +++++----- textures/mcl_fireworks_entity.png | Bin 0 -> 199 bytes 3 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 mods/ITEMS/mcl_fireworks/models/mcl_fireworks_rocket.obj create mode 100644 textures/mcl_fireworks_entity.png diff --git a/mods/ITEMS/mcl_fireworks/models/mcl_fireworks_rocket.obj b/mods/ITEMS/mcl_fireworks/models/mcl_fireworks_rocket.obj new file mode 100644 index 000000000..dbda78990 --- /dev/null +++ b/mods/ITEMS/mcl_fireworks/models/mcl_fireworks_rocket.obj @@ -0,0 +1,30 @@ +# Blender 3.6.7 +# www.blender.org +o Plane +v -0.500000 1.000000 0.500000 +v 0.500000 1.000000 0.500000 +v -0.500000 1.000000 -0.500000 +v 0.500000 1.000000 -0.500000 +v -0.300517 0.000000 0.300517 +v 0.300517 0.000000 -0.300517 +v -0.300517 1.500000 0.300517 +v 0.300517 1.500000 -0.300517 +v 0.300517 0.000000 0.300517 +v -0.300517 0.000000 -0.300517 +v 0.300517 1.500000 0.300517 +v -0.300517 1.500000 -0.300517 +vn -0.0000 1.0000 -0.0000 +vn 0.7071 -0.0000 0.7071 +vn 0.7071 -0.0000 -0.7071 +vt 0.562500 0.562500 +vt 1.000000 0.562500 +vt 1.000000 1.000000 +vt 0.562500 1.000000 +vt -0.000000 0.125000 +vt 0.437500 0.125000 +vt 0.437500 0.937500 +vt -0.000000 0.937500 +s 0 +f 1/1/1 2/2/1 4/3/1 3/4/1 +f 5/5/2 6/6/2 8/7/2 7/8/2 +f 9/5/3 10/6/3 12/7/3 11/8/3 diff --git a/mods/ITEMS/mcl_fireworks/register.lua b/mods/ITEMS/mcl_fireworks/register.lua index e8c6badc7..ec83e019f 100644 --- a/mods/ITEMS/mcl_fireworks/register.lua +++ b/mods/ITEMS/mcl_fireworks/register.lua @@ -12,10 +12,11 @@ local firework_entity = { physical = true, pointable = false, visual = "mesh", - mesh = "mcl_bows_arrow.obj", - visual_size = {x=-1, y=1}, - textures = {"mcl_fireworks_rocket.png"}, - collisionbox = {-0.19, -0.125, -0.19, 0.19, 0.125, 0.19}, + visual_size = {x=1, y=2}, -- TODO adjust + mesh = "mcl_fireworks_rocket.obj", + textures = {"mcl_fireworks_entity.png"}, + backface_culling = false, + collisionbox = {-0.19, -0.125, -0.19, 0.19, 0.125, 0.19}, -- TODO verify collide_with_objects = false, liquid_drag = true, _fire_damage_resistant = true, @@ -44,7 +45,7 @@ local firework_entity = { vl_projectile.has_tracer, function(self, dtime) - self.object:add_velocity(vector.new(0, dtime, 0)) + self.object:add_velocity(vector.new(0, dtime, 0)) -- TODO timeout end, vl_projectile.collides_with_solids, @@ -119,8 +120,8 @@ local firework_entity = { local function register_rocket(n, duration, force) def = table.copy(firework_entity) - vl_projectile.register("mcl_fireworks:rocket_" .. n, def) - minetest.register_craftitem("mcl_fireworks:rocket_" .. n, { + vl_projectile.register("mcl_fireworks:rocket_" .. n, def) -- TODO one entity + minetest.register_craftitem("mcl_fireworks:rocket_" .. n, { -- TODO one item, use metadata description = description, _tt_help = tt_help .. " " .. duration, inventory_image = "mcl_fireworks_rocket.png", @@ -138,7 +139,7 @@ local function register_rocket(n, duration, force) end, on_place = function(itemstack, user, pointed_thing) local pos = pointed_thing.above - pos.y = pos.y + 1 +-- pos.y = pos.y + 1 vl_projectile.create("mcl_fireworks:rocket_" .. n, { pos=pos, velocity=vector.new(0,1,0) diff --git a/textures/mcl_fireworks_entity.png b/textures/mcl_fireworks_entity.png new file mode 100644 index 0000000000000000000000000000000000000000..bbc17db32ad3864a2b6d4af87e1a068ddb7268f4 GIT binary patch literal 199 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPHF3h)VWWl#jN7(5qF`TzgFv6ga1 zOhBQWM0?bgfQzgvIz~IcRnFkK++|=8cc(sRxtxwd!Eu4MA#firb9AJE6Fvp|el@)jL rn!60CYZ?p>^@L(gkrn+tYX6Tt3q^>bP0l+XkKu%Jcn literal 0 HcmV?d00001 From 50e54a375a63a1eeabf4cf7460d5b1192a839e94 Mon Sep 17 00:00:00 2001 From: teknomunk Date: Sat, 14 Dec 2024 19:50:36 -0600 Subject: [PATCH 04/25] Add pitch_offset to correct rocket orientation --- mods/ITEMS/mcl_fireworks/register.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/mods/ITEMS/mcl_fireworks/register.lua b/mods/ITEMS/mcl_fireworks/register.lua index ec83e019f..b7aa19c69 100644 --- a/mods/ITEMS/mcl_fireworks/register.lua +++ b/mods/ITEMS/mcl_fireworks/register.lua @@ -36,6 +36,7 @@ local firework_entity = { survive_collision = true, damages_players = true, maximum_time = 60, + pitch_offset = -math.pi / 2, damage_groups = function(self) return { fleshy = vector.length(self.object:get_velocity()) } end, From 57f743a0c5e27b0fa1c0813b1e17a614f3b79a25 Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Sun, 22 Dec 2024 02:38:10 +0100 Subject: [PATCH 05/25] Adjusted firework entity size --- mods/ITEMS/mcl_fireworks/register.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/mcl_fireworks/register.lua b/mods/ITEMS/mcl_fireworks/register.lua index b7aa19c69..3c956dbef 100644 --- a/mods/ITEMS/mcl_fireworks/register.lua +++ b/mods/ITEMS/mcl_fireworks/register.lua @@ -12,11 +12,11 @@ local firework_entity = { physical = true, pointable = false, visual = "mesh", - visual_size = {x=1, y=2}, -- TODO adjust + visual_size = {x=3, y=3}, mesh = "mcl_fireworks_rocket.obj", textures = {"mcl_fireworks_entity.png"}, backface_culling = false, - collisionbox = {-0.19, -0.125, -0.19, 0.19, 0.125, 0.19}, -- TODO verify + collisionbox = {-0.1, 0, -0.1, 0.1, 0.5, 0.1}, collide_with_objects = false, liquid_drag = true, _fire_damage_resistant = true, @@ -46,7 +46,7 @@ local firework_entity = { vl_projectile.has_tracer, function(self, dtime) - self.object:add_velocity(vector.new(0, dtime, 0)) -- TODO timeout + self.object:add_velocity(vector.new(0, dtime, 0)) -- TODO timeout TODO var. accel. TODO max speed? end, vl_projectile.collides_with_solids, From 6066e0dc4610ae63275d9d12b3fc126f43c927d0 Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Sun, 22 Dec 2024 04:22:55 +0100 Subject: [PATCH 06/25] Change firework explosion code --- mods/ITEMS/mcl_fireworks/register.lua | 31 +++++++-------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/mods/ITEMS/mcl_fireworks/register.lua b/mods/ITEMS/mcl_fireworks/register.lua index 3c956dbef..bbc42cdcd 100644 --- a/mods/ITEMS/mcl_fireworks/register.lua +++ b/mods/ITEMS/mcl_fireworks/register.lua @@ -22,20 +22,18 @@ local firework_entity = { _fire_damage_resistant = true, _save_fields = { - "last_pos", "startpos", "damage", "is_critical", "time_in_air", "vl_projectile", "arrow_item"--[[???]], "itemstring" + "last_pos", "startpos", "damage", "time_in_air", "vl_projectile", "arrow_item"--[[???]], "itemstring" }, _damage=1, -- Damage on impact - _is_critical=false, -- Whether this arrow would deal critical damage _blocked = false, _viscosity=0, -- Viscosity of node the arrow is currently in - _deflection_cooloff=0, -- Cooloff timer after an arrow deflection, to prevent many deflections in quick succession _vl_projectile = { ignore_gravity = true, - survive_collision = true, + survive_collision = false, damages_players = true, - maximum_time = 60, + maximum_time = 3, pitch_offset = -math.pi / 2, damage_groups = function(self) return { fleshy = vector.length(self.object:get_velocity()) } @@ -46,7 +44,7 @@ local firework_entity = { vl_projectile.has_tracer, function(self, dtime) - self.object:add_velocity(vector.new(0, dtime, 0)) -- TODO timeout TODO var. accel. TODO max speed? + self.object:add_velocity(vector.new(0, 2*dtime, 0)) -- TODO var. accel. TODO max speed? end, vl_projectile.collides_with_solids, @@ -61,23 +59,6 @@ local firework_entity = { return true end, - on_collide_with_entity = function(self, pos, obj) - if self.object == obj then return end - --if (self.object:get_velocity() + obj:get_velocity()).lenght() < 5 then return end - - minetest.log("entity collision") - - explode(self, pos) - - mcl_util.remove_entity(self) - end, - on_collide_with_solid = function(self, pos, node) - explode(self, pos) - - minetest.log("solid collision") - - mcl_util.remove_entity(self) - end }, get_staticdata = function(self) @@ -117,6 +98,10 @@ local firework_entity = { self._vl_projetile = {} end end, + + _on_remove = function(self) + explode(self, self.object:get_pos()) + end, } local function register_rocket(n, duration, force) From 3291786c1fb4ff1842f39b7749e1b58d1680ecd2 Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Sun, 22 Dec 2024 04:37:18 +0100 Subject: [PATCH 07/25] Moved particle explosion to mcl_fireworks API - crossbow rockets use the API - fireworks use it obviously - fireworks fly a bit faster too --- mods/ITEMS/mcl_bows/rocket.lua | 190 +------------------------ mods/ITEMS/mcl_fireworks/init.lua | 191 +++++++++++++++++++++++++- mods/ITEMS/mcl_fireworks/register.lua | 3 +- 3 files changed, 194 insertions(+), 190 deletions(-) diff --git a/mods/ITEMS/mcl_bows/rocket.lua b/mods/ITEMS/mcl_bows/rocket.lua index 86f91f211..af8ca1f45 100644 --- a/mods/ITEMS/mcl_bows/rocket.lua +++ b/mods/ITEMS/mcl_bows/rocket.lua @@ -8,6 +8,8 @@ local ROCKET_TIMEOUT = 1 local YAW_OFFSET = -math.pi/2 +local particle_explosion = mcl_fireworks.particle_explosion + local function damage_explosion(self, damagemulitplier, pos) if self._harmless then return end @@ -27,194 +29,6 @@ local function damage_explosion(self, damagemulitplier, pos) end end -local function particle_explosion(pos) - if pos.object then pos = pos.object:get_pos() end - local particle_pattern = math.random(1, 3) - local fpitch - local type = math.random(1, 2) - local size = math.random(1, 3) - local colors = {"red", "yellow", "blue", "green", "white"} - local this_colors = {colors[math.random(#colors)], colors[math.random(#colors)], colors[math.random(#colors)]} - - if size == 1 then - fpitch = math.random(200, 300) - elseif size == 2 then - fpitch = math.random(100, 130) - else - fpitch = math.random(60, 70) - end - - if type == 1 then - core.sound_play("mcl_bows_firework", { - pos = pos, - max_hear_distance = 100, - gain = 3.0, - pitch = fpitch/100 - }, true) - else - core.sound_play("mcl_bows_firework_soft", { - pos = pos, - max_hear_distance = 100, - gain = 4.0, - pitch = fpitch/100 - }, true) - end - - if particle_pattern == 1 then - core.add_particlespawner({ - amount = 400 * size, - time = 0.0001, - minpos = pos, - maxpos = pos, - minvel = vector.new(-7 * size,-7 * size,-7 * size), - maxvel = vector.new(7 * size,7 * size,7 * size), - minexptime = .6 * size / 2, - maxexptime = .9 * size / 2, - minsize = 2 * size, - maxsize = 3 * size, - collisiondetection = false, - vertical = false, - texture = "mcl_bows_firework_"..this_colors[1]..".png", - glow = 14, - }) - core.add_particlespawner({ - amount = 400 * size, - time = 0.0001, - minpos = pos, - maxpos = pos, - minvel = vector.new(-2 * size,-2 * size,-2 * size), - maxvel = vector.new(2 * size,2 * size,2 * size), - minexptime = .6 * size / 2, - maxexptime = .9 * size / 2, - minsize = 2 * size, - maxsize = 3 * size, - collisiondetection = false, - vertical = false, - texture = "mcl_bows_firework_"..this_colors[2]..".png", - glow = 14, - }) - core.add_particlespawner({ - amount = 100 * size, - time = 0.0001, - minpos = pos, - maxpos = pos, - minvel = vector.new(-14 * size,-14 * size,-14 * size), - maxvel = vector.new(14 * size,14 * size,14 * size), - minexptime = .6 * size / 2, - maxexptime = .9 * size / 2, - minsize = 2 * size, - maxsize = 3 * size, - collisiondetection = false, - vertical = false, - texture = "mcl_bows_firework_"..this_colors[3]..".png", - glow = 14, - }) - elseif particle_pattern == 2 then - - core.add_particlespawner({ - amount = 240 * size, - time = 0.0001, - minpos = pos, - maxpos = pos, - minvel = vector.new(-5 * size,-5 * size,-5 * size), - maxvel = vector.new(5 * size,5 * size,5 * size), - minexptime = .6 * size / 2, - maxexptime = .9 * size / 2, - minsize = 2 * size, - maxsize = 3 * size, - collisiondetection = false, - vertical = false, - texture = "mcl_bows_firework_"..this_colors[1]..".png", - glow = 14, - }) - core.add_particlespawner({ - amount = 500 * size, - time = 0.0001, - minpos = pos, - maxpos = pos, - minvel = vector.new(-2 * size,-2 * size,-2 * size), - maxvel = vector.new(2 * size,2 * size,2 * size), - minexptime = .6 * size / 2, - maxexptime = .9 * size / 2, - minsize = 2 * size, - maxsize = 3 * size, - collisiondetection = false, - vertical = false, - texture = "mcl_bows_firework_"..this_colors[2]..".png", - glow = 14, - }) - core.add_particlespawner({ - amount = 350 * size, - time = 0.0001, - minpos = pos, - maxpos = pos, - minvel = vector.new(-3 * size,-3 * size,-3 * size), - maxvel = vector.new(3 * size,3 * size,3 * size), - minexptime = .6 * size / 2, - maxexptime = .9 * size / 2, - minsize = 2 * size, - maxsize = 3 * size, - collisiondetection = false, - vertical = false, - texture = "mcl_bows_firework_"..this_colors[3]..".png", - glow = 14, - }) - elseif particle_pattern == 3 then - - core.add_particlespawner({ - amount = 400 * size, - time = 0.0001, - minpos = pos, - maxpos = pos, - minvel = vector.new(-6 * size,-4 * size,-6 * size), - maxvel = vector.new(6 * size,4 * size,6 * size), - minexptime = .6 * size, - maxexptime = .9 * size, - minsize = 2 * size, - maxsize = 3 * size, - collisiondetection = false, - vertical = false, - texture = "mcl_bows_firework_"..this_colors[1]..".png", - glow = 14, - }) - core.add_particlespawner({ - amount = 120 * size, - time = 0.0001, - minpos = pos, - maxpos = pos, - minvel = vector.new(-8 * size,6 * size,-8 * size), - maxvel = vector.new(8 * size,6 * size,8 * size), - minexptime = .6 * size, - maxexptime = .9 * size, - minsize = 2 * size, - maxsize = 3 * size, - collisiondetection = false, - vertical = false, - texture = "mcl_bows_firework_"..this_colors[2]..".png", - glow = 14, - }) - core.add_particlespawner({ - amount = 130 * size, - time = 0.0001, - minpos = pos, - maxpos = pos, - minvel = vector.new(-3 * size,3 * size,-3 * size), - maxvel = vector.new(3 * size,3 * size,3 * size), - minexptime = .6 * size, - maxexptime = .9 * size, - minsize = 2 * size, - maxsize = 3 * size, - collisiondetection = false, - vertical = false, - texture = "mcl_bows_firework_"..this_colors[3]..".png", - glow = 14, - }) - end - - return size - -end - core.register_craftitem("mcl_bows:rocket", { description = S("Arrow"), _tt_help = S("Ammunition").."\n"..S("Damage from bow: 1-10").."\n"..S("Damage from dispenser: 3"), diff --git a/mods/ITEMS/mcl_fireworks/init.lua b/mods/ITEMS/mcl_fireworks/init.lua index cd1922580..45d787677 100644 --- a/mods/ITEMS/mcl_fireworks/init.lua +++ b/mods/ITEMS/mcl_fireworks/init.lua @@ -1,4 +1,193 @@ local path = minetest.get_modpath("mcl_fireworks") +mcl_fireworks = {} + +function mcl_fireworks.particle_explosion(pos) + if pos.object then pos = pos.object:get_pos() end + local particle_pattern = math.random(1, 3) + local fpitch + local type = math.random(1, 2) + local size = math.random(1, 3) + local colors = {"red", "yellow", "blue", "green", "white"} + local this_colors = {colors[math.random(#colors)], colors[math.random(#colors)], colors[math.random(#colors)]} + + if size == 1 then + fpitch = math.random(200, 300) + elseif size == 2 then + fpitch = math.random(100, 130) + else + fpitch = math.random(60, 70) + end + + if type == 1 then + core.sound_play("mcl_bows_firework", { + pos = pos, + max_hear_distance = 100, + gain = 3.0, + pitch = fpitch/100 + }, true) + else + core.sound_play("mcl_bows_firework_soft", { + pos = pos, + max_hear_distance = 100, + gain = 4.0, + pitch = fpitch/100 + }, true) + end + + if particle_pattern == 1 then + core.add_particlespawner({ + amount = 400 * size, + time = 0.0001, + minpos = pos, + maxpos = pos, + minvel = vector.new(-7 * size,-7 * size,-7 * size), + maxvel = vector.new(7 * size,7 * size,7 * size), + minexptime = .6 * size / 2, + maxexptime = .9 * size / 2, + minsize = 2 * size, + maxsize = 3 * size, + collisiondetection = false, + vertical = false, + texture = "mcl_bows_firework_"..this_colors[1]..".png", + glow = 14, + }) + core.add_particlespawner({ + amount = 400 * size, + time = 0.0001, + minpos = pos, + maxpos = pos, + minvel = vector.new(-2 * size,-2 * size,-2 * size), + maxvel = vector.new(2 * size,2 * size,2 * size), + minexptime = .6 * size / 2, + maxexptime = .9 * size / 2, + minsize = 2 * size, + maxsize = 3 * size, + collisiondetection = false, + vertical = false, + texture = "mcl_bows_firework_"..this_colors[2]..".png", + glow = 14, + }) + core.add_particlespawner({ + amount = 100 * size, + time = 0.0001, + minpos = pos, + maxpos = pos, + minvel = vector.new(-14 * size,-14 * size,-14 * size), + maxvel = vector.new(14 * size,14 * size,14 * size), + minexptime = .6 * size / 2, + maxexptime = .9 * size / 2, + minsize = 2 * size, + maxsize = 3 * size, + collisiondetection = false, + vertical = false, + texture = "mcl_bows_firework_"..this_colors[3]..".png", + glow = 14, + }) + elseif particle_pattern == 2 then + + core.add_particlespawner({ + amount = 240 * size, + time = 0.0001, + minpos = pos, + maxpos = pos, + minvel = vector.new(-5 * size,-5 * size,-5 * size), + maxvel = vector.new(5 * size,5 * size,5 * size), + minexptime = .6 * size / 2, + maxexptime = .9 * size / 2, + minsize = 2 * size, + maxsize = 3 * size, + collisiondetection = false, + vertical = false, + texture = "mcl_bows_firework_"..this_colors[1]..".png", + glow = 14, + }) + core.add_particlespawner({ + amount = 500 * size, + time = 0.0001, + minpos = pos, + maxpos = pos, + minvel = vector.new(-2 * size,-2 * size,-2 * size), + maxvel = vector.new(2 * size,2 * size,2 * size), + minexptime = .6 * size / 2, + maxexptime = .9 * size / 2, + minsize = 2 * size, + maxsize = 3 * size, + collisiondetection = false, + vertical = false, + texture = "mcl_bows_firework_"..this_colors[2]..".png", + glow = 14, + }) + core.add_particlespawner({ + amount = 350 * size, + time = 0.0001, + minpos = pos, + maxpos = pos, + minvel = vector.new(-3 * size,-3 * size,-3 * size), + maxvel = vector.new(3 * size,3 * size,3 * size), + minexptime = .6 * size / 2, + maxexptime = .9 * size / 2, + minsize = 2 * size, + maxsize = 3 * size, + collisiondetection = false, + vertical = false, + texture = "mcl_bows_firework_"..this_colors[3]..".png", + glow = 14, + }) + elseif particle_pattern == 3 then + + core.add_particlespawner({ + amount = 400 * size, + time = 0.0001, + minpos = pos, + maxpos = pos, + minvel = vector.new(-6 * size,-4 * size,-6 * size), + maxvel = vector.new(6 * size,4 * size,6 * size), + minexptime = .6 * size, + maxexptime = .9 * size, + minsize = 2 * size, + maxsize = 3 * size, + collisiondetection = false, + vertical = false, + texture = "mcl_bows_firework_"..this_colors[1]..".png", + glow = 14, + }) + core.add_particlespawner({ + amount = 120 * size, + time = 0.0001, + minpos = pos, + maxpos = pos, + minvel = vector.new(-8 * size,6 * size,-8 * size), + maxvel = vector.new(8 * size,6 * size,8 * size), + minexptime = .6 * size, + maxexptime = .9 * size, + minsize = 2 * size, + maxsize = 3 * size, + collisiondetection = false, + vertical = false, + texture = "mcl_bows_firework_"..this_colors[2]..".png", + glow = 14, + }) + core.add_particlespawner({ + amount = 130 * size, + time = 0.0001, + minpos = pos, + maxpos = pos, + minvel = vector.new(-3 * size,3 * size,-3 * size), + maxvel = vector.new(3 * size,3 * size,3 * size), + minexptime = .6 * size, + maxexptime = .9 * size, + minsize = 2 * size, + maxsize = 3 * size, + collisiondetection = false, + vertical = false, + texture = "mcl_bows_firework_"..this_colors[3]..".png", + glow = 14, + }) + end + + return size +end + dofile(path .. "/register.lua") -dofile(path .. "/crafting.lua") \ No newline at end of file +dofile(path .. "/crafting.lua") diff --git a/mods/ITEMS/mcl_fireworks/register.lua b/mods/ITEMS/mcl_fireworks/register.lua index bbc42cdcd..5bb8808b2 100644 --- a/mods/ITEMS/mcl_fireworks/register.lua +++ b/mods/ITEMS/mcl_fireworks/register.lua @@ -5,6 +5,7 @@ local description = S("Firework Rocket") local function explode(self, pos) -- temp code + mcl_fireworks.particle_explosion(pos) mcl_mobs.mob_class.boom(self, pos, 1) end @@ -44,7 +45,7 @@ local firework_entity = { vl_projectile.has_tracer, function(self, dtime) - self.object:add_velocity(vector.new(0, 2*dtime, 0)) -- TODO var. accel. TODO max speed? + self.object:add_velocity(vector.new(0, 5*dtime, 0)) -- TODO var. accel. TODO max speed? end, vl_projectile.collides_with_solids, From 93a6ce6824dae89e438226dffb4cfc77e941fdeb Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Tue, 24 Dec 2024 22:53:31 +0100 Subject: [PATCH 08/25] Renamed mcl_fireworks to vl_fireworks --- mods/ITEMS/mcl_bows/rocket.lua | 4 ++-- .../{mcl_fireworks => vl_fireworks}/README.txt | 0 .../crafting.lua | 8 ++++---- .../{mcl_fireworks => vl_fireworks}/init.lua | 6 +++--- .../locale/template.txt | 0 .../locale/vl_fireworks.de.tr} | 0 .../locale/vl_fireworks.es.tr} | 0 .../locale/vl_fireworks.fr.tr} | 0 .../locale/vl_fireworks.ja.tr} | 0 .../locale/vl_fireworks.nb.tr} | 0 .../locale/vl_fireworks.pl.tr} | 0 .../locale/vl_fireworks.pt_BR.tr} | 0 .../locale/vl_fireworks.ru.tr} | 0 .../locale/vl_fireworks.zh_CN.tr} | 0 .../{mcl_fireworks => vl_fireworks}/mod.conf | 2 +- .../models/vl_fireworks_rocket.obj} | 0 .../register.lua | 16 ++++++++-------- .../sounds/vl_fireworks_rocket.ogg} | Bin ...works_entity.png => vl_fireworks_entity.png} | Bin ...works_rocket.png => vl_fireworks_rocket.png} | Bin 20 files changed, 18 insertions(+), 18 deletions(-) rename mods/ITEMS/{mcl_fireworks => vl_fireworks}/README.txt (100%) rename mods/ITEMS/{mcl_fireworks => vl_fireworks}/crafting.lua (77%) rename mods/ITEMS/{mcl_fireworks => vl_fireworks}/init.lua (97%) rename mods/ITEMS/{mcl_fireworks => vl_fireworks}/locale/template.txt (100%) rename mods/ITEMS/{mcl_fireworks/locale/mcl_fireworks.de.tr => vl_fireworks/locale/vl_fireworks.de.tr} (100%) rename mods/ITEMS/{mcl_fireworks/locale/mcl_fireworks.es.tr => vl_fireworks/locale/vl_fireworks.es.tr} (100%) rename mods/ITEMS/{mcl_fireworks/locale/mcl_fireworks.fr.tr => vl_fireworks/locale/vl_fireworks.fr.tr} (100%) rename mods/ITEMS/{mcl_fireworks/locale/mcl_fireworks.ja.tr => vl_fireworks/locale/vl_fireworks.ja.tr} (100%) rename mods/ITEMS/{mcl_fireworks/locale/mcl_fireworks.nb.tr => vl_fireworks/locale/vl_fireworks.nb.tr} (100%) rename mods/ITEMS/{mcl_fireworks/locale/mcl_fireworks.pl.tr => vl_fireworks/locale/vl_fireworks.pl.tr} (100%) rename mods/ITEMS/{mcl_fireworks/locale/mcl_fireworks.pt_BR.tr => vl_fireworks/locale/vl_fireworks.pt_BR.tr} (100%) rename mods/ITEMS/{mcl_fireworks/locale/mcl_fireworks.ru.tr => vl_fireworks/locale/vl_fireworks.ru.tr} (100%) rename mods/ITEMS/{mcl_fireworks/locale/mcl_fireworks.zh_CN.tr => vl_fireworks/locale/vl_fireworks.zh_CN.tr} (100%) rename mods/ITEMS/{mcl_fireworks => vl_fireworks}/mod.conf (81%) rename mods/ITEMS/{mcl_fireworks/models/mcl_fireworks_rocket.obj => vl_fireworks/models/vl_fireworks_rocket.obj} (100%) rename mods/ITEMS/{mcl_fireworks => vl_fireworks}/register.lua (87%) rename mods/ITEMS/{mcl_fireworks/sounds/mcl_fireworks_rocket.ogg => vl_fireworks/sounds/vl_fireworks_rocket.ogg} (100%) rename textures/{mcl_fireworks_entity.png => vl_fireworks_entity.png} (100%) rename textures/{mcl_fireworks_rocket.png => vl_fireworks_rocket.png} (100%) diff --git a/mods/ITEMS/mcl_bows/rocket.lua b/mods/ITEMS/mcl_bows/rocket.lua index af8ca1f45..5cc593639 100644 --- a/mods/ITEMS/mcl_bows/rocket.lua +++ b/mods/ITEMS/mcl_bows/rocket.lua @@ -8,7 +8,7 @@ local ROCKET_TIMEOUT = 1 local YAW_OFFSET = -math.pi/2 -local particle_explosion = mcl_fireworks.particle_explosion +local particle_explosion = vl_fireworks.particle_explosion local function damage_explosion(self, damagemulitplier, pos) if self._harmless then return end @@ -97,7 +97,7 @@ if core.get_modpath("mcl_core") and core.get_modpath("mcl_mobitems") then output = "mcl_bows:rocket 1", recipe = { {"mcl_core:paper"}, - {"mcl_fireworks:rocket_2"}, + {"vl_fireworks:rocket_2"}, {"mcl_bows:arrow"}, } }) diff --git a/mods/ITEMS/mcl_fireworks/README.txt b/mods/ITEMS/vl_fireworks/README.txt similarity index 100% rename from mods/ITEMS/mcl_fireworks/README.txt rename to mods/ITEMS/vl_fireworks/README.txt diff --git a/mods/ITEMS/mcl_fireworks/crafting.lua b/mods/ITEMS/vl_fireworks/crafting.lua similarity index 77% rename from mods/ITEMS/mcl_fireworks/crafting.lua rename to mods/ITEMS/vl_fireworks/crafting.lua index a9e156aa6..1161cc8c2 100644 --- a/mods/ITEMS/mcl_fireworks/crafting.lua +++ b/mods/ITEMS/vl_fireworks/crafting.lua @@ -1,17 +1,17 @@ minetest.register_craft({ type = "shapeless", - output = "mcl_fireworks:rocket_1 3", + output = "vl_fireworks:rocket_1 3", recipe = {"mcl_core:paper", "mcl_mobitems:gunpowder"}, }) minetest.register_craft({ type = "shapeless", - output = "mcl_fireworks:rocket_2 3", + output = "vl_fireworks:rocket_2 3", recipe = {"mcl_core:paper", "mcl_mobitems:gunpowder", "mcl_mobitems:gunpowder"}, }) minetest.register_craft({ type = "shapeless", - output = "mcl_fireworks:rocket_3 3", + output = "vl_fireworks:rocket_3 3", recipe = {"mcl_core:paper", "mcl_mobitems:gunpowder", "mcl_mobitems:gunpowder", "mcl_mobitems:gunpowder"}, -}) \ No newline at end of file +}) diff --git a/mods/ITEMS/mcl_fireworks/init.lua b/mods/ITEMS/vl_fireworks/init.lua similarity index 97% rename from mods/ITEMS/mcl_fireworks/init.lua rename to mods/ITEMS/vl_fireworks/init.lua index 45d787677..612a63419 100644 --- a/mods/ITEMS/mcl_fireworks/init.lua +++ b/mods/ITEMS/vl_fireworks/init.lua @@ -1,8 +1,8 @@ -local path = minetest.get_modpath("mcl_fireworks") +local path = minetest.get_modpath("vl_fireworks") -mcl_fireworks = {} +vl_fireworks = {} -function mcl_fireworks.particle_explosion(pos) +function vl_fireworks.generic_particle_explosion(pos) if pos.object then pos = pos.object:get_pos() end local particle_pattern = math.random(1, 3) local fpitch diff --git a/mods/ITEMS/mcl_fireworks/locale/template.txt b/mods/ITEMS/vl_fireworks/locale/template.txt similarity index 100% rename from mods/ITEMS/mcl_fireworks/locale/template.txt rename to mods/ITEMS/vl_fireworks/locale/template.txt diff --git a/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.de.tr b/mods/ITEMS/vl_fireworks/locale/vl_fireworks.de.tr similarity index 100% rename from mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.de.tr rename to mods/ITEMS/vl_fireworks/locale/vl_fireworks.de.tr diff --git a/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.es.tr b/mods/ITEMS/vl_fireworks/locale/vl_fireworks.es.tr similarity index 100% rename from mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.es.tr rename to mods/ITEMS/vl_fireworks/locale/vl_fireworks.es.tr diff --git a/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.fr.tr b/mods/ITEMS/vl_fireworks/locale/vl_fireworks.fr.tr similarity index 100% rename from mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.fr.tr rename to mods/ITEMS/vl_fireworks/locale/vl_fireworks.fr.tr diff --git a/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.ja.tr b/mods/ITEMS/vl_fireworks/locale/vl_fireworks.ja.tr similarity index 100% rename from mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.ja.tr rename to mods/ITEMS/vl_fireworks/locale/vl_fireworks.ja.tr diff --git a/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.nb.tr b/mods/ITEMS/vl_fireworks/locale/vl_fireworks.nb.tr similarity index 100% rename from mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.nb.tr rename to mods/ITEMS/vl_fireworks/locale/vl_fireworks.nb.tr diff --git a/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.pl.tr b/mods/ITEMS/vl_fireworks/locale/vl_fireworks.pl.tr similarity index 100% rename from mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.pl.tr rename to mods/ITEMS/vl_fireworks/locale/vl_fireworks.pl.tr diff --git a/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.pt_BR.tr b/mods/ITEMS/vl_fireworks/locale/vl_fireworks.pt_BR.tr similarity index 100% rename from mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.pt_BR.tr rename to mods/ITEMS/vl_fireworks/locale/vl_fireworks.pt_BR.tr diff --git a/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.ru.tr b/mods/ITEMS/vl_fireworks/locale/vl_fireworks.ru.tr similarity index 100% rename from mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.ru.tr rename to mods/ITEMS/vl_fireworks/locale/vl_fireworks.ru.tr diff --git a/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.zh_CN.tr b/mods/ITEMS/vl_fireworks/locale/vl_fireworks.zh_CN.tr similarity index 100% rename from mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.zh_CN.tr rename to mods/ITEMS/vl_fireworks/locale/vl_fireworks.zh_CN.tr diff --git a/mods/ITEMS/mcl_fireworks/mod.conf b/mods/ITEMS/vl_fireworks/mod.conf similarity index 81% rename from mods/ITEMS/mcl_fireworks/mod.conf rename to mods/ITEMS/vl_fireworks/mod.conf index 6c0971176..efb925363 100644 --- a/mods/ITEMS/mcl_fireworks/mod.conf +++ b/mods/ITEMS/vl_fireworks/mod.conf @@ -1,3 +1,3 @@ -name = mcl_fireworks +name = vl_fireworks description = Adds fun fireworks to the game which players can use. depends = vl_projectile diff --git a/mods/ITEMS/mcl_fireworks/models/mcl_fireworks_rocket.obj b/mods/ITEMS/vl_fireworks/models/vl_fireworks_rocket.obj similarity index 100% rename from mods/ITEMS/mcl_fireworks/models/mcl_fireworks_rocket.obj rename to mods/ITEMS/vl_fireworks/models/vl_fireworks_rocket.obj diff --git a/mods/ITEMS/mcl_fireworks/register.lua b/mods/ITEMS/vl_fireworks/register.lua similarity index 87% rename from mods/ITEMS/mcl_fireworks/register.lua rename to mods/ITEMS/vl_fireworks/register.lua index 5bb8808b2..e02647e1e 100644 --- a/mods/ITEMS/mcl_fireworks/register.lua +++ b/mods/ITEMS/vl_fireworks/register.lua @@ -5,7 +5,7 @@ local description = S("Firework Rocket") local function explode(self, pos) -- temp code - mcl_fireworks.particle_explosion(pos) + vl_fireworks.generic_particle_explosion(pos) mcl_mobs.mob_class.boom(self, pos, 1) end @@ -14,8 +14,8 @@ local firework_entity = { pointable = false, visual = "mesh", visual_size = {x=3, y=3}, - mesh = "mcl_fireworks_rocket.obj", - textures = {"mcl_fireworks_entity.png"}, + mesh = "vl_fireworks_rocket.obj", + textures = {"vl_fireworks_entity.png"}, backface_culling = false, collisionbox = {-0.1, 0, -0.1, 0.1, 0.5, 0.1}, collide_with_objects = false, @@ -107,11 +107,11 @@ local firework_entity = { local function register_rocket(n, duration, force) def = table.copy(firework_entity) - vl_projectile.register("mcl_fireworks:rocket_" .. n, def) -- TODO one entity - minetest.register_craftitem("mcl_fireworks:rocket_" .. n, { -- TODO one item, use metadata + vl_projectile.register("vl_fireworks:rocket_" .. n, def) -- TODO one entity + minetest.register_craftitem("vl_fireworks:rocket_" .. n, { -- TODO one item, use metadata description = description, _tt_help = tt_help .. " " .. duration, - inventory_image = "mcl_fireworks_rocket.png", + inventory_image = "vl_fireworks_rocket.png", stack_max = 64, on_use = function(itemstack, user, pointed_thing) local elytra = mcl_playerplus.elytra[user] @@ -120,14 +120,14 @@ local function register_rocket(n, duration, force) if not minetest.is_creative_enabled(user:get_player_name()) then itemstack:take_item() end - minetest.sound_play("mcl_fireworks_rocket", {pos = user:get_pos()}) + minetest.sound_play("vl_fireworks_rocket", {pos = user:get_pos()}) end return itemstack end, on_place = function(itemstack, user, pointed_thing) local pos = pointed_thing.above -- pos.y = pos.y + 1 - vl_projectile.create("mcl_fireworks:rocket_" .. n, { + vl_projectile.create("vl_fireworks:rocket_" .. n, { pos=pos, velocity=vector.new(0,1,0) }) diff --git a/mods/ITEMS/mcl_fireworks/sounds/mcl_fireworks_rocket.ogg b/mods/ITEMS/vl_fireworks/sounds/vl_fireworks_rocket.ogg similarity index 100% rename from mods/ITEMS/mcl_fireworks/sounds/mcl_fireworks_rocket.ogg rename to mods/ITEMS/vl_fireworks/sounds/vl_fireworks_rocket.ogg diff --git a/textures/mcl_fireworks_entity.png b/textures/vl_fireworks_entity.png similarity index 100% rename from textures/mcl_fireworks_entity.png rename to textures/vl_fireworks_entity.png diff --git a/textures/mcl_fireworks_rocket.png b/textures/vl_fireworks_rocket.png similarity index 100% rename from textures/mcl_fireworks_rocket.png rename to textures/vl_fireworks_rocket.png From 9ef0738a2ef7f915c1ff16aeac0cd43dd89f78a1 Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Tue, 24 Dec 2024 22:56:47 +0100 Subject: [PATCH 09/25] Dispensers work with fireworks --- mods/ITEMS/vl_fireworks/register.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/vl_fireworks/register.lua b/mods/ITEMS/vl_fireworks/register.lua index e02647e1e..b6259ed56 100644 --- a/mods/ITEMS/vl_fireworks/register.lua +++ b/mods/ITEMS/vl_fireworks/register.lua @@ -6,7 +6,7 @@ local description = S("Firework Rocket") local function explode(self, pos) -- temp code vl_fireworks.generic_particle_explosion(pos) - mcl_mobs.mob_class.boom(self, pos, 1) + mcl_mobs.mob_class.safe_boom(self, pos, 1) end local firework_entity = { @@ -132,6 +132,12 @@ local function register_rocket(n, duration, force) velocity=vector.new(0,1,0) }) end, + _on_dispense = function(dropitem, pos, droppos, dropnode, dropdir) + vl_projectile.create("vl_fireworks:rocket_" .. n, { + pos=pos, + velocity=vector.new(0,1,0) + }) + end, }) end From 1a98c9ad2ec8d4cc9750c2212ec7b3ac0c561735 Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Tue, 24 Dec 2024 23:05:05 +0100 Subject: [PATCH 10/25] One firework entity to rule them all --- mods/ITEMS/vl_fireworks/register.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mods/ITEMS/vl_fireworks/register.lua b/mods/ITEMS/vl_fireworks/register.lua index b6259ed56..adf8b4101 100644 --- a/mods/ITEMS/vl_fireworks/register.lua +++ b/mods/ITEMS/vl_fireworks/register.lua @@ -105,9 +105,9 @@ local firework_entity = { end, } +vl_projectile.register("vl_fireworks:rocket", firework_entity) + local function register_rocket(n, duration, force) - def = table.copy(firework_entity) - vl_projectile.register("vl_fireworks:rocket_" .. n, def) -- TODO one entity minetest.register_craftitem("vl_fireworks:rocket_" .. n, { -- TODO one item, use metadata description = description, _tt_help = tt_help .. " " .. duration, @@ -127,13 +127,13 @@ local function register_rocket(n, duration, force) on_place = function(itemstack, user, pointed_thing) local pos = pointed_thing.above -- pos.y = pos.y + 1 - vl_projectile.create("vl_fireworks:rocket_" .. n, { + vl_projectile.create("vl_fireworks:rocket", { pos=pos, velocity=vector.new(0,1,0) }) end, _on_dispense = function(dropitem, pos, droppos, dropnode, dropdir) - vl_projectile.create("vl_fireworks:rocket_" .. n, { + vl_projectile.create("vl_fireworks:rocket", { pos=pos, velocity=vector.new(0,1,0) }) From a9187ab9de5282162e170a54c5c98cd623296b4e Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Tue, 24 Dec 2024 23:38:35 +0100 Subject: [PATCH 11/25] Squashed all rockets into one item --- mods/ITEMS/vl_fireworks/crafting.lua | 6 +-- mods/ITEMS/vl_fireworks/register.lua | 68 ++++++++++++++-------------- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/mods/ITEMS/vl_fireworks/crafting.lua b/mods/ITEMS/vl_fireworks/crafting.lua index 1161cc8c2..f8b83b17e 100644 --- a/mods/ITEMS/vl_fireworks/crafting.lua +++ b/mods/ITEMS/vl_fireworks/crafting.lua @@ -1,17 +1,17 @@ minetest.register_craft({ type = "shapeless", - output = "vl_fireworks:rocket_1 3", + output = "vl_fireworks:rocket 3", recipe = {"mcl_core:paper", "mcl_mobitems:gunpowder"}, }) minetest.register_craft({ type = "shapeless", - output = "vl_fireworks:rocket_2 3", + output = "vl_fireworks:rocket 3", recipe = {"mcl_core:paper", "mcl_mobitems:gunpowder", "mcl_mobitems:gunpowder"}, }) minetest.register_craft({ type = "shapeless", - output = "vl_fireworks:rocket_3 3", + output = "vl_fireworks:rocket 3", recipe = {"mcl_core:paper", "mcl_mobitems:gunpowder", "mcl_mobitems:gunpowder", "mcl_mobitems:gunpowder"}, }) diff --git a/mods/ITEMS/vl_fireworks/register.lua b/mods/ITEMS/vl_fireworks/register.lua index adf8b4101..4be469f5c 100644 --- a/mods/ITEMS/vl_fireworks/register.lua +++ b/mods/ITEMS/vl_fireworks/register.lua @@ -107,40 +107,40 @@ local firework_entity = { vl_projectile.register("vl_fireworks:rocket", firework_entity) -local function register_rocket(n, duration, force) - minetest.register_craftitem("vl_fireworks:rocket_" .. n, { -- TODO one item, use metadata - description = description, - _tt_help = tt_help .. " " .. duration, - inventory_image = "vl_fireworks_rocket.png", - stack_max = 64, - on_use = function(itemstack, user, pointed_thing) - local elytra = mcl_playerplus.elytra[user] - if elytra.active and elytra.rocketing <= 0 then - elytra.rocketing = duration - if not minetest.is_creative_enabled(user:get_player_name()) then - itemstack:take_item() - end - minetest.sound_play("vl_fireworks_rocket", {pos = user:get_pos()}) +-- local function register_rocket(n, duration, force) +minetest.register_craftitem("vl_fireworks:rocket", { -- TODO use metadata + description = description, +-- _tt_help = tt_help .. " " .. duration, + inventory_image = "vl_fireworks_rocket.png", + stack_max = 64, + on_use = function(itemstack, user, pointed_thing) + local elytra = mcl_playerplus.elytra[user] + if elytra.active and elytra.rocketing <= 0 then + elytra.rocketing = 5 -- duration + if not minetest.is_creative_enabled(user:get_player_name()) then + itemstack:take_item() end - return itemstack - end, - on_place = function(itemstack, user, pointed_thing) - local pos = pointed_thing.above + minetest.sound_play("vl_fireworks_rocket", {pos = user:get_pos()}) + end + return itemstack + end, + on_place = function(itemstack, user, pointed_thing) + local pos = pointed_thing.above -- pos.y = pos.y + 1 - vl_projectile.create("vl_fireworks:rocket", { - pos=pos, - velocity=vector.new(0,1,0) - }) - end, - _on_dispense = function(dropitem, pos, droppos, dropnode, dropdir) - vl_projectile.create("vl_fireworks:rocket", { - pos=pos, - velocity=vector.new(0,1,0) - }) - end, - }) -end + vl_projectile.create("vl_fireworks:rocket", { + pos=pos, + velocity=vector.new(0,1,0) + }) + end, + _on_dispense = function(dropitem, pos, droppos, dropnode, dropdir) + vl_projectile.create("vl_fireworks:rocket", { + pos=pos, + velocity=vector.new(0,1,0) + }) + end, +}) +-- end -register_rocket(1, 2.2, 10) -register_rocket(2, 4.5, 20) -register_rocket(3, 6, 30) +-- register_rocket(1, 2.2, 10) +-- register_rocket(2, 4.5, 20) +-- register_rocket(3, 6, 30) From 8b0534437aa57be0f66a22a908eb39aa01660de8 Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Thu, 26 Dec 2024 02:58:53 +0100 Subject: [PATCH 12/25] Add metadata-based firework duration and force --- mods/HELP/mcl_tt/snippets_mcl.lua | 16 ++++++++++++++ mods/HUD/mcl_inventory/creative.lua | 10 +++++++++ mods/ITEMS/vl_fireworks/register.lua | 33 +++++++++++++++++----------- 3 files changed, 46 insertions(+), 13 deletions(-) diff --git a/mods/HELP/mcl_tt/snippets_mcl.lua b/mods/HELP/mcl_tt/snippets_mcl.lua index a964b96a3..384d590c0 100644 --- a/mods/HELP/mcl_tt/snippets_mcl.lua +++ b/mods/HELP/mcl_tt/snippets_mcl.lua @@ -184,3 +184,19 @@ tt.register_snippet(function(itemstring, _, itemstack) end return s:trim() end) + + +-- Fireworks info +tt.register_snippet(function(itemstring, _, itemstack) + if not itemstack then return end + local def = itemstack:get_definition() + if not def then return end + + if not def._vl_fireworks_tt then return end + + local s = "" + local meta = itemstack:get_meta() + s = s .. def._vl_fireworks_tt(meta:get_float("vl_fireworks:duration")) + + return s:trim() +end) diff --git a/mods/HUD/mcl_inventory/creative.lua b/mods/HUD/mcl_inventory/creative.lua index 3adede128..7504b080b 100644 --- a/mods/HUD/mcl_inventory/creative.lua +++ b/mods/HUD/mcl_inventory/creative.lua @@ -113,6 +113,16 @@ minetest.register_on_mods_loaded(function() table.insert(inventory_lists["matr"], name) nonmisc = true end + if def._vl_fireworks_std_durs_forces then + for i, tbl in ipairs(def._vl_fireworks_std_durs_forces) do + local stack = ItemStack(name) + local meta = stack:get_meta() + meta:set_float("vl_fireworks:duration", tbl[1]) + meta:set_int("vl_fireworks:force", tbl[2]) + table.insert(inventory_lists["misc"], stack:to_string()) + end + nonmisc = true + end -- Misc. category is for everything which is not in any other category if not nonmisc then table.insert(inventory_lists["misc"], name) diff --git a/mods/ITEMS/vl_fireworks/register.lua b/mods/ITEMS/vl_fireworks/register.lua index 4be469f5c..64f4e2114 100644 --- a/mods/ITEMS/vl_fireworks/register.lua +++ b/mods/ITEMS/vl_fireworks/register.lua @@ -23,7 +23,7 @@ local firework_entity = { _fire_damage_resistant = true, _save_fields = { - "last_pos", "startpos", "damage", "time_in_air", "vl_projectile", "arrow_item"--[[???]], "itemstring" + "last_pos", "startpos", "time_in_air", "vl_projectile", "arrow_item"--[[???]], "itemstring", "duration" }, _damage=1, -- Damage on impact @@ -46,6 +46,10 @@ local firework_entity = { function(self, dtime) self.object:add_velocity(vector.new(0, 5*dtime, 0)) -- TODO var. accel. TODO max speed? + if self._vl_projectile.extra then + self._vl_projectile.maximum_time = self._vl_projectile.extra + self._vl_projectile.extra = nil + end end, vl_projectile.collides_with_solids, @@ -107,16 +111,14 @@ local firework_entity = { vl_projectile.register("vl_fireworks:rocket", firework_entity) --- local function register_rocket(n, duration, force) minetest.register_craftitem("vl_fireworks:rocket", { -- TODO use metadata description = description, --- _tt_help = tt_help .. " " .. duration, inventory_image = "vl_fireworks_rocket.png", stack_max = 64, on_use = function(itemstack, user, pointed_thing) local elytra = mcl_playerplus.elytra[user] if elytra.active and elytra.rocketing <= 0 then - elytra.rocketing = 5 -- duration + elytra.rocketing = meta:get_float("vl_fireworks:duration") if not minetest.is_creative_enabled(user:get_player_name()) then itemstack:take_item() end @@ -126,21 +128,26 @@ minetest.register_craftitem("vl_fireworks:rocket", { -- TODO use metadata end, on_place = function(itemstack, user, pointed_thing) local pos = pointed_thing.above + local meta = itemstack:get_meta() -- pos.y = pos.y + 1 vl_projectile.create("vl_fireworks:rocket", { - pos=pos, - velocity=vector.new(0,1,0) + pos = pos, + dir = vector.new(0,1,0), + velocity = 1 + meta:get_int("vl_fireworks:force")/10, + extra = meta:get_float("vl_fireworks:duration") }) end, _on_dispense = function(dropitem, pos, droppos, dropnode, dropdir) + local meta = itemstack:get_meta() vl_projectile.create("vl_fireworks:rocket", { - pos=pos, - velocity=vector.new(0,1,0) + pos = pos, + dir = vector.new(0,1,0), + velocity = 1 + meta:get_int("vl_fireworks:force")/10, + extra = meta:get_float("vl_fireworks:duration") }) end, + _vl_fireworks_std_durs_forces = { {2.2, 10}, {4.5, 20}, {6, 30} }, + _vl_fireworks_tt = function(duration) + return S("Duration:") .. " " .. duration + end, }) --- end - --- register_rocket(1, 2.2, 10) --- register_rocket(2, 4.5, 20) --- register_rocket(3, 6, 30) From e69bd1412ec8ea843e2dcacb1fe93fd44f5a3d22 Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Thu, 26 Dec 2024 03:59:32 +0100 Subject: [PATCH 13/25] Fireworks now fly in arches --- mods/ITEMS/vl_fireworks/register.lua | 46 ++++++++++++++++++---------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/mods/ITEMS/vl_fireworks/register.lua b/mods/ITEMS/vl_fireworks/register.lua index 64f4e2114..21a378744 100644 --- a/mods/ITEMS/vl_fireworks/register.lua +++ b/mods/ITEMS/vl_fireworks/register.lua @@ -3,6 +3,8 @@ local S = minetest.get_translator(minetest.get_current_modname()) local tt_help = S("Flight Duration:") local description = S("Firework Rocket") +local TAU = 2*math.pi + local function explode(self, pos) -- temp code vl_fireworks.generic_particle_explosion(pos) @@ -45,11 +47,18 @@ local firework_entity = { vl_projectile.has_tracer, function(self, dtime) - self.object:add_velocity(vector.new(0, 5*dtime, 0)) -- TODO var. accel. TODO max speed? if self._vl_projectile.extra then - self._vl_projectile.maximum_time = self._vl_projectile.extra + local e = self._vl_projectile.extra + self._force = e.force/10 + 5 + self._vl_projectile.maximum_time = e.dur + self._rot_axis = e.rot_axis + self._dir = self.object:get_velocity():normalize() self._vl_projectile.extra = nil end + if not self._dir then return end + self._dir = self._dir:rotate_around_axis(self._rot_axis, dtime/3) + local obj = self.object + obj:set_velocity((obj:get_velocity():length() + self._force*dtime) * self._dir) end, vl_projectile.collides_with_solids, @@ -111,6 +120,22 @@ local firework_entity = { vl_projectile.register("vl_fireworks:rocket", firework_entity) +function vl_fireworks.shoot_firework(itemstack, pos) + local meta = itemstack:get_meta() + local rot_axis = vector.new(1,0,0) + rot_axis = rot_axis:rotate_around_axis(vector.new(0,1,0), math.random()*TAU) + vl_projectile.create("vl_fireworks:rocket", { + pos = pos, + dir = vector.new(0,1,0), + velocity = 1 + meta:get_int("vl_fireworks:force")/10, + extra = { + dur = meta:get_float("vl_fireworks:duration"), + force = meta:get_float("vl_fireworks:force"), + rot_axis = rot_axis + } + }) +end + minetest.register_craftitem("vl_fireworks:rocket", { -- TODO use metadata description = description, inventory_image = "vl_fireworks_rocket.png", @@ -128,23 +153,10 @@ minetest.register_craftitem("vl_fireworks:rocket", { -- TODO use metadata end, on_place = function(itemstack, user, pointed_thing) local pos = pointed_thing.above - local meta = itemstack:get_meta() --- pos.y = pos.y + 1 - vl_projectile.create("vl_fireworks:rocket", { - pos = pos, - dir = vector.new(0,1,0), - velocity = 1 + meta:get_int("vl_fireworks:force")/10, - extra = meta:get_float("vl_fireworks:duration") - }) + vl_fireworks.shoot_firework(itemstack, pos) end, _on_dispense = function(dropitem, pos, droppos, dropnode, dropdir) - local meta = itemstack:get_meta() - vl_projectile.create("vl_fireworks:rocket", { - pos = pos, - dir = vector.new(0,1,0), - velocity = 1 + meta:get_int("vl_fireworks:force")/10, - extra = meta:get_float("vl_fireworks:duration") - }) + vl_fireworks.shoot_firework(dropitem, pos) end, _vl_fireworks_std_durs_forces = { {2.2, 10}, {4.5, 20}, {6, 30} }, _vl_fireworks_tt = function(duration) From a65684e8758e80396ca175e841b5f1ab361204da Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Thu, 26 Dec 2024 04:24:43 +0100 Subject: [PATCH 14/25] Fireworks are now craftable --- mods/ITEMS/vl_fireworks/crafting.lua | 43 +++++++++++++++++----------- mods/ITEMS/vl_fireworks/register.lua | 7 +++-- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/mods/ITEMS/vl_fireworks/crafting.lua b/mods/ITEMS/vl_fireworks/crafting.lua index f8b83b17e..60b371a02 100644 --- a/mods/ITEMS/vl_fireworks/crafting.lua +++ b/mods/ITEMS/vl_fireworks/crafting.lua @@ -1,17 +1,28 @@ -minetest.register_craft({ - type = "shapeless", - output = "vl_fireworks:rocket 3", - recipe = {"mcl_core:paper", "mcl_mobitems:gunpowder"}, -}) +local function register_firework_crafts() + local recipe = {"mcl_core:paper"} + for i=1, 3 do + table.insert(recipe, "mcl_mobitems:gunpowder") + minetest.register_craft({ + type = "shapeless", + output = "vl_fireworks:rocket 3", + recipe = recipe, + }) + end +end +register_firework_crafts() -minetest.register_craft({ - type = "shapeless", - output = "vl_fireworks:rocket 3", - recipe = {"mcl_core:paper", "mcl_mobitems:gunpowder", "mcl_mobitems:gunpowder"}, -}) - -minetest.register_craft({ - type = "shapeless", - output = "vl_fireworks:rocket 3", - recipe = {"mcl_core:paper", "mcl_mobitems:gunpowder", "mcl_mobitems:gunpowder", "mcl_mobitems:gunpowder"}, -}) +local function craft_firework(itemstack, player, old_grid) + if itemstack:get_name() ~= "vl_fireworks:rocket" then return end + local gp = 0 + for _, item in pairs(old_grid) do + if item:get_name() == "mcl_mobitems:gunpowder" then gp = gp + 1 end + end + local tbl = vl_fireworks.firework_def._vl_fireworks_std_durs_forces[gp] + local meta = itemstack:get_meta() + meta:set_float("vl_fireworks:duration", tbl[1]) + meta:set_int("vl_fireworks:force", tbl[2]) + tt.reload_itemstack_description(itemstack) + return itemstack +end +core.register_craft_predict(craft_firework) +core.register_on_craft(craft_firework) diff --git a/mods/ITEMS/vl_fireworks/register.lua b/mods/ITEMS/vl_fireworks/register.lua index 21a378744..b19b6b597 100644 --- a/mods/ITEMS/vl_fireworks/register.lua +++ b/mods/ITEMS/vl_fireworks/register.lua @@ -136,7 +136,7 @@ function vl_fireworks.shoot_firework(itemstack, pos) }) end -minetest.register_craftitem("vl_fireworks:rocket", { -- TODO use metadata +local firework_def = { description = description, inventory_image = "vl_fireworks_rocket.png", stack_max = 64, @@ -162,4 +162,7 @@ minetest.register_craftitem("vl_fireworks:rocket", { -- TODO use metadata _vl_fireworks_tt = function(duration) return S("Duration:") .. " " .. duration end, -}) +} +vl_fireworks.firework_def = table.copy(firework_def) + +minetest.register_craftitem("vl_fireworks:rocket", firework_def) From 4254b9311c8874bf9c31724e15217b3d50f43add Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Fri, 27 Dec 2024 00:52:07 +0100 Subject: [PATCH 15/25] Dispenser shoots fireworks where it's looking --- mods/ITEMS/vl_fireworks/register.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/vl_fireworks/register.lua b/mods/ITEMS/vl_fireworks/register.lua index b19b6b597..97cd2a052 100644 --- a/mods/ITEMS/vl_fireworks/register.lua +++ b/mods/ITEMS/vl_fireworks/register.lua @@ -120,13 +120,13 @@ local firework_entity = { vl_projectile.register("vl_fireworks:rocket", firework_entity) -function vl_fireworks.shoot_firework(itemstack, pos) +function vl_fireworks.shoot_firework(itemstack, pos, dir) local meta = itemstack:get_meta() local rot_axis = vector.new(1,0,0) rot_axis = rot_axis:rotate_around_axis(vector.new(0,1,0), math.random()*TAU) vl_projectile.create("vl_fireworks:rocket", { pos = pos, - dir = vector.new(0,1,0), + dir = dir or vector.new(0,1,0), velocity = 1 + meta:get_int("vl_fireworks:force")/10, extra = { dur = meta:get_float("vl_fireworks:duration"), @@ -156,7 +156,7 @@ local firework_def = { vl_fireworks.shoot_firework(itemstack, pos) end, _on_dispense = function(dropitem, pos, droppos, dropnode, dropdir) - vl_fireworks.shoot_firework(dropitem, pos) + vl_fireworks.shoot_firework(dropitem, pos, dropdir) end, _vl_fireworks_std_durs_forces = { {2.2, 10}, {4.5, 20}, {6, 30} }, _vl_fireworks_tt = function(duration) From 67592d13ee8278683022f09001fb30db978b3d9b Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Fri, 27 Dec 2024 01:10:00 +0100 Subject: [PATCH 16/25] Improve firework direction correction math ...to allow shooting them from narrow tunnels --- mods/ITEMS/vl_fireworks/register.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mods/ITEMS/vl_fireworks/register.lua b/mods/ITEMS/vl_fireworks/register.lua index 97cd2a052..dfbc6a6d3 100644 --- a/mods/ITEMS/vl_fireworks/register.lua +++ b/mods/ITEMS/vl_fireworks/register.lua @@ -56,6 +56,9 @@ local firework_entity = { self._vl_projectile.extra = nil end if not self._dir then return end + if self._last_pos and (self._last_pos - self.object:get_pos()):length() < (10*dtime) then + self._rot_axis = -self._rot_axis + end self._dir = self._dir:rotate_around_axis(self._rot_axis, dtime/3) local obj = self.object obj:set_velocity((obj:get_velocity():length() + self._force*dtime) * self._dir) From 30f64eeb1670a0ff248d97c1a2e2c8ee66eb44e7 Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Fri, 27 Dec 2024 02:10:43 +0100 Subject: [PATCH 17/25] Show fireworks properly in creative search ...also fixes potions there, this time for real --- mods/HUD/mcl_inventory/creative.lua | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/mods/HUD/mcl_inventory/creative.lua b/mods/HUD/mcl_inventory/creative.lua index 7504b080b..a2e510d53 100644 --- a/mods/HUD/mcl_inventory/creative.lua +++ b/mods/HUD/mcl_inventory/creative.lua @@ -72,6 +72,8 @@ minetest.register_on_mods_loaded(function() -- Is set to true if it was added in any category besides misc local nonmisc = false + -- Is set to true if it has already been added to the "all" category (special handler) + local all_handled = false if def.groups.building_block then table.insert(inventory_lists["blocks"], name) nonmisc = true @@ -120,8 +122,10 @@ minetest.register_on_mods_loaded(function() meta:set_float("vl_fireworks:duration", tbl[1]) meta:set_int("vl_fireworks:force", tbl[2]) table.insert(inventory_lists["misc"], stack:to_string()) + table.insert(inventory_lists["all"], stack:to_string()) end nonmisc = true + all_handled = true end -- Misc. category is for everything which is not in any other category if not nonmisc then @@ -143,7 +147,9 @@ minetest.register_on_mods_loaded(function() table.insert(inventory_lists["brew"], stack:to_string()) table.insert(inventory_lists["all"], stack:to_string()) end - else + end + + if not all_handled then table.insert(inventory_lists["all"], name) end @@ -200,12 +206,11 @@ local function set_inv_search(filter, player) local inv = minetest.get_inventory({ type = "detached", name = "creative_" .. playername }) local creative_list = {} local lang = minetest.get_player_information(playername).lang_code - for name, def in pairs(minetest.registered_items) do - if (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0) and def.description and - def.description ~= "" then - if filter_item(string.lower(def.name), def.description, lang, filter) then - table.insert(creative_list, name) - end + for _, str in pairs(inventory_lists["all"]) do + local stack = ItemStack(str) + if filter_item(stack:get_name(), minetest.strip_colors(stack:get_description()), lang, filter) + and stack:get_name() ~= "mcl_enchanting:book_enchanted" then + table.insert(creative_list, stack:to_string()) end end for ench, def in pairs(mcl_enchanting.enchantments) do From 9365fb68d3e855b912a9796d80fc857b8dc9707d Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Fri, 27 Dec 2024 02:51:37 +0100 Subject: [PATCH 18/25] Firework static saving improvements --- mods/ITEMS/vl_fireworks/register.lua | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/vl_fireworks/register.lua b/mods/ITEMS/vl_fireworks/register.lua index dfbc6a6d3..4f2af0034 100644 --- a/mods/ITEMS/vl_fireworks/register.lua +++ b/mods/ITEMS/vl_fireworks/register.lua @@ -25,7 +25,11 @@ local firework_entity = { _fire_damage_resistant = true, _save_fields = { - "last_pos", "startpos", "time_in_air", "vl_projectile", "arrow_item"--[[???]], "itemstring", "duration" + "last_pos", "vl_projectile", "dir", "rot_axis", "force" + }, + + _vector_save_fields = { + last_pos = true, dir = true, rot_axis = true, force = true }, _damage=1, -- Damage on impact @@ -85,6 +89,7 @@ local firework_entity = { local field = save_fields[i] out[field] = self["_"..field] end + out.timer = self.timer -- Preserve entity properties out.properties = self.object:get_properties() @@ -103,12 +108,18 @@ local firework_entity = { self.object:set_properties(data.properties) data.properties = nil end + self.timer = data.timer - -- Restore arrow state + -- Restore rocket state local save_fields = self._save_fields + local vecs = self._vector_save_fields for i = 1,#save_fields do local field = save_fields[i] - self["_"..field] = data[field] + local d = data[field] + if type(d) == "table" and vecs[field] then + d = vector.new(d.x, d.y, d.z) + end + self["_"..field] = d end if not self._vl_projectile then From 36b8689bf45f082997b8512b3cc9d8df25d10e98 Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Fri, 27 Dec 2024 03:02:50 +0100 Subject: [PATCH 19/25] Slight vl_fireworks reorganisation --- mods/ITEMS/vl_fireworks/README.txt | 2 +- mods/ITEMS/vl_fireworks/init.lua | 7 ++++--- mods/ITEMS/vl_fireworks/{register.lua => rockets.lua} | 0 mods/ITEMS/vl_fireworks/star.lua | 1 + 4 files changed, 6 insertions(+), 4 deletions(-) rename mods/ITEMS/vl_fireworks/{register.lua => rockets.lua} (100%) create mode 100644 mods/ITEMS/vl_fireworks/star.lua diff --git a/mods/ITEMS/vl_fireworks/README.txt b/mods/ITEMS/vl_fireworks/README.txt index 3202bc137..0d23404f5 100644 --- a/mods/ITEMS/vl_fireworks/README.txt +++ b/mods/ITEMS/vl_fireworks/README.txt @@ -1,6 +1,6 @@ Firework mod for VoxeLibre -by NO11 and and some parts by j45 +by Herowl and teknomunk, based on the old version by NO11 and j45 Sound credits: diff --git a/mods/ITEMS/vl_fireworks/init.lua b/mods/ITEMS/vl_fireworks/init.lua index 612a63419..8c61358f7 100644 --- a/mods/ITEMS/vl_fireworks/init.lua +++ b/mods/ITEMS/vl_fireworks/init.lua @@ -2,12 +2,12 @@ local path = minetest.get_modpath("vl_fireworks") vl_fireworks = {} -function vl_fireworks.generic_particle_explosion(pos) +function vl_fireworks.generic_particle_explosion(pos, size) if pos.object then pos = pos.object:get_pos() end local particle_pattern = math.random(1, 3) local fpitch local type = math.random(1, 2) - local size = math.random(1, 3) + local size = size or math.random(1, 3) local colors = {"red", "yellow", "blue", "green", "white"} local this_colors = {colors[math.random(#colors)], colors[math.random(#colors)], colors[math.random(#colors)]} @@ -189,5 +189,6 @@ function vl_fireworks.generic_particle_explosion(pos) return size end -dofile(path .. "/register.lua") +dofile(path .. "/star.lua") +dofile(path .. "/rockets.lua") dofile(path .. "/crafting.lua") diff --git a/mods/ITEMS/vl_fireworks/register.lua b/mods/ITEMS/vl_fireworks/rockets.lua similarity index 100% rename from mods/ITEMS/vl_fireworks/register.lua rename to mods/ITEMS/vl_fireworks/rockets.lua diff --git a/mods/ITEMS/vl_fireworks/star.lua b/mods/ITEMS/vl_fireworks/star.lua new file mode 100644 index 000000000..e3e7585af --- /dev/null +++ b/mods/ITEMS/vl_fireworks/star.lua @@ -0,0 +1 @@ +local S = minetest.get_translator(minetest.get_current_modname()) From d4ca99f09ea3eccffaa8f6b64418675075aa4fb6 Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Fri, 27 Dec 2024 04:20:01 +0100 Subject: [PATCH 20/25] Added firework stars - empty fireworks now have a simple boom - fireworks with generic stars have a colorful boom --- mods/HELP/mcl_tt/snippets_mcl.lua | 4 ++- mods/HUD/mcl_inventory/creative.lua | 4 +++ mods/ITEMS/mcl_mobitems/init.lua | 3 +- mods/ITEMS/vl_fireworks/crafting.lua | 40 ++++++++++++++++++++--- mods/ITEMS/vl_fireworks/rockets.lua | 47 ++++++++++++++++++--------- mods/ITEMS/vl_fireworks/star.lua | 12 +++++++ textures/vl_fireworks_star.png | Bin 0 -> 241 bytes 7 files changed, 87 insertions(+), 23 deletions(-) create mode 100644 textures/vl_fireworks_star.png diff --git a/mods/HELP/mcl_tt/snippets_mcl.lua b/mods/HELP/mcl_tt/snippets_mcl.lua index 384d590c0..76665f897 100644 --- a/mods/HELP/mcl_tt/snippets_mcl.lua +++ b/mods/HELP/mcl_tt/snippets_mcl.lua @@ -196,7 +196,9 @@ tt.register_snippet(function(itemstring, _, itemstack) local s = "" local meta = itemstack:get_meta() - s = s .. def._vl_fireworks_tt(meta:get_float("vl_fireworks:duration")) + local stars = meta:get("vl_fireworks:stars") or core.serialize({}) + s = s .. def._vl_fireworks_tt(meta:get_float("vl_fireworks:duration"), + core.deserialize(stars)) return s:trim() end) diff --git a/mods/HUD/mcl_inventory/creative.lua b/mods/HUD/mcl_inventory/creative.lua index a2e510d53..5a2a79ce3 100644 --- a/mods/HUD/mcl_inventory/creative.lua +++ b/mods/HUD/mcl_inventory/creative.lua @@ -116,6 +116,7 @@ minetest.register_on_mods_loaded(function() nonmisc = true end if def._vl_fireworks_std_durs_forces then + local generic = core.serialize({{fn="generic"}}) for i, tbl in ipairs(def._vl_fireworks_std_durs_forces) do local stack = ItemStack(name) local meta = stack:get_meta() @@ -123,6 +124,9 @@ minetest.register_on_mods_loaded(function() meta:set_int("vl_fireworks:force", tbl[2]) table.insert(inventory_lists["misc"], stack:to_string()) table.insert(inventory_lists["all"], stack:to_string()) + meta:set_string("vl_fireworks:stars", generic) + table.insert(inventory_lists["misc"], stack:to_string()) + table.insert(inventory_lists["all"], stack:to_string()) end nonmisc = true all_handled = true diff --git a/mods/ITEMS/mcl_mobitems/init.lua b/mods/ITEMS/mcl_mobitems/init.lua index a3155b13c..edf07c7bd 100644 --- a/mods/ITEMS/mcl_mobitems/init.lua +++ b/mods/ITEMS/mcl_mobitems/init.lua @@ -313,8 +313,7 @@ minetest.register_craftitem("mcl_mobitems:nether_star", { _doc_items_longdesc = S("A nether star is dropped when the Wither dies. Place it in an item frame to show the world how hardcore you are! Or just as decoration."), wield_image = "mcl_mobitems_nether_star.png", inventory_image = "mcl_mobitems_nether_star.png", - -- TODO: Reveal item when it's useful - groups = { craftitem = 1, not_in_creative_inventory = 1 }, + groups = { craftitem = 1 }, stack_max = 64, }) diff --git a/mods/ITEMS/vl_fireworks/crafting.lua b/mods/ITEMS/vl_fireworks/crafting.lua index 60b371a02..b18ef6066 100644 --- a/mods/ITEMS/vl_fireworks/crafting.lua +++ b/mods/ITEMS/vl_fireworks/crafting.lua @@ -1,11 +1,27 @@ +-- Firework Star +core.register_craft({ -- temporary + type = "shapeless", + output = "vl_fireworks:firework_star", + recipe = {"mcl_mobitems:gunpowder", "mcl_core:clay_lump"} +}) + +-- Firework Rocket local function register_firework_crafts() - local recipe = {"mcl_core:paper"} + local r1 = {"mcl_core:paper"} + local r2 = table.copy(r1) + table.insert(r2, "vl_fireworks:firework_star") -- TODO replace with a loop or such to allow more stars for i=1, 3 do - table.insert(recipe, "mcl_mobitems:gunpowder") - minetest.register_craft({ + table.insert(r1, "mcl_mobitems:gunpowder") + table.insert(r2, "mcl_mobitems:gunpowder") + core.register_craft({ type = "shapeless", output = "vl_fireworks:rocket 3", - recipe = recipe, + recipe = r1, + }) + core.register_craft({ + type = "shapeless", + output = "vl_fireworks:rocket 3", + recipe = r2, }) end end @@ -13,14 +29,28 @@ register_firework_crafts() local function craft_firework(itemstack, player, old_grid) if itemstack:get_name() ~= "vl_fireworks:rocket" then return end - local gp = 0 + local gp = 0 -- gunpowder + local stars = {} + + -- analyze the recipe used for _, item in pairs(old_grid) do if item:get_name() == "mcl_mobitems:gunpowder" then gp = gp + 1 end + if item:get_name() == "vl_fireworks:firework_star" then + local effect = item:get_meta():get("vl_fireworks:star_effect") + or core.serialize({fn="generic"}) + table.insert(stars, effect) + end end + + -- determine duration and force from the amount of gunpowder used local tbl = vl_fireworks.firework_def._vl_fireworks_std_durs_forces[gp] local meta = itemstack:get_meta() meta:set_float("vl_fireworks:duration", tbl[1]) meta:set_int("vl_fireworks:force", tbl[2]) + + -- write star effects into metadata + meta:set_string("vl_fireworks:stars", core.serialize(stars)) + tt.reload_itemstack_description(itemstack) return itemstack end diff --git a/mods/ITEMS/vl_fireworks/rockets.lua b/mods/ITEMS/vl_fireworks/rockets.lua index 4f2af0034..5dfdcbaf6 100644 --- a/mods/ITEMS/vl_fireworks/rockets.lua +++ b/mods/ITEMS/vl_fireworks/rockets.lua @@ -1,14 +1,19 @@ -local S = minetest.get_translator(minetest.get_current_modname()) +local S = core.get_translator(core.get_current_modname()) local tt_help = S("Flight Duration:") local description = S("Firework Rocket") local TAU = 2*math.pi -local function explode(self, pos) - -- temp code - vl_fireworks.generic_particle_explosion(pos) +local function explode(self, pos, stars) mcl_mobs.mob_class.safe_boom(self, pos, 1) + if not stars then return end + for _, effect in pairs(stars) do + if effect.fn == "generic" then + vl_fireworks.generic_particle_explosion(pos) + end + -- TODO implement other handlers + end end local firework_entity = { @@ -25,7 +30,7 @@ local firework_entity = { _fire_damage_resistant = true, _save_fields = { - "last_pos", "vl_projectile", "dir", "rot_axis", "force" + "last_pos", "vl_projectile", "dir", "rot_axis", "force", "stars" }, _vector_save_fields = { @@ -57,6 +62,7 @@ local firework_entity = { self._vl_projectile.maximum_time = e.dur self._rot_axis = e.rot_axis self._dir = self.object:get_velocity():normalize() + self._stars = e.stars self._vl_projectile.extra = nil end if not self._dir then return end @@ -76,7 +82,7 @@ local firework_entity = { if lua and lua.name == "mobs_mc:rover" then return false end --if (self.object:get_velocity() + object:get_velocity()).length() < 5 then return end - minetest.log("allow punching") + core.log("allow punching") return true end, @@ -94,13 +100,13 @@ local firework_entity = { -- Preserve entity properties out.properties = self.object:get_properties() - return minetest.serialize(out) + return core.serialize(out) end, on_activate = function(self, staticdata, dtime_s) self.object:set_armor_groups({ immortal = 1 }) self._time_in_air = 1.0 - local data = minetest.deserialize(staticdata) + local data = core.deserialize(staticdata) if not data then return end -- Restore entity properties @@ -128,7 +134,7 @@ local firework_entity = { end, _on_remove = function(self) - explode(self, self.object:get_pos()) + explode(self, self.object:get_pos(), self._stars) end, } @@ -138,6 +144,7 @@ function vl_fireworks.shoot_firework(itemstack, pos, dir) local meta = itemstack:get_meta() local rot_axis = vector.new(1,0,0) rot_axis = rot_axis:rotate_around_axis(vector.new(0,1,0), math.random()*TAU) + local stars = meta:get("vl_fireworks:stars") or core.serialize({}) vl_projectile.create("vl_fireworks:rocket", { pos = pos, dir = dir or vector.new(0,1,0), @@ -145,7 +152,8 @@ function vl_fireworks.shoot_firework(itemstack, pos, dir) extra = { dur = meta:get_float("vl_fireworks:duration"), force = meta:get_float("vl_fireworks:force"), - rot_axis = rot_axis + rot_axis = rot_axis, + stars = core.deserialize(stars) } }) end @@ -158,10 +166,10 @@ local firework_def = { local elytra = mcl_playerplus.elytra[user] if elytra.active and elytra.rocketing <= 0 then elytra.rocketing = meta:get_float("vl_fireworks:duration") - if not minetest.is_creative_enabled(user:get_player_name()) then + if not core.is_creative_enabled(user:get_player_name()) then itemstack:take_item() end - minetest.sound_play("vl_fireworks_rocket", {pos = user:get_pos()}) + core.sound_play("vl_fireworks_rocket", {pos = user:get_pos()}) end return itemstack end, @@ -173,10 +181,19 @@ local firework_def = { vl_fireworks.shoot_firework(dropitem, pos, dropdir) end, _vl_fireworks_std_durs_forces = { {2.2, 10}, {4.5, 20}, {6, 30} }, - _vl_fireworks_tt = function(duration) - return S("Duration:") .. " " .. duration + _vl_fireworks_tt = function(duration, stars) + local retval = S("Duration:") .. " " .. duration + + for _, effect in pairs(stars) do + retval = retval .. "\n\n" + if effect.fn == "generic" then + retval = retval .. S("Generic Firework Star") + end + end + + return retval end, } vl_fireworks.firework_def = table.copy(firework_def) -minetest.register_craftitem("vl_fireworks:rocket", firework_def) +core.register_craftitem("vl_fireworks:rocket", firework_def) diff --git a/mods/ITEMS/vl_fireworks/star.lua b/mods/ITEMS/vl_fireworks/star.lua index e3e7585af..4e76fe598 100644 --- a/mods/ITEMS/vl_fireworks/star.lua +++ b/mods/ITEMS/vl_fireworks/star.lua @@ -1 +1,13 @@ local S = minetest.get_translator(minetest.get_current_modname()) + +minetest.register_craftitem("vl_fireworks:firework_star", { + description = S("Firework Star"), + _doc_items_longdesc = S("A firework star is the key component of a firework rocket which is responsible for the visible explosion."), + wield_image = "vl_fireworks_star.png", + inventory_image = "vl_fireworks_star.png", + groups = { craftitem = 1 }, + stack_max = 64, +}) + +-- TODO tt snippets +-- TODO image handlers diff --git a/textures/vl_fireworks_star.png b/textures/vl_fireworks_star.png new file mode 100644 index 0000000000000000000000000000000000000000..cb4b03d851a5006d9d6e401de7c79d97dd12f80a GIT binary patch literal 241 zcmViO+#`f}z{~#KK zL7HK-v6k|GoGyV$fHZ?_#bpRyufP<-G{b0^H$X0slN80&jqd!uzCJL9xd0RvAk8?v z0TTe(1kwP~4D$wh7=T=W(*R_}*a8sd61>p|QUKG0>~|22)pl&I(AL&Q@iR;_QPBv) rFbz2UjSG;HlnLe|LV19q91Oz%?hr+a2qV!|00000NkvXXu0mjfC`x4) literal 0 HcmV?d00001 From 954ba26bb6b289d9f31ee2d0623c9c6aa9070f58 Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Fri, 27 Dec 2024 04:52:43 +0100 Subject: [PATCH 21/25] Predefined firework explosion size --- mods/HELP/mcl_tt/snippets_mcl.lua | 16 ++++++++++++++ mods/ITEMS/vl_fireworks/crafting.lua | 31 ++++++++++++++++++++++++++++ mods/ITEMS/vl_fireworks/rockets.lua | 9 ++++---- mods/ITEMS/vl_fireworks/star.lua | 14 ++++++++++++- 4 files changed, 64 insertions(+), 6 deletions(-) diff --git a/mods/HELP/mcl_tt/snippets_mcl.lua b/mods/HELP/mcl_tt/snippets_mcl.lua index 76665f897..bd50c095a 100644 --- a/mods/HELP/mcl_tt/snippets_mcl.lua +++ b/mods/HELP/mcl_tt/snippets_mcl.lua @@ -202,3 +202,19 @@ tt.register_snippet(function(itemstring, _, itemstack) return s:trim() end) +tt.register_snippet(function(itemstring, _, itemstack) + if not itemstack then return end + local def = itemstack:get_definition() + if not def then return end + + if not def._vl_fireworks_star then return end + + local s = "" + local meta = itemstack:get_meta() + local effect = meta:get("vl_fireworks:star_effect") or core.serialize({fn="generic"}) + if effect then + s = vl_fireworks.star_tt(core.deserialize(effect)) + end + + return s +end) diff --git a/mods/ITEMS/vl_fireworks/crafting.lua b/mods/ITEMS/vl_fireworks/crafting.lua index b18ef6066..684788543 100644 --- a/mods/ITEMS/vl_fireworks/crafting.lua +++ b/mods/ITEMS/vl_fireworks/crafting.lua @@ -4,6 +4,37 @@ core.register_craft({ -- temporary output = "vl_fireworks:firework_star", recipe = {"mcl_mobitems:gunpowder", "mcl_core:clay_lump"} }) +core.register_craft({ -- temporary + type = "shapeless", + output = "vl_fireworks:firework_star", + recipe = {"mcl_mobitems:gunpowder", "mcl_core:clay_lump", "mcl_fire:fire_charge"} +}) +core.register_craft({ -- temporary + type = "shapeless", + output = "vl_fireworks:firework_star", + recipe = {"mcl_mobitems:gunpowder", "mcl_core:clay_lump", "mcl_end:crystal"} +}) + +local function craft_star(itemstack, player, old_grid) + if itemstack:get_name() ~= "vl_fireworks:firework_star" then return end + local size = 1 + + -- analyze the recipe used + for _, item in pairs(old_grid) do + if item:get_name() == "mcl_fire:fire_charge" then size = 2 end + if item:get_name() == "mcl_end:crystal" then size = 3 end + end + + local effect = { + fn = "generic", + size = size + } + itemstack:get_meta():set_string("vl_fireworks:star_effect", core.serialize(effect)) + tt.reload_itemstack_description(itemstack) + return itemstack +end +core.register_craft_predict(craft_star) +core.register_on_craft(craft_star) -- Firework Rocket local function register_firework_crafts() diff --git a/mods/ITEMS/vl_fireworks/rockets.lua b/mods/ITEMS/vl_fireworks/rockets.lua index 5dfdcbaf6..d78c74f8d 100644 --- a/mods/ITEMS/vl_fireworks/rockets.lua +++ b/mods/ITEMS/vl_fireworks/rockets.lua @@ -9,8 +9,9 @@ local function explode(self, pos, stars) mcl_mobs.mob_class.safe_boom(self, pos, 1) if not stars then return end for _, effect in pairs(stars) do + if type(effect) == "string" then effect = core.deserialize(effect) end if effect.fn == "generic" then - vl_fireworks.generic_particle_explosion(pos) + vl_fireworks.generic_particle_explosion(pos, effect.size or 1) end -- TODO implement other handlers end @@ -185,10 +186,8 @@ local firework_def = { local retval = S("Duration:") .. " " .. duration for _, effect in pairs(stars) do - retval = retval .. "\n\n" - if effect.fn == "generic" then - retval = retval .. S("Generic Firework Star") - end + if type(effect) == "string" then effect = core.deserialize(effect) end + retval = retval .. "\n\n" .. vl_fireworks.star_tt(effect) end return retval diff --git a/mods/ITEMS/vl_fireworks/star.lua b/mods/ITEMS/vl_fireworks/star.lua index 4e76fe598..7d86d6948 100644 --- a/mods/ITEMS/vl_fireworks/star.lua +++ b/mods/ITEMS/vl_fireworks/star.lua @@ -7,7 +7,19 @@ minetest.register_craftitem("vl_fireworks:firework_star", { inventory_image = "vl_fireworks_star.png", groups = { craftitem = 1 }, stack_max = 64, + + _vl_fireworks_star = true }) --- TODO tt snippets +function vl_fireworks.star_tt(effect) + local s = "" + if effect.fn == "generic" then + s = S("Generic Firework Star") + end + if effect.size then + s = s .. "\nSize: " .. effect.size + end + return s:trim() +end + -- TODO image handlers From 8e77fece502f395d77f2dd6ab1e8fe750e179bb1 Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Fri, 27 Dec 2024 15:27:08 +0100 Subject: [PATCH 22/25] Review commemts implemented --- mods/ITEMS/vl_fireworks/crafting.lua | 10 ++++++++-- mods/ITEMS/vl_fireworks/init.lua | 4 +++- mods/ITEMS/vl_fireworks/rockets.lua | 5 ++--- mods/ITEMS/vl_fireworks/star.lua | 6 ++---- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/mods/ITEMS/vl_fireworks/crafting.lua b/mods/ITEMS/vl_fireworks/crafting.lua index 684788543..9f97cb07b 100644 --- a/mods/ITEMS/vl_fireworks/crafting.lua +++ b/mods/ITEMS/vl_fireworks/crafting.lua @@ -21,8 +21,14 @@ local function craft_star(itemstack, player, old_grid) -- analyze the recipe used for _, item in pairs(old_grid) do - if item:get_name() == "mcl_fire:fire_charge" then size = 2 end - if item:get_name() == "mcl_end:crystal" then size = 3 end + if item:get_name() == "mcl_fire:fire_charge" then + size = 2 + break + end + if item:get_name() == "mcl_end:crystal" then + size = 3 + break + end end local effect = { diff --git a/mods/ITEMS/vl_fireworks/init.lua b/mods/ITEMS/vl_fireworks/init.lua index 8c61358f7..c5a5c2bbb 100644 --- a/mods/ITEMS/vl_fireworks/init.lua +++ b/mods/ITEMS/vl_fireworks/init.lua @@ -2,13 +2,15 @@ local path = minetest.get_modpath("vl_fireworks") vl_fireworks = {} +local colors = {"red", "yellow", "blue", "green", "white"} + + function vl_fireworks.generic_particle_explosion(pos, size) if pos.object then pos = pos.object:get_pos() end local particle_pattern = math.random(1, 3) local fpitch local type = math.random(1, 2) local size = size or math.random(1, 3) - local colors = {"red", "yellow", "blue", "green", "white"} local this_colors = {colors[math.random(#colors)], colors[math.random(#colors)], colors[math.random(#colors)]} if size == 1 then diff --git a/mods/ITEMS/vl_fireworks/rockets.lua b/mods/ITEMS/vl_fireworks/rockets.lua index d78c74f8d..a02788512 100644 --- a/mods/ITEMS/vl_fireworks/rockets.lua +++ b/mods/ITEMS/vl_fireworks/rockets.lua @@ -81,10 +81,9 @@ local firework_entity = { allow_punching = function(self, entity_def, projectile_def, object) local lua = object:get_luaentity() if lua and lua.name == "mobs_mc:rover" then return false end + -- TODO at some point make it so impact depends on collision speed? (see next line) --if (self.object:get_velocity() + object:get_velocity()).length() < 5 then return end - core.log("allow punching") - return true end, }, @@ -183,7 +182,7 @@ local firework_def = { end, _vl_fireworks_std_durs_forces = { {2.2, 10}, {4.5, 20}, {6, 30} }, _vl_fireworks_tt = function(duration, stars) - local retval = S("Duration:") .. " " .. duration + local retval = tt_help .. " " .. duration for _, effect in pairs(stars) do if type(effect) == "string" then effect = core.deserialize(effect) end diff --git a/mods/ITEMS/vl_fireworks/star.lua b/mods/ITEMS/vl_fireworks/star.lua index 7d86d6948..f60fceb0a 100644 --- a/mods/ITEMS/vl_fireworks/star.lua +++ b/mods/ITEMS/vl_fireworks/star.lua @@ -5,10 +5,8 @@ minetest.register_craftitem("vl_fireworks:firework_star", { _doc_items_longdesc = S("A firework star is the key component of a firework rocket which is responsible for the visible explosion."), wield_image = "vl_fireworks_star.png", inventory_image = "vl_fireworks_star.png", - groups = { craftitem = 1 }, + groups = { craftitem = 1, _vl_fireworks_star = 1 }, stack_max = 64, - - _vl_fireworks_star = true }) function vl_fireworks.star_tt(effect) @@ -17,7 +15,7 @@ function vl_fireworks.star_tt(effect) s = S("Generic Firework Star") end if effect.size then - s = s .. "\nSize: " .. effect.size + s = s .. "\n" .. S("Size:") .. " " .. effect.size end return s:trim() end From f8f30b73113477e8f8256927226cb204df654e8f Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Sat, 28 Dec 2024 23:24:40 +0100 Subject: [PATCH 23/25] Firework rockets are no longer infinite in survival --- mods/ITEMS/vl_fireworks/rockets.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mods/ITEMS/vl_fireworks/rockets.lua b/mods/ITEMS/vl_fireworks/rockets.lua index a02788512..f0e6c897d 100644 --- a/mods/ITEMS/vl_fireworks/rockets.lua +++ b/mods/ITEMS/vl_fireworks/rockets.lua @@ -176,6 +176,10 @@ local firework_def = { on_place = function(itemstack, user, pointed_thing) local pos = pointed_thing.above vl_fireworks.shoot_firework(itemstack, pos) + if mcl_gamemode.get_gamemode(user) ~= "creative" then + itemstack:take_item() + return itemstack + end end, _on_dispense = function(dropitem, pos, droppos, dropnode, dropdir) vl_fireworks.shoot_firework(dropitem, pos, dropdir) From c9bc8ecbd2500d29e2ee7a0a9e9b2e12da9b4c6d Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Sun, 29 Dec 2024 05:07:01 +0100 Subject: [PATCH 24/25] Fixed firework star description --- mods/HELP/mcl_tt/snippets_mcl.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/HELP/mcl_tt/snippets_mcl.lua b/mods/HELP/mcl_tt/snippets_mcl.lua index bd50c095a..e4b5cf867 100644 --- a/mods/HELP/mcl_tt/snippets_mcl.lua +++ b/mods/HELP/mcl_tt/snippets_mcl.lua @@ -207,7 +207,7 @@ tt.register_snippet(function(itemstring, _, itemstack) local def = itemstack:get_definition() if not def then return end - if not def._vl_fireworks_star then return end + if not def.groups._vl_fireworks_star or def.groups._vl_fireworks_star == 0 then return end local s = "" local meta = itemstack:get_meta() From 8f33a0678e3cc9bbf4dbb5c8767c77724c9592e3 Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Sun, 29 Dec 2024 08:07:54 +0100 Subject: [PATCH 25/25] Renamed the group --- mods/HELP/mcl_tt/snippets_mcl.lua | 2 +- mods/ITEMS/vl_fireworks/star.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/HELP/mcl_tt/snippets_mcl.lua b/mods/HELP/mcl_tt/snippets_mcl.lua index e4b5cf867..d03ee5f5f 100644 --- a/mods/HELP/mcl_tt/snippets_mcl.lua +++ b/mods/HELP/mcl_tt/snippets_mcl.lua @@ -207,7 +207,7 @@ tt.register_snippet(function(itemstring, _, itemstack) local def = itemstack:get_definition() if not def then return end - if not def.groups._vl_fireworks_star or def.groups._vl_fireworks_star == 0 then return end + if not def.groups.firework_star or def.groups.firework_star == 0 then return end local s = "" local meta = itemstack:get_meta() diff --git a/mods/ITEMS/vl_fireworks/star.lua b/mods/ITEMS/vl_fireworks/star.lua index f60fceb0a..339ec491d 100644 --- a/mods/ITEMS/vl_fireworks/star.lua +++ b/mods/ITEMS/vl_fireworks/star.lua @@ -5,7 +5,7 @@ minetest.register_craftitem("vl_fireworks:firework_star", { _doc_items_longdesc = S("A firework star is the key component of a firework rocket which is responsible for the visible explosion."), wield_image = "vl_fireworks_star.png", inventory_image = "vl_fireworks_star.png", - groups = { craftitem = 1, _vl_fireworks_star = 1 }, + groups = { craftitem = 1, firework_star = 1 }, stack_max = 64, })