From f4d8cc0f0bf33a998aa0d6d95de4b34f69fb31db Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 15 Jul 2021 19:19:59 +0000 Subject: [PATCH] Add wallmounted support for plantlike and plantlike_rooted nodes (#11379) --- builtin/game/falling.lua | 3 +- doc/lua_api.txt | 10 +++- games/devtest/mods/testnodes/drawtypes.lua | 30 +++++++++++ ...plantlike_rooted_base_side_wallmounted.png | Bin 0 -> 224 bytes ...testnodes_plantlike_rooted_wallmounted.png | Bin 0 -> 268 bytes .../testnodes_plantlike_wallmounted.png | Bin 0 -> 268 bytes src/client/content_mapblock.cpp | 48 +++++++++++++++++- src/client/content_mapblock.h | 2 +- src/mapnode.cpp | 4 +- 9 files changed, 90 insertions(+), 7 deletions(-) create mode 100644 games/devtest/mods/testnodes/textures/testnodes_plantlike_rooted_base_side_wallmounted.png create mode 100644 games/devtest/mods/testnodes/textures/testnodes_plantlike_rooted_wallmounted.png create mode 100644 games/devtest/mods/testnodes/textures/testnodes_plantlike_wallmounted.png diff --git a/builtin/game/falling.lua b/builtin/game/falling.lua index 4a13b0776..6db563534 100644 --- a/builtin/game/falling.lua +++ b/builtin/game/falling.lua @@ -157,7 +157,8 @@ core.register_entity(":__builtin:falling_node", { if euler then self.object:set_rotation(euler) end - elseif (def.paramtype2 == "wallmounted" or def.paramtype2 == "colorwallmounted" or def.drawtype == "signlike") then + elseif (def.drawtype ~= "plantlike" and def.drawtype ~= "plantlike_rooted" and + (def.paramtype2 == "wallmounted" or def.paramtype2 == "colorwallmounted" or def.drawtype == "signlike")) then local rot = node.param2 % 8 if (def.drawtype == "signlike" and def.paramtype2 ~= "wallmounted" and def.paramtype2 ~= "colorwallmounted") then -- Change rotation to "floor" by default for non-wallmounted paramtype2 diff --git a/doc/lua_api.txt b/doc/lua_api.txt index ad11d7235..3c96d0b36 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -1022,7 +1022,8 @@ The function of `param2` is determined by `paramtype2` in node definition. to access/manipulate the content of this field * Bit 3: If set, liquid is flowing downwards (no graphical effect) * `paramtype2 = "wallmounted"` - * Supported drawtypes: "torchlike", "signlike", "normal", "nodebox", "mesh" + * Supported drawtypes: "torchlike", "signlike", "plantlike", + "plantlike_rooted", "normal", "nodebox", "mesh" * The rotation of the node is stored in `param2` * You can make this value by using `minetest.dir_to_wallmounted()` * Values range 0 - 5 @@ -1198,7 +1199,12 @@ Look for examples in `games/devtest` or `games/minetest_game`. * `plantlike_rooted` * Enables underwater `plantlike` without air bubbles around the nodes. * Consists of a base cube at the co-ordinates of the node plus a - `plantlike` extension above with a height of `param2 / 16` nodes. + `plantlike` extension above + * If `paramtype2="leveled", the `plantlike` extension has a height + of `param2 / 16` nodes, otherwise it's the height of 1 node + * If `paramtype2="wallmounted"`, the `plantlike` extension + will be at one of the corresponding 6 sides of the base cube. + Also, the base cube rotates like a `normal` cube would * The `plantlike` extension visually passes through any nodes above the base cube without affecting them. * The base cube texture tiles are defined as normal, the `plantlike` diff --git a/games/devtest/mods/testnodes/drawtypes.lua b/games/devtest/mods/testnodes/drawtypes.lua index 2bc7ec2e3..208774f6c 100644 --- a/games/devtest/mods/testnodes/drawtypes.lua +++ b/games/devtest/mods/testnodes/drawtypes.lua @@ -208,6 +208,19 @@ minetest.register_node("testnodes:plantlike_waving", { groups = { dig_immediate = 3 }, }) +minetest.register_node("testnodes:plantlike_wallmounted", { + description = S("Wallmounted Plantlike Drawtype Test Node"), + drawtype = "plantlike", + paramtype = "light", + paramtype2 = "wallmounted", + tiles = { "testnodes_plantlike_wallmounted.png" }, + leveled = 1, + + + walkable = false, + sunlight_propagates = true, + groups = { dig_immediate = 3 }, +}) -- param2 will rotate @@ -320,6 +333,20 @@ minetest.register_node("testnodes:plantlike_rooted", { groups = { dig_immediate = 3 }, }) +minetest.register_node("testnodes:plantlike_rooted_wallmounted", { + description = S("Wallmounted Rooted Plantlike Drawtype Test Node"), + drawtype = "plantlike_rooted", + paramtype = "light", + paramtype2 = "wallmounted", + tiles = { + "testnodes_plantlike_rooted_base.png", + "testnodes_plantlike_rooted_base.png", + "testnodes_plantlike_rooted_base_side_wallmounted.png" }, + special_tiles = { "testnodes_plantlike_rooted_wallmounted.png" }, + + groups = { dig_immediate = 3 }, +}) + minetest.register_node("testnodes:plantlike_rooted_waving", { description = S("Waving Rooted Plantlike Drawtype Test Node"), drawtype = "plantlike_rooted", @@ -588,6 +615,9 @@ scale("allfaces_optional_waving", scale("plantlike", S("Double-sized Plantlike Drawtype Test Node"), S("Half-sized Plantlike Drawtype Test Node")) +scale("plantlike_wallmounted", + S("Double-sized Wallmounted Plantlike Drawtype Test Node"), + S("Half-sized Wallmounted Plantlike Drawtype Test Node")) scale("torchlike_wallmounted", S("Double-sized Wallmounted Torchlike Drawtype Test Node"), S("Half-sized Wallmounted Torchlike Drawtype Test Node")) diff --git a/games/devtest/mods/testnodes/textures/testnodes_plantlike_rooted_base_side_wallmounted.png b/games/devtest/mods/testnodes/textures/testnodes_plantlike_rooted_base_side_wallmounted.png new file mode 100644 index 0000000000000000000000000000000000000000..b0be8d0779e28fc4f5e378d3a6a2263d62303c72 GIT binary patch literal 224 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|oCO|{#S9GG!XV7ZFl&wkP>{XE z)7O>#DVvzMq@Lb|GXX%MdQTU}5RLO|CmC`bP~dT$Z)IKfLU7My_m$7TaL8Jf>Ae-$ z;CMvK^Cc%LZit-x&E(7#p|HmN-gH6MGh!3V>nA;`U#XDD(`y=HTQyiXY5$IvVuWBc}eoe TCq-|8PGRtL^>bP0l+XkKHY`w; literal 0 HcmV?d00001 diff --git a/games/devtest/mods/testnodes/textures/testnodes_plantlike_rooted_wallmounted.png b/games/devtest/mods/testnodes/textures/testnodes_plantlike_rooted_wallmounted.png new file mode 100644 index 0000000000000000000000000000000000000000..421466407db7c1af181f1bde0b2d2d78f10ef105 GIT binary patch literal 268 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|oCO|{#S9GG!XV7ZFl&wkP>{XE z)7O>#DVvzMl;mCqt2scS)t)YnAsXkC|C~Qy@KJ;LW5dV)|Nryo`wOqEdK7D{#wK*o z;L?S!30g5LULOpx5TAUI<)KYwIlo@WvI&2m+_mkfnCWEZBA~={l|is|Lgn+Whherr z=|iq!EDW{XE z)7O>#DVvzM6uY}W`+uO&YEKu(5RLQ6f6gB;_^84BvEk$Y|Nr$R!vt4W9o<-<#wK*o z;L?T+aoUzQpK1H6 zle?=0^foCR;yU0AGgOKWHIyO7k-ZEx?r*&vv+itEy4OtB{8ecNh9OSxq z_visual_scale; @@ -998,6 +1026,22 @@ void MapblockMeshGenerator::drawPlantlike() break; } + if (is_rooted) { + u8 wall = n.getWallMounted(nodedef); + switch (wall) { + case DWM_YP: + offset.Y += BS*2; + break; + case DWM_XN: + case DWM_XP: + case DWM_ZN: + case DWM_ZP: + offset.X += -BS; + offset.Y += BS; + break; + } + } + switch (draw_style) { case PLANT_STYLE_CROSS: drawPlantlikeQuad(46); @@ -1048,7 +1092,7 @@ void MapblockMeshGenerator::drawPlantlikeRootedNode() MapNode ntop = data->m_vmanip.getNodeNoEx(blockpos_nodes + p); light = LightPair(getInteriorLight(ntop, 1, nodedef)); } - drawPlantlike(); + drawPlantlike(true); p.Y--; } diff --git a/src/client/content_mapblock.h b/src/client/content_mapblock.h index 237cc7847..7344f05ee 100644 --- a/src/client/content_mapblock.h +++ b/src/client/content_mapblock.h @@ -146,7 +146,7 @@ public: void drawPlantlikeQuad(float rotation, float quad_offset = 0, bool offset_top_only = false); - void drawPlantlike(); + void drawPlantlike(bool is_rooted = false); // firelike-specific void drawFirelikeQuad(float rotation, float opening_angle, diff --git a/src/mapnode.cpp b/src/mapnode.cpp index c885bfe1d..f212ea8c9 100644 --- a/src/mapnode.cpp +++ b/src/mapnode.cpp @@ -161,7 +161,9 @@ u8 MapNode::getWallMounted(const NodeDefManager *nodemgr) const if (f.param_type_2 == CPT2_WALLMOUNTED || f.param_type_2 == CPT2_COLORED_WALLMOUNTED) { return getParam2() & 0x07; - } else if (f.drawtype == NDT_SIGNLIKE || f.drawtype == NDT_TORCHLIKE) { + } else if (f.drawtype == NDT_SIGNLIKE || f.drawtype == NDT_TORCHLIKE || + f.drawtype == NDT_PLANTLIKE || + f.drawtype == NDT_PLANTLIKE_ROOTED) { return 1; } return 0;