From 98eb370326f8e7ff7caeb2cbb95a25df275ee4c7 Mon Sep 17 00:00:00 2001 From: IamPyu Date: Fri, 15 Nov 2024 18:21:17 -0600 Subject: [PATCH] Improve Fireworks and Crates --- CHANGELOG.md | 1 + mods/ENTITIES/pyutest_fireworks/init.lua | 51 +++++++++++++++------- mods/ITEMS/pyutest_blocks/special.lua | 13 +++--- mods/ITEMS/pyutest_grass/init.lua | 52 ++++++++++++----------- mods/PLAYER/pyutest_inventory/init.lua | 4 +- textures/pyutest-firework-trail1.png | Bin 0 -> 84 bytes textures/pyutest-firework-trail2.png | Bin 0 -> 89 bytes 7 files changed, 70 insertions(+), 51 deletions(-) create mode 100644 textures/pyutest-firework-trail1.png create mode 100644 textures/pyutest-firework-trail2.png diff --git a/CHANGELOG.md b/CHANGELOG.md index d0f8435..e429b0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ I should just start giving updates a version number to avoid naming updates. - Grass Plants and Ferns now require Shears to be obtained - Added Paper - Added various new colored blocks variants (How will I make flowers for all of these?) +- Crates now drop what's contained inside of them instead of not allowing the player to destroy it. ## [Oct 20th - Nov 2nd] Update: The Something Update diff --git a/mods/ENTITIES/pyutest_fireworks/init.lua b/mods/ENTITIES/pyutest_fireworks/init.lua index ce7bf7e..8c57dd8 100644 --- a/mods/ENTITIES/pyutest_fireworks/init.lua +++ b/mods/ENTITIES/pyutest_fireworks/init.lua @@ -1,16 +1,16 @@ minetest.register_entity("pyutest_fireworks:firework", { initial_properties = { visual = "upright_sprite", - textures = {"pyutest-firework.png", "pyutest-firework.png"}, + textures = { "pyutest-firework.png", "pyutest-firework.png" }, physical = true, glow = minetest.LIGHT_MAX }, - on_activate = function (self) + on_activate = function(self) self.object:set_velocity(vector.new(0, 10, 0)) end, - on_step = function (self, dtime) + on_step = function(self, dtime) local vel = self.object:get_velocity() if vel.y < 0 then self:explode() @@ -23,20 +23,39 @@ minetest.register_entity("pyutest_fireworks:firework", { self:trail() end, - trail = function (self) - local pos = self.object:get_pos() - vector.new(0, .5, 0) + trail = function(self) + local pos = self.object:get_pos() - vector.new(0, 1, 0) - minetest.add_particle({ - pos = pos, - size = 1.2, - expirationtime = 0.6, - glow = minetest.LIGHT_MAX, - vertical = true, - texture = "pyutest-firework-blast.png" - }) + local velocity = vector.new(math.random(-1, 1), 0, math.random(-1, 1)) + + if math.random(1, 2) == 1 then + minetest.add_particle({ + pos = pos, + size = 1.2, + expirationtime = 0.6, + glow = minetest.LIGHT_MAX, + vertical = true, + velocity = velocity, + collisiondetection = true, + collision_removal = true, + texture = "pyutest-firework-trail1.png" + }) + else + minetest.add_particle({ + pos = pos, + size = 1.2, + expirationtime = 0.6, + glow = minetest.LIGHT_MAX, + vertical = true, + velocity = velocity, + collisiondetection = true, + collision_removal = true, + texture = "pyutest-firework-trail2.png" + }) + end end, - explode = function (self) + explode = function(self) local color = { r = math.random(50, 255), g = math.random(50, 255), @@ -61,7 +80,7 @@ minetest.register_entity("pyutest_fireworks:firework", { minpos = pos, maxpos = pos, minvel = vector.new(-6, -6, -6), - maxvel = vector.new( 6, 6, 6), + maxvel = vector.new(6, 6, 6), }) minetest.sound_play({ @@ -74,7 +93,7 @@ minetest.register_entity("pyutest_fireworks:firework", { }) PyuTest.make_item("pyutest_fireworks:firework", "Firework", {}, "pyutest-firework.png", { - on_place = function (itemstack, placer, pointed_thing) + 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") diff --git a/mods/ITEMS/pyutest_blocks/special.lua b/mods/ITEMS/pyutest_blocks/special.lua index 97695bc..680653b 100644 --- a/mods/ITEMS/pyutest_blocks/special.lua +++ b/mods/ITEMS/pyutest_blocks/special.lua @@ -125,16 +125,13 @@ PyuTest.make_node("pyutest_blocks:crate", "Crate", { inventory:set_size("main", 8 * 4) end, - can_dig = function(pos, player) - local meta = minetest.get_meta(pos) - local inventory = meta:get_inventory() - local empty = inventory:is_empty("main") + on_destruct = function (pos) + local drops = {} + PyuTest.get_inventory_drops(pos, "main", drops) - if not empty then - minetest.chat_send_player(player:get_player_name(), "Cannot destroy crate, it's not empty!") + for _, v in pairs(drops) do + minetest.add_item(pos, v) end - - return empty end, on_rightclick = function(pos, node, clicker) diff --git a/mods/ITEMS/pyutest_grass/init.lua b/mods/ITEMS/pyutest_grass/init.lua index dca41a4..5fa7acd 100644 --- a/mods/ITEMS/pyutest_grass/init.lua +++ b/mods/ITEMS/pyutest_grass/init.lua @@ -1,14 +1,14 @@ -PyuTest.make_grass = function (name, desc, groups, color, ttex, stex, dtex, econf) - local _ttex = {name = ttex or "pyutest-grass-top.png", color = color} - local _stex = {name = stex or "pyutest-grass-side.png", color = color} - local _dtex = {_ttex, dtex or "pyutest-dirt.png"} +PyuTest.make_grass = function(name, desc, groups, color, dont_make_flora, ttex, stex, dtex, econf) + local _ttex = { name = ttex or "pyutest-grass-top.png", color = color } + local _stex = { name = stex or "pyutest-grass-side.png", color = color } + local _dtex = { _ttex, dtex or "pyutest-dirt.png" } PyuTest.make_building_blocks(name, desc, _dtex, nil, PyuTest.util.tableconcat(groups or {}, { ground = 1, grass = 1, dirt = 1, }), { - overlay_tiles = {"", "", _stex} + overlay_tiles = { "", "", _stex } }) local function make_drops(name) @@ -16,48 +16,50 @@ PyuTest.make_grass = function (name, desc, groups, color, ttex, stex, dtex, econ max_items = 1, items = { { - tool_groups = { - "shears" - }, - items = {name} + tool_groups = { + "shears" + }, + items = { name } } } } end - PyuTest.make_flower(name.."_plant", desc .. " Plant", "pyutest-grass-plant.png", nil, false, nil, { - color = color, - drop = make_drops(name.."_plant") - }) + if dont_make_flora ~= true then + PyuTest.make_flower(name .. "_plant", desc .. " Plant", "pyutest-grass-plant.png", nil, false, nil, { + color = color, + drop = make_drops(name .. "_plant") + }) - PyuTest.make_flower(name.."_fern", desc .. " Fern", "pyutest-fern.png", nil, false, nil, { - color = color, - drop = make_drops(name.."_fern") - }) + PyuTest.make_flower(name .. "_fern", desc .. " Fern", "pyutest-fern.png", nil, false, nil, { + color = color, + drop = make_drops(name .. "_fern") + }) + end - minetest.override_item(name.."_block", econf or {}) + minetest.override_item(name .. "_block", econf or {}) minetest.register_craft({ - output = name.."_block 2", + output = name .. "_block 2", recipe = { - name.."_block", "pyutest_blocks:dirt_block" + name .. "_block", "pyutest_blocks:dirt_block" }, type = "shapeless" }) minetest.register_decoration({ deco_type = "simple", - place_on = {name.."_block"}, + place_on = { name .. "_block" }, sidelen = 16, fill_ratio = 0.048, - decoration = name.."_plant" + decoration = name .. "_plant" }) minetest.register_decoration({ deco_type = "simple", - place_on = {name.."_block"}, + place_on = { name .. "_block" }, sidelen = 16, fill_ratio = 0.022, - decoration = name.."_fern" + decoration = name .. "_fern" }) end @@ -101,7 +103,7 @@ PyuTest.make_grass("pyutest_grass:snowy_grass", "Snowy Grass", { PyuTest.make_grass("pyutest_grass:dirt_path", "Dirt Path", { crumbly = PyuTest.BLOCK_FAST, acid_vulnerable = 1, -}, "#d9a066", nil, nil, nil, { +}, "#d9a066", true, nil, nil, nil, { drawtype = "nodebox", node_box = PyuTest.NODE_BOXES.SLIGHTLY_SMALLER, collision_box = PyuTest.NODE_BOXES.SLIGHTLY_SMALLER, diff --git a/mods/PLAYER/pyutest_inventory/init.lua b/mods/PLAYER/pyutest_inventory/init.lua index cedc603..7be16c1 100644 --- a/mods/PLAYER/pyutest_inventory/init.lua +++ b/mods/PLAYER/pyutest_inventory/init.lua @@ -42,8 +42,8 @@ unified_inventory.register_category("pyutest_inventory:minerals", { }) unified_inventory.register_category("pyutest_inventory:colored", { - symbol = "pyutest_wool:yellow_wool_block", - label = "Colored Blocks", + symbol = "pyutest_wool:red_wool_block", + label = "Colored Items", index = 7, items = get_items_from_group("colored") }) diff --git a/textures/pyutest-firework-trail1.png b/textures/pyutest-firework-trail1.png new file mode 100644 index 0000000000000000000000000000000000000000..98c3eeefff2e50c559af0caecd347914536ada59 GIT binary patch literal 84 zcmeAS@N?(olHy`uVBq!ia0vp^%plCc1|-8Yw(bW~(w;7kAsjQ4D?UFvTh9gr5@$dB f|6k9+9LdH|^gx)C<GAsjPpPZ;tt7zi*MuKu%< n?QrSuvqmeL!neMC^no#NpU^I)>6)*BY8gCT{an^LB{Ts5g?1UU literal 0 HcmV?d00001