Skip to content

Commit f4d8cc0

Browse files
authoredJul 15, 2021
Add wallmounted support for plantlike and plantlike_rooted nodes (#11379)
1 parent 68143ed commit f4d8cc0

9 files changed

+90
-7
lines changed
 

‎builtin/game/falling.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ core.register_entity(":__builtin:falling_node", {
157157
if euler then
158158
self.object:set_rotation(euler)
159159
end
160-
elseif (def.paramtype2 == "wallmounted" or def.paramtype2 == "colorwallmounted" or def.drawtype == "signlike") then
160+
elseif (def.drawtype ~= "plantlike" and def.drawtype ~= "plantlike_rooted" and
161+
(def.paramtype2 == "wallmounted" or def.paramtype2 == "colorwallmounted" or def.drawtype == "signlike")) then
161162
local rot = node.param2 % 8
162163
if (def.drawtype == "signlike" and def.paramtype2 ~= "wallmounted" and def.paramtype2 ~= "colorwallmounted") then
163164
-- Change rotation to "floor" by default for non-wallmounted paramtype2

‎doc/lua_api.txt

+8-2
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,8 @@ The function of `param2` is determined by `paramtype2` in node definition.
10221022
to access/manipulate the content of this field
10231023
* Bit 3: If set, liquid is flowing downwards (no graphical effect)
10241024
* `paramtype2 = "wallmounted"`
1025-
* Supported drawtypes: "torchlike", "signlike", "normal", "nodebox", "mesh"
1025+
* Supported drawtypes: "torchlike", "signlike", "plantlike",
1026+
"plantlike_rooted", "normal", "nodebox", "mesh"
10261027
* The rotation of the node is stored in `param2`
10271028
* You can make this value by using `minetest.dir_to_wallmounted()`
10281029
* Values range 0 - 5
@@ -1198,7 +1199,12 @@ Look for examples in `games/devtest` or `games/minetest_game`.
11981199
* `plantlike_rooted`
11991200
* Enables underwater `plantlike` without air bubbles around the nodes.
12001201
* Consists of a base cube at the co-ordinates of the node plus a
1201-
`plantlike` extension above with a height of `param2 / 16` nodes.
1202+
`plantlike` extension above
1203+
* If `paramtype2="leveled", the `plantlike` extension has a height
1204+
of `param2 / 16` nodes, otherwise it's the height of 1 node
1205+
* If `paramtype2="wallmounted"`, the `plantlike` extension
1206+
will be at one of the corresponding 6 sides of the base cube.
1207+
Also, the base cube rotates like a `normal` cube would
12021208
* The `plantlike` extension visually passes through any nodes above the
12031209
base cube without affecting them.
12041210
* The base cube texture tiles are defined as normal, the `plantlike`

‎games/devtest/mods/testnodes/drawtypes.lua

+30
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,19 @@ minetest.register_node("testnodes:plantlike_waving", {
208208
groups = { dig_immediate = 3 },
209209
})
210210

211+
minetest.register_node("testnodes:plantlike_wallmounted", {
212+
description = S("Wallmounted Plantlike Drawtype Test Node"),
213+
drawtype = "plantlike",
214+
paramtype = "light",
215+
paramtype2 = "wallmounted",
216+
tiles = { "testnodes_plantlike_wallmounted.png" },
217+
leveled = 1,
218+
219+
220+
walkable = false,
221+
sunlight_propagates = true,
222+
groups = { dig_immediate = 3 },
223+
})
211224

212225

213226
-- param2 will rotate
@@ -320,6 +333,20 @@ minetest.register_node("testnodes:plantlike_rooted", {
320333
groups = { dig_immediate = 3 },
321334
})
322335

336+
minetest.register_node("testnodes:plantlike_rooted_wallmounted", {
337+
description = S("Wallmounted Rooted Plantlike Drawtype Test Node"),
338+
drawtype = "plantlike_rooted",
339+
paramtype = "light",
340+
paramtype2 = "wallmounted",
341+
tiles = {
342+
"testnodes_plantlike_rooted_base.png",
343+
"testnodes_plantlike_rooted_base.png",
344+
"testnodes_plantlike_rooted_base_side_wallmounted.png" },
345+
special_tiles = { "testnodes_plantlike_rooted_wallmounted.png" },
346+
347+
groups = { dig_immediate = 3 },
348+
})
349+
323350
minetest.register_node("testnodes:plantlike_rooted_waving", {
324351
description = S("Waving Rooted Plantlike Drawtype Test Node"),
325352
drawtype = "plantlike_rooted",
@@ -588,6 +615,9 @@ scale("allfaces_optional_waving",
588615
scale("plantlike",
589616
S("Double-sized Plantlike Drawtype Test Node"),
590617
S("Half-sized Plantlike Drawtype Test Node"))
618+
scale("plantlike_wallmounted",
619+
S("Double-sized Wallmounted Plantlike Drawtype Test Node"),
620+
S("Half-sized Wallmounted Plantlike Drawtype Test Node"))
591621
scale("torchlike_wallmounted",
592622
S("Double-sized Wallmounted Torchlike Drawtype Test Node"),
593623
S("Half-sized Wallmounted Torchlike Drawtype Test Node"))
Loading
Loading
Loading

‎src/client/content_mapblock.cpp

+46-2
Original file line numberDiff line numberDiff line change
@@ -958,10 +958,38 @@ void MapblockMeshGenerator::drawPlantlikeQuad(float rotation, float quad_offset,
958958
vertex.rotateXZBy(rotation + rotate_degree);
959959
vertex += offset;
960960
}
961+
962+
u8 wall = n.getWallMounted(nodedef);
963+
if (wall != DWM_YN) {
964+
for (v3f &vertex : vertices) {
965+
switch (wall) {
966+
case DWM_YP:
967+
vertex.rotateYZBy(180);
968+
vertex.rotateXZBy(180);
969+
break;
970+
case DWM_XP:
971+
vertex.rotateXYBy(90);
972+
break;
973+
case DWM_XN:
974+
vertex.rotateXYBy(-90);
975+
vertex.rotateYZBy(180);
976+
break;
977+
case DWM_ZP:
978+
vertex.rotateYZBy(-90);
979+
vertex.rotateXYBy(90);
980+
break;
981+
case DWM_ZN:
982+
vertex.rotateYZBy(90);
983+
vertex.rotateXYBy(90);
984+
break;
985+
}
986+
}
987+
}
988+
961989
drawQuad(vertices, v3s16(0, 0, 0), plant_height);
962990
}
963991

964-
void MapblockMeshGenerator::drawPlantlike()
992+
void MapblockMeshGenerator::drawPlantlike(bool is_rooted)
965993
{
966994
draw_style = PLANT_STYLE_CROSS;
967995
scale = BS / 2 * f->visual_scale;
@@ -998,6 +1026,22 @@ void MapblockMeshGenerator::drawPlantlike()
9981026
break;
9991027
}
10001028

1029+
if (is_rooted) {
1030+
u8 wall = n.getWallMounted(nodedef);
1031+
switch (wall) {
1032+
case DWM_YP:
1033+
offset.Y += BS*2;
1034+
break;
1035+
case DWM_XN:
1036+
case DWM_XP:
1037+
case DWM_ZN:
1038+
case DWM_ZP:
1039+
offset.X += -BS;
1040+
offset.Y += BS;
1041+
break;
1042+
}
1043+
}
1044+
10011045
switch (draw_style) {
10021046
case PLANT_STYLE_CROSS:
10031047
drawPlantlikeQuad(46);
@@ -1048,7 +1092,7 @@ void MapblockMeshGenerator::drawPlantlikeRootedNode()
10481092
MapNode ntop = data->m_vmanip.getNodeNoEx(blockpos_nodes + p);
10491093
light = LightPair(getInteriorLight(ntop, 1, nodedef));
10501094
}
1051-
drawPlantlike();
1095+
drawPlantlike(true);
10521096
p.Y--;
10531097
}
10541098

‎src/client/content_mapblock.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class MapblockMeshGenerator
146146

147147
void drawPlantlikeQuad(float rotation, float quad_offset = 0,
148148
bool offset_top_only = false);
149-
void drawPlantlike();
149+
void drawPlantlike(bool is_rooted = false);
150150

151151
// firelike-specific
152152
void drawFirelikeQuad(float rotation, float opening_angle,

‎src/mapnode.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ u8 MapNode::getWallMounted(const NodeDefManager *nodemgr) const
161161
if (f.param_type_2 == CPT2_WALLMOUNTED ||
162162
f.param_type_2 == CPT2_COLORED_WALLMOUNTED) {
163163
return getParam2() & 0x07;
164-
} else if (f.drawtype == NDT_SIGNLIKE || f.drawtype == NDT_TORCHLIKE) {
164+
} else if (f.drawtype == NDT_SIGNLIKE || f.drawtype == NDT_TORCHLIKE ||
165+
f.drawtype == NDT_PLANTLIKE ||
166+
f.drawtype == NDT_PLANTLIKE_ROOTED) {
165167
return 1;
166168
}
167169
return 0;

0 commit comments

Comments
 (0)
Please sign in to comment.