diff --git a/CHANGELOG.md b/CHANGELOG.md index fb0aae3..9dd30ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ I should just start giving updates a version number to avoid naming updates. - Added various new sounds - Give Fire an animated texture - Added a Sky Dimension for people using `floatlands` mapgen setting in v7 +- Added Fireworks! ## [Oct 20th - Nov 2nd] Update: The Something Update diff --git a/mods/CORE/pyutest/util.lua b/mods/CORE/pyutest/util.lua index fee78ae..bd7feae 100644 --- a/mods/CORE/pyutest/util.lua +++ b/mods/CORE/pyutest/util.lua @@ -303,3 +303,11 @@ function PyuTest.get_inventory_drops(pos, inventory, drops) end end end + +PyuTest.drop_item = function (pos, name) + local o = minetest.add_item(pos, name) + + if o then + o:add_velocity(vector.new(math.random(-2, 2), 5, math.random(-2, 2))) + end +end diff --git a/mods/ENTITIES/pyutest_entities/api.lua b/mods/ENTITIES/pyutest_entities/api.lua index 739da48..9dd9c88 100644 --- a/mods/ENTITIES/pyutest_entities/api.lua +++ b/mods/ENTITIES/pyutest_entities/api.lua @@ -259,11 +259,7 @@ PyuTest.make_mob = function (name, properties, options) local pos = self.object:get_pos() for _, v in pairs(self.options.drops) do - local o = minetest.add_item(pos, v) - - if o then - o:add_velocity(vector.new(math.random(-2, 2), 5, math.random(-2, 2))) - end + PyuTest.drop_item(pos, v) end end }, {__index = class})) diff --git a/mods/ENTITIES/pyutest_fireworks/init.lua b/mods/ENTITIES/pyutest_fireworks/init.lua new file mode 100644 index 0000000..09d8ed9 --- /dev/null +++ b/mods/ENTITIES/pyutest_fireworks/init.lua @@ -0,0 +1,84 @@ +minetest.register_entity("pyutest_fireworks:firework", { + initial_properties = { + visual = "upright_sprite", + textures = {"pyutest-firework.png", "pyutest-firework.png"}, + physical = true + }, + + on_activate = function (self) + self.object:set_velocity(vector.new(0, 10, 0)) + end, + + on_step = function (self, dtime) + local vel = self.object:get_velocity() + if vel.y < 0 then + self:explode() + self.object:remove() + end + + vel.y = vel.y - (2 * dtime) + self.object:set_velocity(vel) + self:trail() + end, + + trail = function (self) + local pos = self.object:get_pos() + + minetest.add_particle({ + pos = pos, + size = 2, + expirationtime = 0.2, + glow = minetest.LIGHT_MAX, + vertical = true, + texture = "pyutest-firework-blast.png" + }) + end, + + explode = function (self) + local color = { + r = math.random(50, 255), + g = math.random(50, 255), + b = math.random(50, 255), + } + local texture = string.format("pyutest-firework-blast.png^[colorize:%s", minetest.colorspec_to_colorstring(color)) + + local pos = self.object:get_pos() + + minetest.add_particlespawner({ + amount = math.random(20, 40), + time = 1.8, + minexptime = 0.4, + maxexptime = 1.4, + minsize = 2, + maxsize = 2, + vertical = false, + glow = minetest.LIGHT_MAX, + + collisiondetection = false, + texture = texture, + minpos = pos, + maxpos = pos, + minvel = vector.new(-6, -6, -6), + maxvel = vector.new( 6, 6, 6), + }) + + minetest.sound_play({ + name = "block_break", + gain = 3, + }, { + pos = pos + }) + end +}) + +PyuTest.make_item("pyutest_fireworks:firework", "Firework", {}, "pyutest-firework.png", { + on_place = function (itemstack, placer, pointed_thing) + if pointed_thing.type == "node" then + local pos = pointed_thing.above + minetest.add_entity(pos, "pyutest_fireworks:firework") + itemstack:take_item() + end + + return itemstack + end +}) diff --git a/mods/ENTITIES/pyutest_fireworks/mod.conf b/mods/ENTITIES/pyutest_fireworks/mod.conf new file mode 100644 index 0000000..15c0bdd --- /dev/null +++ b/mods/ENTITIES/pyutest_fireworks/mod.conf @@ -0,0 +1 @@ +depends = pyutest_tools diff --git a/mods/ITEMS/pyutest_grass/init.lua b/mods/ITEMS/pyutest_grass/init.lua index 6177a5b..bb583f5 100644 --- a/mods/ITEMS/pyutest_grass/init.lua +++ b/mods/ITEMS/pyutest_grass/init.lua @@ -27,6 +27,22 @@ PyuTest.make_grass = function (name, desc, groups, color, ttex, stex, dtex, econ }, type = "shapeless" }) + + minetest.register_decoration({ + deco_type = "simple", + place_on = {name.."_block"}, + sidelen = 16, + fill_ratio = 0.048, + decoration = name.."_plant" + }) + + minetest.register_decoration({ + deco_type = "simple", + place_on = {name.."_block"}, + sidelen = 16, + fill_ratio = 0.022, + decoration = name.."_fern" + }) end PyuTest.make_grass("pyutest_grass:grass", "Grass", { diff --git a/textures/pyutest-firework-blast.png b/textures/pyutest-firework-blast.png new file mode 100644 index 0000000..ba9b40d Binary files /dev/null and b/textures/pyutest-firework-blast.png differ diff --git a/textures/pyutest-firework.png b/textures/pyutest-firework.png new file mode 100644 index 0000000..20d967a Binary files /dev/null and b/textures/pyutest-firework.png differ