Skip to content

Commit a833bee

Browse files
GreenXenithparamat
authored andcommitted
Add object visual type 'item' (#7870)
1 parent 98fa8a1 commit a833bee

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

doc/lua_api.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -5472,7 +5472,7 @@ Used by `ObjectRef` methods. Part of an Entity definition.
54725472
pointable = true,
54735473
-- Overrides selection box when false
54745474

5475-
visual = "cube" / "sprite" / "upright_sprite" / "mesh" / "wielditem",
5475+
visual = "cube" / "sprite" / "upright_sprite" / "mesh" / "wielditem" / "item",
54765476
-- "cube" is a node-sized cube.
54775477
-- "sprite" is a flat texture always facing the player.
54785478
-- "upright_sprite" is a vertical flat texture.
@@ -5488,6 +5488,7 @@ Used by `ObjectRef` methods. Part of an Entity definition.
54885488
-- of its texture.
54895489
-- Otherwise for non-node items, the object will be an extrusion of
54905490
-- 'inventory_image'.
5491+
-- "item" is similar to "wielditem" but ignores the 'wield_image' parameter.
54915492

54925493
visual_size = {x = 1, y = 1},
54935494
-- `x` multiplies horizontal (X and Z) visual size.

src/client/content_cao.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc)
662662
}
663663
else
664664
errorstream<<"GenericCAO::addToScene(): Could not load mesh "<<m_prop.mesh<<std::endl;
665-
} else if (m_prop.visual == "wielditem") {
665+
} else if (m_prop.visual == "wielditem" || m_prop.visual == "item") {
666666
ItemStack item;
667667
infostream << "GenericCAO::addToScene(): wielditem" << std::endl;
668668
if (m_prop.wield_item.empty()) {
@@ -680,7 +680,8 @@ void GenericCAO::addToScene(ITextureSource *tsrc)
680680
}
681681
m_wield_meshnode = new WieldMeshSceneNode(
682682
RenderingEngine::get_scene_manager(), -1);
683-
m_wield_meshnode->setItem(item, m_client);
683+
m_wield_meshnode->setItem(item, m_client,
684+
(m_prop.visual == "wielditem"));
684685

685686
m_wield_meshnode->setScale(
686687
v3f(m_prop.visual_size.X / 2, m_prop.visual_size.Y / 2,

src/client/wieldmesh.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ scene::SMesh *createSpecialNodeMesh(Client *client, content_t id, std::vector<It
333333
return mesh;
334334
}
335335

336-
void WieldMeshSceneNode::setItem(const ItemStack &item, Client *client)
336+
void WieldMeshSceneNode::setItem(const ItemStack &item, Client *client, bool check_wield_image)
337337
{
338338
ITextureSource *tsrc = client->getTextureSource();
339339
IItemDefManager *idef = client->getItemDefManager();
@@ -354,8 +354,8 @@ void WieldMeshSceneNode::setItem(const ItemStack &item, Client *client)
354354
m_colors.clear();
355355
m_base_color = idef->getItemstackColor(item, client);
356356

357-
// If wield_image is defined, it overrides everything else
358-
if (!def.wield_image.empty()) {
357+
// If wield_image needs to be checked and is defined, it overrides everything else
358+
if (!def.wield_image.empty() && check_wield_image) {
359359
setExtruded(def.wield_image, def.wield_overlay, def.wield_scale, tsrc,
360360
1);
361361
m_colors.emplace_back();

src/client/wieldmesh.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ class WieldMeshSceneNode : public scene::ISceneNode
8080
void setCube(const ContentFeatures &f, v3f wield_scale);
8181
void setExtruded(const std::string &imagename, const std::string &overlay_image,
8282
v3f wield_scale, ITextureSource *tsrc, u8 num_frames);
83-
void setItem(const ItemStack &item, Client *client);
83+
void setItem(const ItemStack &item, Client *client,
84+
bool check_wield_image = true);
8485

8586
// Sets the vertex color of the wield mesh.
8687
// Must only be used if the constructor was called with lighting = false

0 commit comments

Comments
 (0)