From a6286169b3f1441c3e1cf1f0425e6fb360bf19ce Mon Sep 17 00:00:00 2001 From: IamPyu Date: Tue, 17 Dec 2024 17:46:54 -0600 Subject: [PATCH] Snowballs are now throwable, and added extender electricity component --- CHANGELOG.md | 2 + mods/ENTITIES/pyutest_mobs/snowman.lua | 14 +------ mods/ENTITIES/pyutest_projectiles/init.lua | 10 +---- .../projectiles/snowball.lua | 39 ++++++++++++++++++ mods/ITEMS/pyutest_crafts/etc.lua | 8 ++++ .../components/extender.lua | 11 +++++ mods/ITEMS/pyutest_magic/init.lua | 2 +- mods/ITEMS/pyutest_tools/items.lua | 9 +++- textures/pyutest-snowball-particle.png | Bin 0 -> 82 bytes 9 files changed, 71 insertions(+), 24 deletions(-) create mode 100644 mods/ENTITIES/pyutest_projectiles/projectiles/snowball.lua create mode 100644 mods/ITEMS/pyutest_electricity/components/extender.lua create mode 100644 textures/pyutest-snowball-particle.png diff --git a/CHANGELOG.md b/CHANGELOG.md index c314674..80fd6d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ Notable Game Changes: - Dispenser - Note Block - Delayer + - Extender - Re-added sprinting! - Added Magic Wands - Added Golden Apples and Spellbooks of Healing @@ -70,6 +71,7 @@ Other Game Changes: - New Heater Device recipe - Added Sofas - Removed Spellbooks of Fire +- Snowballs are now throwable Code Changes: diff --git a/mods/ENTITIES/pyutest_mobs/snowman.lua b/mods/ENTITIES/pyutest_mobs/snowman.lua index c42fd62..cbe5f96 100644 --- a/mods/ENTITIES/pyutest_mobs/snowman.lua +++ b/mods/ENTITIES/pyutest_mobs/snowman.lua @@ -9,7 +9,7 @@ mobs:register_arrow("pyutest_mobs:arrow_snowball", { visual_size = { x = 1, y = 1 }, textures = { "pyutest-snowball.png" }, hit_node = function(self, pos) - PyuTest.create_explosion(pos, 1, false, 9, { self.object }) + -- PyuTest.create_explosion(pos, 1, false, 9, { self.object }) end, hit_player = snowball_hit_player, hit_mob = snowball_hit_player, @@ -75,15 +75,3 @@ mobs:register_mob("pyutest_mobs:snowman", { PyuTest.create_boss_egg("pyutest_mobs:snowman", "Snowman Spawn Egg", "pyutest-egg.png^[multiply:skyblue", 0, nil, "pyutest_blocks:snow_block") - -mobs:spawn({ - name = "pyutest_mobs:snowman", - nodes = { "group:ground", "group:ice" }, - interval = 3, - chance = 4, - active_object_count = 3, - min_light = 0, - max_light = 15, - max_height = PyuTest.IceWorld.y_max, - min_height = PyuTest.IceWorld.y_min -}) diff --git a/mods/ENTITIES/pyutest_projectiles/init.lua b/mods/ENTITIES/pyutest_projectiles/init.lua index f246f46..565162d 100644 --- a/mods/ENTITIES/pyutest_projectiles/init.lua +++ b/mods/ENTITIES/pyutest_projectiles/init.lua @@ -1,17 +1,13 @@ local modpath = core.get_modpath(core.get_current_modname()) dofile(modpath .. "/api.lua") +dofile(modpath .. "/projectiles/snowball.lua") PyuTest.make_projectile("pyutest_projectiles:fireball", { visual = "sprite", visual_size = {x = 1.4, y = 1.4}, textures = { "pyutest-fireball.png", - "pyutest-fireball.png", - "pyutest-fireball.png", - "pyutest-fireball.png", - "pyutest-fireball.png", - "pyutest-fireball.png", } }, { _slowdown = false @@ -30,10 +26,6 @@ PyuTest.make_projectile("pyutest_projectiles:arrow", { textures = { "pyutest-arrow.png", "pyutest-arrow.png", - "pyutest-arrow.png", - "pyutest-arrow.png", - "pyutest-arrow.png", - "pyutest-arrow.png", } }, { _slowdown = false diff --git a/mods/ENTITIES/pyutest_projectiles/projectiles/snowball.lua b/mods/ENTITIES/pyutest_projectiles/projectiles/snowball.lua new file mode 100644 index 0000000..b6e3cfc --- /dev/null +++ b/mods/ENTITIES/pyutest_projectiles/projectiles/snowball.lua @@ -0,0 +1,39 @@ +local function do_particles(pos) + local vel = 0.5 + + core.add_particlespawner({ + amount = math.random(5, 10), + time = 0.8, + exptime = 0.3, + vertical = true, + glow = core.LIGHT_MAX, + + -- collisiondetection = true, + texture = "pyutest-snowball-particle.png", + pos = pos, + vel = { + min = vector.new(-vel, -vel, -vel), + max = vector.new(vel, vel, vel), + }, + -- minvel = vector.new(-vel, -vel, -vel), + -- maxvel = vector.new(vel, vel, vel), + }) +end + +PyuTest.make_projectile("pyutest_projectiles:snowball", { + visual = "sprite", + visual_size = {x = 1, y = 1}, + textures = { + "pyutest-snowball.png", + } +}, { + _slowdown = false, +}, { + on_hit_node = function (self, pos, node) + do_particles(pos + vector.new(0, 1, 0)) + end, + on_hit_object = function (self, object) + do_particles(self.object:get_pos()) + PyuTest.deal_damage(object, 1, PyuTest.DAMAGE_TYPES.shot("Snowball")) + end +}) diff --git a/mods/ITEMS/pyutest_crafts/etc.lua b/mods/ITEMS/pyutest_crafts/etc.lua index 65e5d4c..6f52e35 100644 --- a/mods/ITEMS/pyutest_crafts/etc.lua +++ b/mods/ITEMS/pyutest_crafts/etc.lua @@ -57,3 +57,11 @@ core.register_craft({ }, type = "shapeless" }) + +core.register_craft({ + output = "pyutest_tools:snowball 5", + recipe = { + "pyutest_blocks:snow" + }, + type = "shapeless" +}) diff --git a/mods/ITEMS/pyutest_electricity/components/extender.lua b/mods/ITEMS/pyutest_electricity/components/extender.lua new file mode 100644 index 0000000..3186ed8 --- /dev/null +++ b/mods/ITEMS/pyutest_electricity/components/extender.lua @@ -0,0 +1,11 @@ +local function after_place_node(pos) + PyuTest.component_after_place_node(pos) +end + +PyuTest.make_electricity_device("pyutest_electricity:extender", "Extender", { + cracky = PyuTest.BLOCK_NORMAL +}, {"pyutest-delayer.png"}, nil, { + after_place_node = after_place_node, +}, function (pos, node, sender_pos, sender) + PyuTest.component_action(pos, sender) +end) diff --git a/mods/ITEMS/pyutest_magic/init.lua b/mods/ITEMS/pyutest_magic/init.lua index afbe026..2227851 100644 --- a/mods/ITEMS/pyutest_magic/init.lua +++ b/mods/ITEMS/pyutest_magic/init.lua @@ -1,6 +1,6 @@ local modpath = core.get_modpath(core.get_current_modname()) -PyuTest.make_item("pyutest_magic:magic_shards", "Magic Shards", {}, "pyutest-magic-shards.png") +PyuTest.make_item("pyutest_magic:magic_shards", "Enchanted Fragments", {}, "pyutest-magic-shards.png") PyuTest.make_item("pyutest_magic:enchanted_shard", "Enchanted Shard", {}, "pyutest-shard.png", { color = "indigo", diff --git a/mods/ITEMS/pyutest_tools/items.lua b/mods/ITEMS/pyutest_tools/items.lua index 588e658..9c06e8c 100644 --- a/mods/ITEMS/pyutest_tools/items.lua +++ b/mods/ITEMS/pyutest_tools/items.lua @@ -40,6 +40,13 @@ PyuTest.make_item("pyutest_tools:glass_bottle", "Glass Bottle", {}, "pyutest-gla stack_max = 16 }) PyuTest.make_item("pyutest_tools:brick", "Brick", {}, "pyutest-brick.png") -PyuTest.make_item("pyutest_tools:snowball", "Snowball", {}, "pyutest-snowball.png") +PyuTest.make_item("pyutest_tools:snowball", "Snowball", {}, "pyutest-snowball.png", { + on_use = function (itemstack, user, pointed_thing) + if user == nil then return end + PyuTest.shoot_projectile_from_object("pyutest_projectiles:snowball", user) + itemstack:take_item() + return itemstack + end +}) PyuTest.make_item("pyutest_tools:flint", "Flint", {}, "pyutest-flint.png") PyuTest.make_item("pyutest_tools:paper", "Paper", {}, "pyutest-paper.png") diff --git a/textures/pyutest-snowball-particle.png b/textures/pyutest-snowball-particle.png new file mode 100644 index 0000000000000000000000000000000000000000..c3a4251f2512374896c3f2a0d0f0f6c0754b79b8 GIT binary patch literal 82 zcmeAS@N?(olHy`uVBq!ia0vp^%plCc1|-8Yw(bW~lAbP(AsjQ4fBgUdzn%>UBzjMR a*$gckgx}7pm(&6(V(@hJb6Mw<&;$S;XBZOz literal 0 HcmV?d00001