minetest / minetest

Minetest is an open source voxel game-creation platform with easy modding and game creation
https://www.minetest.net/
Other
10.71k stars 2.02k forks source link

Redesign item glow #11661

Open Wuzzy2 opened 3 years ago

Wuzzy2 commented 3 years ago

Problem

Currently, dropped items glow (with glow property) if the light_source field is set in the item definition. It was me who added it. I thought it would be nice of dropped items could glow in the dark.

But I start to dislike the implementation now because it couples the node light_source value with the dropped item glow. At least one core dev disliked it, too, and I start to understand why. Not every game wants their dropped items to glow in the dark, even if it's a node that normally glows. Because it also affects things like torches which look strange in their glowing item form.

In general, I now think the Minetest API is always better when features are decoupled from each other, compared to lumping several features together behind a single node definition field.

Solution

First, revert the item glow. Second, add the feature back, but instead of abusing light_source, introduce a new field to the item definition called item_glow which does what it says on the tin: It specifies the glow value of this thing in item form.

At first, it will affect the dropped item form only. This is probably the easy part because the code for this already exists, it just needs to use a different property name. Later, the wielded item form could be affected as well, which is the not-so-easy part because the code for this is still WIP.

Alternatives

Maybe go all in and not only add item_glow but also wield_glow, having two separate properties, one for the dropped item (entity) form, one for the item in its wielded form. For maximum flexibility.

I'm not sure which way to prefer.

Active PR

Currently, wielded item glow is being implemented here: #9441 But it currently also abuses light_source like I did.

Backwards compability issues?

I don't think backwards-compability is an issue here. It's just a builtin thing and I don't think any game specifically depends on this still rather young and kinda obscure built-in behavior.

I'd say it will be OK to drop the abuse of light_source altogether.

Wuzzy2 commented 3 years ago

Note: I am ready to write code for this, but I am waiting for concept approval because I don't want to waste my time writing code if it's going to get nuked anyway.