From 0cc0a7e01de8fc00dd63eab1b960701940719a66 Mon Sep 17 00:00:00 2001 From: NO11 Date: Fri, 12 Nov 2021 17:49:27 +0000 Subject: [PATCH 1/5] Make dripping particles MC-like --- mods/ENTITIES/drippingwater/init.lua | 167 ++++++++++----------------- 1 file changed, 59 insertions(+), 108 deletions(-) diff --git a/mods/ENTITIES/drippingwater/init.lua b/mods/ENTITIES/drippingwater/init.lua index e17bdda40..a4855acdc 100644 --- a/mods/ENTITIES/drippingwater/init.lua +++ b/mods/ENTITIES/drippingwater/init.lua @@ -1,114 +1,65 @@ ---Dripping Water Mod ---by kddekadenz +-- Dripping Water Mod +-- by kddekadenz local math = math -- License of code, textures & sounds: CC0 ---Drop entities +local function register_drop(liquid, glow, sound, nodes) + minetest.register_entity("drippingwater:drop_" .. liquid, { + hp_max = 1, + physical = true, + collide_with_objects = false, + collisionbox = {-0.01, 0.01, -0.01, 0.01, 0.01, 0.01}, + glow = glow, + pointable = false, + visual = "sprite", + visual_size = {x = 0.1, y = 0.1}, + textures = {""}, + spritediv = {x = 1, y = 1}, + initial_sprite_basepos = {x = 0, y = 0}, + static_save = false, + _dropped = false, + on_activate = function(self) + self.object:set_properties({ + textures = {"[combine:2x2:" .. -math.random(1, 16) .. "," .. -math.random(1, 16) .. "=default_" .. liquid .. "_source_animated.png"} + }) + end, + on_step = function(self, dtime) + local k = math.random(1, 222) + local ownpos = self.object:get_pos() + if k == 1 then + self.object:set_acceleration(vector.new(0, -5, 0)) + end + if minetest.get_node(vector.offset(ownpos, 0, 0.5, 0)).name == "air" then + self.object:set_acceleration(vector.new(0, -5, 0)) + end + if minetest.get_node(vector.offset(ownpos, 0, -0.1, 0)).name ~= "air" then + if not self.object:get_luaentity()._dropped then + self.object:get_luaentity()._dropped = true + minetest.sound_play({name = "drippingwater_" .. sound .. "drip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true) + end + if k < 3 then + self.object:remove() + end + end + end, + }) + minetest.register_abm({ + label = "Create drops", + nodenames = nodes, + neighbors = {"group:" .. liquid}, + interval = 2, + chance = 22, + action = function(pos) + if minetest.get_item_group(minetest.get_node(vector.offset(pos, 0, 1, 0)).name, liquid) ~= 0 + and minetest.get_node(vector.offset(pos, 0, -1, 0)).name == "air" then + local x, z = math.random(-45, 45) / 100, math.random(-45, 45) / 100 + minetest.add_entity(vector.offset(pos, x, -0.520, z), "drippingwater:drop_" .. liquid) + end + end, + }) +end ---water - -local water_tex = "default_water_source_animated.png^[verticalframe:16:0" -minetest.register_entity("drippingwater:drop_water", { - hp_max = 1, - physical = true, - collide_with_objects = false, - collisionbox = {-0.025,-0.05,-0.025,0.025,-0.01,0.025}, - pointable = false, - visual = "cube", - visual_size = {x=0.05, y=0.1}, - textures = {water_tex, water_tex, water_tex, water_tex, water_tex, water_tex}, - spritediv = {x=1, y=1}, - initial_sprite_basepos = {x=0, y=0}, - static_save = false, - on_activate = function(self, staticdata) - self.object:set_sprite({x=0,y=0}, 1, 1, true) - end, - on_step = function(self, dtime) - local k = math.random(1,222) - local ownpos = self.object:get_pos() - if k==1 then - self.object:set_acceleration({x=0, y=-5, z=0}) - end - if minetest.get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then - self.object:set_acceleration({x=0, y=-5, z=0}) - end - if minetest.get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then - self.object:remove() - minetest.sound_play({name="drippingwater_drip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true) - end - end, -}) - - ---lava - -local lava_tex = "default_lava_source_animated.png^[verticalframe:16:0" -minetest.register_entity("drippingwater:drop_lava", { - hp_max = 1, - physical = true, - collide_with_objects = false, - collisionbox = {-0.025,-0.05,-0.025,0.025,-0.01,0.025}, - glow = math.max(7, minetest.registered_nodes["mcl_core:lava_source"].light_source - 3), - pointable = false, - visual = "cube", - visual_size = {x=0.05, y=0.1}, - textures = {lava_tex, lava_tex, lava_tex, lava_tex, lava_tex, lava_tex}, - spritediv = {x=1, y=1}, - initial_sprite_basepos = {x=0, y=0}, - static_save = false, - on_activate = function(self, staticdata) - self.object:set_sprite({x=0,y=0}, 1, 0, true) - end, - on_step = function(self, dtime) - local k = math.random(1,222) - local ownpos = self.object:get_pos() - if k == 1 then - self.object:set_acceleration({x=0, y=-5, z=0}) - end - if minetest.get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then - self.object:set_acceleration({x=0, y=-5, z=0}) - end - if minetest.get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then - self.object:remove() - minetest.sound_play({name="drippingwater_lavadrip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true) - end - end, -}) - - - ---Create drop - -minetest.register_abm({ - label = "Create water drops", - nodenames = {"group:opaque", "group:leaves"}, - neighbors = {"group:water"}, - interval = 2, - chance = 22, - action = function(pos) - if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name, "water") ~= 0 - and minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then - local i = math.random(-45,45) / 100 - minetest.add_entity({x=pos.x + i, y=pos.y - 0.501, z=pos.z + i}, "drippingwater:drop_water") - end - end, -}) - ---Create lava drop - -minetest.register_abm({ - label = "Create lava drops", - nodenames = {"group:opaque"}, - neighbors = {"group:lava"}, - interval = 2, - chance = 22, - action = function(pos) - if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name, "lava") ~= 0 - and minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then - local i = math.random(-45,45) / 100 - minetest.add_entity({x=pos.x + i, y=pos.y - 0.501, z=pos.z + i}, "drippingwater:drop_lava") - end - end, -}) \ No newline at end of file +register_drop("water", 1, "", {"group:opaque", "group:leaves"}) +register_drop("lava", math.max(7, minetest.registered_nodes["mcl_core:lava_source"].light_source - 3), "lava", {"group:opaque"}) \ No newline at end of file From 7ed964756e1798ba7e2feb6b3459e1fb66dae914 Mon Sep 17 00:00:00 2001 From: NO11 Date: Fri, 12 Nov 2021 18:00:04 +0000 Subject: [PATCH 2/5] local luaentity --- mods/ENTITIES/drippingwater/init.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/drippingwater/init.lua b/mods/ENTITIES/drippingwater/init.lua index a4855acdc..45a211d8f 100644 --- a/mods/ENTITIES/drippingwater/init.lua +++ b/mods/ENTITIES/drippingwater/init.lua @@ -35,8 +35,9 @@ local function register_drop(liquid, glow, sound, nodes) self.object:set_acceleration(vector.new(0, -5, 0)) end if minetest.get_node(vector.offset(ownpos, 0, -0.1, 0)).name ~= "air" then - if not self.object:get_luaentity()._dropped then - self.object:get_luaentity()._dropped = true + local ent = self.object:get_luaentity() + if not ent._dropped then + ent._dropped = true minetest.sound_play({name = "drippingwater_" .. sound .. "drip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true) end if k < 3 then From 7ef6613f0967718463e9be3f1f90f97811d8346a Mon Sep 17 00:00:00 2001 From: NO11 Date: Mon, 15 Nov 2021 21:39:43 +0100 Subject: [PATCH 3/5] Rename drippingwater mod to mcl_dripping --- .../{drippingwater => mcl_dripping}/init.lua | 0 .../{drippingwater => mcl_dripping}/mod.conf | 0 .../{drippingwater => mcl_dripping}/readme.txt | 0 .../sounds/drippingwater_drip.1.ogg | Bin .../sounds/drippingwater_drip.2.ogg | Bin .../sounds/drippingwater_drip.3.ogg | Bin .../sounds/drippingwater_lavadrip.1.ogg | Bin .../sounds/drippingwater_lavadrip.2.ogg | Bin .../sounds/drippingwater_lavadrip.3.ogg | Bin 9 files changed, 0 insertions(+), 0 deletions(-) rename mods/ENTITIES/{drippingwater => mcl_dripping}/init.lua (100%) rename mods/ENTITIES/{drippingwater => mcl_dripping}/mod.conf (100%) rename mods/ENTITIES/{drippingwater => mcl_dripping}/readme.txt (100%) rename mods/ENTITIES/{drippingwater => mcl_dripping}/sounds/drippingwater_drip.1.ogg (100%) rename mods/ENTITIES/{drippingwater => mcl_dripping}/sounds/drippingwater_drip.2.ogg (100%) rename mods/ENTITIES/{drippingwater => mcl_dripping}/sounds/drippingwater_drip.3.ogg (100%) rename mods/ENTITIES/{drippingwater => mcl_dripping}/sounds/drippingwater_lavadrip.1.ogg (100%) rename mods/ENTITIES/{drippingwater => mcl_dripping}/sounds/drippingwater_lavadrip.2.ogg (100%) rename mods/ENTITIES/{drippingwater => mcl_dripping}/sounds/drippingwater_lavadrip.3.ogg (100%) diff --git a/mods/ENTITIES/drippingwater/init.lua b/mods/ENTITIES/mcl_dripping/init.lua similarity index 100% rename from mods/ENTITIES/drippingwater/init.lua rename to mods/ENTITIES/mcl_dripping/init.lua diff --git a/mods/ENTITIES/drippingwater/mod.conf b/mods/ENTITIES/mcl_dripping/mod.conf similarity index 100% rename from mods/ENTITIES/drippingwater/mod.conf rename to mods/ENTITIES/mcl_dripping/mod.conf diff --git a/mods/ENTITIES/drippingwater/readme.txt b/mods/ENTITIES/mcl_dripping/readme.txt similarity index 100% rename from mods/ENTITIES/drippingwater/readme.txt rename to mods/ENTITIES/mcl_dripping/readme.txt diff --git a/mods/ENTITIES/drippingwater/sounds/drippingwater_drip.1.ogg b/mods/ENTITIES/mcl_dripping/sounds/drippingwater_drip.1.ogg similarity index 100% rename from mods/ENTITIES/drippingwater/sounds/drippingwater_drip.1.ogg rename to mods/ENTITIES/mcl_dripping/sounds/drippingwater_drip.1.ogg diff --git a/mods/ENTITIES/drippingwater/sounds/drippingwater_drip.2.ogg b/mods/ENTITIES/mcl_dripping/sounds/drippingwater_drip.2.ogg similarity index 100% rename from mods/ENTITIES/drippingwater/sounds/drippingwater_drip.2.ogg rename to mods/ENTITIES/mcl_dripping/sounds/drippingwater_drip.2.ogg diff --git a/mods/ENTITIES/drippingwater/sounds/drippingwater_drip.3.ogg b/mods/ENTITIES/mcl_dripping/sounds/drippingwater_drip.3.ogg similarity index 100% rename from mods/ENTITIES/drippingwater/sounds/drippingwater_drip.3.ogg rename to mods/ENTITIES/mcl_dripping/sounds/drippingwater_drip.3.ogg diff --git a/mods/ENTITIES/drippingwater/sounds/drippingwater_lavadrip.1.ogg b/mods/ENTITIES/mcl_dripping/sounds/drippingwater_lavadrip.1.ogg similarity index 100% rename from mods/ENTITIES/drippingwater/sounds/drippingwater_lavadrip.1.ogg rename to mods/ENTITIES/mcl_dripping/sounds/drippingwater_lavadrip.1.ogg diff --git a/mods/ENTITIES/drippingwater/sounds/drippingwater_lavadrip.2.ogg b/mods/ENTITIES/mcl_dripping/sounds/drippingwater_lavadrip.2.ogg similarity index 100% rename from mods/ENTITIES/drippingwater/sounds/drippingwater_lavadrip.2.ogg rename to mods/ENTITIES/mcl_dripping/sounds/drippingwater_lavadrip.2.ogg diff --git a/mods/ENTITIES/drippingwater/sounds/drippingwater_lavadrip.3.ogg b/mods/ENTITIES/mcl_dripping/sounds/drippingwater_lavadrip.3.ogg similarity index 100% rename from mods/ENTITIES/drippingwater/sounds/drippingwater_lavadrip.3.ogg rename to mods/ENTITIES/mcl_dripping/sounds/drippingwater_lavadrip.3.ogg From d2a03ec0b91c7e5580daab13cea2b585501e50d6 Mon Sep 17 00:00:00 2001 From: NO11 Date: Mon, 15 Nov 2021 21:44:23 +0100 Subject: [PATCH 4/5] Rename entity ids --- mods/ENTITIES/mcl_dripping/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mcl_dripping/init.lua b/mods/ENTITIES/mcl_dripping/init.lua index 45a211d8f..57ba7ecfe 100644 --- a/mods/ENTITIES/mcl_dripping/init.lua +++ b/mods/ENTITIES/mcl_dripping/init.lua @@ -6,7 +6,7 @@ local math = math -- License of code, textures & sounds: CC0 local function register_drop(liquid, glow, sound, nodes) - minetest.register_entity("drippingwater:drop_" .. liquid, { + minetest.register_entity("mcl_dripping:drop_" .. liquid, { hp_max = 1, physical = true, collide_with_objects = false, @@ -56,7 +56,7 @@ local function register_drop(liquid, glow, sound, nodes) if minetest.get_item_group(minetest.get_node(vector.offset(pos, 0, 1, 0)).name, liquid) ~= 0 and minetest.get_node(vector.offset(pos, 0, -1, 0)).name == "air" then local x, z = math.random(-45, 45) / 100, math.random(-45, 45) / 100 - minetest.add_entity(vector.offset(pos, x, -0.520, z), "drippingwater:drop_" .. liquid) + minetest.add_entity(vector.offset(pos, x, -0.520, z), "mcl_dripping:drop_" .. liquid) end end, }) From a9804879e208de4c8774498d05bb17a5ff0facaf Mon Sep 17 00:00:00 2001 From: NO11 Date: Mon, 15 Nov 2021 21:54:16 +0100 Subject: [PATCH 5/5] Rename drippingwater to mcl_dripping in mod.conf and readme.txt --- mods/ENTITIES/mcl_dripping/mod.conf | 2 +- mods/ENTITIES/mcl_dripping/readme.txt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mods/ENTITIES/mcl_dripping/mod.conf b/mods/ENTITIES/mcl_dripping/mod.conf index 1de118f4c..921d5e59f 100644 --- a/mods/ENTITIES/mcl_dripping/mod.conf +++ b/mods/ENTITIES/mcl_dripping/mod.conf @@ -1,4 +1,4 @@ -name = drippingwater +name = mcl_dripping author = kddekadenz description = Drops are generated rarely under solid nodes depends = mcl_core diff --git a/mods/ENTITIES/mcl_dripping/readme.txt b/mods/ENTITIES/mcl_dripping/readme.txt index f609163ed..afe35608e 100644 --- a/mods/ENTITIES/mcl_dripping/readme.txt +++ b/mods/ENTITIES/mcl_dripping/readme.txt @@ -1,12 +1,12 @@ -Dripping Water Mod +Dripping Mod by kddekadenz -modified for MineClone 2 by Wuzzy +modified for MineClone 2 by Wuzzy and NO11 Installing instructions: - 1. Copy the drippingwater mod folder into games/gamemode/mods + 1. Copy the mcl_dripping mod folder into games/gamemode/mods 2. Start game and enjoy :)