[Mod]Frame - lag-free non-entity item frames![frame]
[Mod]Frame - lag-free non-entity item frames![frame]
Similar to the flowerpot, I've made a new item frame that does not use entities. It should make it possible for multiplayer servers to use item frames without adding lag or much extra loading time, while still offering a large amount of item frame possibilities.
The item frame will either display the items put in them (nodes or craftitems) as block (including separate top/bottom/side textures) or as flat image (but not wielditem view, just flat).
The trick is that just like the flowerpot, there's just one mesh node with 5 different materials, and depending on what you put in there, you get a node with those textures changed from transparent to the item textures.
The downside is extra nodes. But, extra nodes are a lot more efficient than entities.
The nodes store itemstack metadata and wear, so written books will remain written books, and tools with wear will come out with the wear back.
This probably needs more testing, and it's likely missing nodes and not working with some (e.g. nodes that capture rightclick wrong).
Crafting recipe:
Download: https://github.com/minetest-mods/frame/ ... master.zip
Code: https://github.com/minetest-mods/frame
License(s): LGPL-2.1+, CC-BY-SA-3.0, Public-Domain
The item frame will either display the items put in them (nodes or craftitems) as block (including separate top/bottom/side textures) or as flat image (but not wielditem view, just flat).
The trick is that just like the flowerpot, there's just one mesh node with 5 different materials, and depending on what you put in there, you get a node with those textures changed from transparent to the item textures.
The downside is extra nodes. But, extra nodes are a lot more efficient than entities.
The nodes store itemstack metadata and wear, so written books will remain written books, and tools with wear will come out with the wear back.
This probably needs more testing, and it's likely missing nodes and not working with some (e.g. nodes that capture rightclick wrong).
Crafting recipe:
Download: https://github.com/minetest-mods/frame/ ... master.zip
Code: https://github.com/minetest-mods/frame
License(s): LGPL-2.1+, CC-BY-SA-3.0, Public-Domain
- Hybrid Dog
- Member
- Posts: 2835
- Joined: Thu Nov 01, 2012 12:46
- GitHub: HybridDog
- azekill_DIABLO
- Member
- Posts: 7507
- Joined: Wed Oct 29, 2014 20:05
- GitHub: azekillDIABLO
- In-game: azekill_DIABLO
- Location: OMICRON
- Contact:
Re: [Mod]Frame - lag-free non-entity item frames![frame]
awesome! the fact this not 3d for items is not a problem at all!
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!
DMs are always open if you want to get in touch!
- D00Med
- Member
- Posts: 949
- Joined: Sat Feb 07, 2015 22:49
- GitHub: D00Med
- Location: Australia...somewhere
Re: [Mod]Frame - lag-free non-entity item frames![frame]
Is it really more efficient to make lots of nodes rather than a few entities that can swap their textures? (I ask this in a general sense, not specifically for itemframes)extra nodes are a lot more efficient than entities.
Look! I have a signature :]
My subgame: viewtopic.php?f=15&t=14051#p207242
My subgame: viewtopic.php?f=15&t=14051#p207242
Re: [Mod]Frame - lag-free non-entity item frames![frame]
entities have several major drawbacks:D00Med wrote:Is it really more efficient to make lots of nodes rather than a few entities that can swap their textures? (I ask this in a general sense, not specifically for itemframes)extra nodes are a lot more efficient than entities.
- they're as heavy on a server as players, and thus consume a lot of lua memory, generate lag, require on_step() callbacks etc.
- they can get lost. /clearobjects kills them
- they can get punched by players or killed (making them immortal prevents most of this, but still)
- they can get lost if the mapblock saving goes wrong
- they don't appear immediately when you enter an area, it could take forever for them to show up
- they require lots of extra code (fragile) to work around all these issues, and then still there are issues (just ask the itemframe mod makers that have made one before).
So yes, a few mode nodedefs is a far more efficient and reliable way to do this. It entirely avoids all the problems that entity based frames have. And the cost per node is not that large, since we're only adding one nodedef which compresses to a single network packet, and we don't use any new textures.
- D00Med
- Member
- Posts: 949
- Joined: Sat Feb 07, 2015 22:49
- GitHub: D00Med
- Location: Australia...somewhere
Re: [Mod]Frame - lag-free non-entity item frames![frame]
Ok then, thanks for the explanation.
Look! I have a signature :]
My subgame: viewtopic.php?f=15&t=14051#p207242
My subgame: viewtopic.php?f=15&t=14051#p207242
Re:
I've changed over to use this method, but somewhat different. I need an ItemStack table (not a string) to get the full metadata back with the new itemstack format, so I serialize it before storing it in nodemeta. This then allows me to get it back entirely.Hybrid Dog wrote:l think to keep toolwear, metadata, whatsoever, you could simply use stack:to_string() and save the result to meta.
strike that, that was not very thoughtful. I need to think some more to make the new item meta work well
- Wuzzy
- Member
- Posts: 4803
- Joined: Mon Sep 24, 2012 15:01
- GitHub: Wuzzy2
- IRC: Wuzzy
- In-game: Wuzzy
- Contact:
Re: [Mod]Frame - lag-free non-entity item frames![frame]
Lag-free itemframes sounds really cool, especially important for servers. It's annoying that the items are invisible unless you stand 2 cm in front of the item frame. xD
Having not tested it so far, does this work with boats, carts, water buckets, lava buckets, wheat seed and cotton seed from Minetest Game? Because other item frames fail for these items.
I'm not really happy how the flat items look like on the frame. I actually like the design of items “popping” out of the frame. But I fear that's the price we have to pay. :-/
On the other hand, is it really a good idea to avoid entities at all costs? Maybe the real fix should be done in the engine, by making entities more efficient, less laggy and less buggy in general.
EDIT:
No, sorry. This mod is no alternative for MineClone 2 so far. Support for items is way too limited, so I wouldn't even use it on a server either. A good item frame mod should support as many items as possible (ideally all of them).
Many items are not supported:
- The same grass drop bug as in your flowerpot mod
- Leaves are flat instead of cubic
- Placing a water source, lava source or river water source looks very weird. Probably because they're animated?
- The dropped item has a bad appearance (faces missing on the backside when it rotates)
Fun fact: The furnace is seen from the backside instead of the front. XD
EDIT 2:
For MineClone 2, I probably stick with the original mod for now. If you can find a way how to fix this rightclick issue, that would be a great help already.
Some suggestions:
- I would change the item name (“description” field) to “Item Frame”. This is the name which most players would recognize and understand. “Frame” sounds overly generic. Note: The mod name is OK.
- Add a inventory image. This also fixes the issue with the appearance of the dropped item
- Make the node wallmounted/attached (like a sign), so it doesn't float
- Make the node non-walkable, otherwise the player can use item frames to climb up walls. xD
- Use rightclick to make item pop out, intead of punching. I think this feels more natural. IMO I think rightclick should generally be seen as the “interaction” key by nodes, not punching, as this doesn't conflict with mining.
Having not tested it so far, does this work with boats, carts, water buckets, lava buckets, wheat seed and cotton seed from Minetest Game? Because other item frames fail for these items.
I'm not really happy how the flat items look like on the frame. I actually like the design of items “popping” out of the frame. But I fear that's the price we have to pay. :-/
On the other hand, is it really a good idea to avoid entities at all costs? Maybe the real fix should be done in the engine, by making entities more efficient, less laggy and less buggy in general.
EDIT:
No, sorry. This mod is no alternative for MineClone 2 so far. Support for items is way too limited, so I wouldn't even use it on a server either. A good item frame mod should support as many items as possible (ideally all of them).
Many items are not supported:
- Stairs
- Slabs
- Fences
- Fence Gates
- Beds
- Seeds
- Chests
- Flower pots from [flowerpot]
- Walls
- Iron bar and glasspane (xpanes)
- Cart
- Boat
- Key, Skeleton Key
- Screwdriver (rotates item frame instead)
- The same grass drop bug as in your flowerpot mod
- Leaves are flat instead of cubic
- Placing a water source, lava source or river water source looks very weird. Probably because they're animated?
- The dropped item has a bad appearance (faces missing on the backside when it rotates)
Fun fact: The furnace is seen from the backside instead of the front. XD
EDIT 2:
For MineClone 2, I probably stick with the original mod for now. If you can find a way how to fix this rightclick issue, that would be a great help already.
Some suggestions:
- I would change the item name (“description” field) to “Item Frame”. This is the name which most players would recognize and understand. “Frame” sounds overly generic. Note: The mod name is OK.
- Add a inventory image. This also fixes the issue with the appearance of the dropped item
- Make the node wallmounted/attached (like a sign), so it doesn't float
- Make the node non-walkable, otherwise the player can use item frames to climb up walls. xD
- Use rightclick to make item pop out, intead of punching. I think this feels more natural. IMO I think rightclick should generally be seen as the “interaction” key by nodes, not punching, as this doesn't conflict with mining.
Re: [Mod]Frame - lag-free non-entity item frames![frame]
You know, you write this in a fashion which is entirely demoralizing and fails to acknowledge all the work I do addressing concerns that people raise.No, sorry. This mod is no alternative for MineClone 2 so far. Support for items is way too limited, so I wouldn't even use it on a server either. A good item frame mod should support as many items as possible (ideally all of them).
Re: [Mod]Frame - lag-free non-entity item frames![frame]
you mean, that was an issue with other itemframe mods?Lag-free itemframes sounds really cool, especially important for servers. It's annoying that the items are invisible unless you stand 2 cm in front of the item frame. xD
This mod works with them just fine, but the boats and bed mods for instance do not properly propagate the on_rightclick to the node, so this is a minetest_game bug (which I obviously intend to fix).Having not tested it so far, does this work with boats, carts, water buckets, lava buckets, wheat seed and cotton seed from Minetest Game? Because other item frames fail for these items.
/giveme frame:boats_boat
I could fix this, but it would break 32px texture pack support and come at the cost of a *lot* of triangles (1500 or so for a 16px compatible frame, 12000 triangles for a 32px compatible one!). I'm not willing to do that just yet - maybe later.I'm not really happy how the flat items look like on the frame. I actually like the design of items “popping” out of the frame. But I fear that's the price we have to pay. :-/
While making entities more robust, they are always going to consume lua execution time and require globalstep maintenance.On the other hand, is it really a good idea to avoid entities at all costs? Maybe the real fix should be done in the engine, by making entities more efficient, less laggy and less buggy in general.
would require me to make another *mesh* to support those shapes. That means more modelling work, and at this time I don't think that it's reasonable. It also means even more registered nodes, I just don't think that's important right now (yet).Many items are not supported:
- Stairs
- Slabs
- Fences
- Fence Gates
- Walls
These work but all need mtg to be fixed (/giveme ..)[*]Beds
[*]Seeds
[*]Chests
[*]Cart
[*]Boat
[*]Key, Skeleton Key
Added, these were just forgotten (I'm fairly sure there's more I have not included yet)[*]Flower pots from [flowerpot]
[*]Iron bar and glasspane (xpanes)
half of these are bugs. Cart, boat are supported, but minetest_game doesn't pass the on_rightclick through, as I said above (and I will attempt to fix this)[*]Screwdriver (rotates item frame instead)[/list]
You don't want your itemframe rotated? I thought that was pretty neat that it could. Obviously shift-right click may be something we need to implement on some items.
I'll fix that up to stay in the spirit of minetest_gameBugs:
- The same grass drop bug as in your flowerpot mod
I can probably fix that- Leaves are flat instead of cubic
yes, the current texture selection algorithm doesn't handle it yet, but I think I can actually make it look like an animated water cube, except that the transparency would be an issue, so I'm not sure what I'll do with this.- Placing a water source, lava source or river water source looks very weird. Probably because they're animated?
Yes, and an inventory image is trivial, so this will be fixed in a sec.- The dropped item has a bad appearance (faces missing on the backside when it rotates)
spotted that, sadly the "front" texture is tile number 6, not 3. Yet more complex tile handling code coming.Fun fact: The furnace is seen from the backside instead of the front. XD
sure- I would change the item name (“description” field) to “Item Frame”. This is the name which most players would recognize and understand. “Frame” sounds overly generic. Note: The mod name is OK.
done, it's the same as the mesh texture anyway- Add a inventory image. This also fixes the issue with the appearance of the dropped item
I Can't make it attached_node, since then it can't hang on a wall. Making it wallmounted would make it not rotatable! I don't like either of these options. I agree it should fall if the node backing it disappears, but I don't see how I can do that without sacrificing something else yet.- Make the node wallmounted/attached (like a sign), so it doesn't float
This... I don't know. This is more of a personal taste thing if you ask me. For 99% of the time, the frames are probably going to be inside peoples houses as decoration, and this won't be a concern.- Make the node non-walkable, otherwise the player can use item frames to climb up walls. xD
This... I also don't know about. To me, digging means "getting something out" and right clicking means "putting something out/in". You didn't comment on this with the flowerpot, which also uses left/dig right/place controls, so I'm not convinced.- Use rightclick to make item pop out, intead of punching. I think this feels more natural. IMO I think rightclick should generally be seen as the “interaction” key by nodes, not punching, as this doesn't conflict with mining.
As usual, thanks for the review, this is really useful and I think I can address most of the comments really quickly.
Re: [Mod]Frame - lag-free non-entity item frames![frame]
FYI, If `meta set nodedef` ever makes it into minetest_game, It will solve so many issues that remain, and things like stairs, slabs, walls and fences become very reasonable to include in this mod.
https://github.com/minetest/minetest/pull/1118
Having that PR will allow me to use ONE node for all itemframes and vary mesh and tiles from metedata. Since at that point the amount of nodes drops to 3, 2 or even 1 total for all frames, it wouldn't be horrible to include 5-6 different meshes that capture all the other node shapes...
https://github.com/minetest/minetest/pull/1118
Having that PR will allow me to use ONE node for all itemframes and vary mesh and tiles from metedata. Since at that point the amount of nodes drops to 3, 2 or even 1 total for all frames, it wouldn't be horrible to include 5-6 different meshes that capture all the other node shapes...
Re: [Mod]Frame - lag-free non-entity item frames![frame]
https://github.com/minetest/minetest_game/pull/1563
Fix for minetest_game's issues with right click. I omitted the screwdriver, but this fixes boats, beds, seeds, carts and keys.
Fix for minetest_game's issues with right click. I omitted the screwdriver, but this fixes boats, beds, seeds, carts and keys.
- Wuzzy
- Member
- Posts: 4803
- Joined: Mon Sep 24, 2012 15:01
- GitHub: Wuzzy2
- IRC: Wuzzy
- In-game: Wuzzy
- Contact:
Re: [Mod]Frame - lag-free non-entity item frames![frame]
YES! This is definitely the right way to go. This issue is on my watchlist.FYI, If `meta set nodedef` ever makes it into minetest_game, It will solve so many issues that remain, and things like stairs, slabs, walls and fences become very reasonable to include in this mod.
I start to think that the real problem does not lie in the mod, but in Minetest which makes it very hard to make an item frame mod without rightclicking mess. meta set nodedef, and a fix for the rightclick stuff in the engine, then it's green light for item frames. :-)
Thx for taking your time, I posted a lenghty reply there.https://github.com/minetest/minetest_game/pull/1563
Fix for minetest_game's issues with right click. I omitted the screwdriver, but this fixes boats, beds, seeds, carts and keys.
Also thanks for all the other bugfixes and improvements so far. :-)
Oh boy. I haven't thought of this. Good points.I Can't make it attached_node, since then it can't hang on a wall. Making it wallmounted would make it not rotatable! I don't like either of these options. I agree it should fall if the node backing it disappears, but I don't see how I can do that without sacrificing something else yet.
Well, if screwdriver rotates an item frame on rightclick, then how do you put the screwdriver into the item frame?Screwdriver (rotates item frame instead)
half of these are bugs. Cart, boat are supported, but minetest_game doesn't pass the on_rightclick through, as I said above (and I will attempt to fix this)
You don't want your itemframe rotated? I thought that was pretty neat that it could. Obviously shift-right click may be something we need to implement on some items.
Shift-click seems like a solution on the surface, but too bad that shift-click is ALSO already used by the screwdriver. Boy, Minetest's controls are a mess! :D
Well, I already feared it would boil down to this. Entities are the answer to this, but then there's the lag issue again …Many items are not supported:
Stairs
Slabs
Fences
Fence Gates
Walls
would require me to make another *mesh* to support those shapes. That means more modelling work, and at this time I don't think that it's reasonable. It also means even more registered nodes, I just don't think that's important right now (yet).
What do you think about this idea? Making a mixed model. For flat or cube-shaped items, the current default meshes are used (and efficient), but for any other shape with no mesh, an entity is spawned. It's a trade-off between performance and trying to support as many items as possible.
I'm probably just talking crazy here. The real fix would be the new Lua API function (set meta nodedef). :-)
Re: [Mod]Frame - lag-free non-entity item frames![frame]
I actually ended up making it wallmounted+attached_node after all. We lose the screwdriver option but I prefer it popping off the wall.Oh boy. I haven't thought of this. Good points.I Can't make it attached_node, since then it can't hang on a wall. Making it wallmounted would make it not rotatable! I don't like either of these options. I agree it should fall if the node backing it disappears, but I don't see how I can do that without sacrificing something else yet.
Re: [Mod]Frame - lag-free non-entity item frames![frame]
So, from a practical point of view, the mod currently adds 251 nodes to the game (250 without flowerpot), and that's already outrageous (of course, they do look pretty good thus far).Wuzzy wrote:Well, I already feared it would boil down to this. Entities are the answer to this, but then there's the lag issue again …Many items are not supported:
Stairs
Slabs
Fences
Fence Gates
Walls
would require me to make another *mesh* to support those shapes. That means more modelling work, and at this time I don't think that it's reasonable. It also means even more registered nodes, I just don't think that's important right now (yet).
What do you think about this idea? Making a mixed model. For flat or cube-shaped items, the current default meshes are used (and efficient), but for any other shape with no mesh, an entity is spawned. It's a trade-off between performance and trying to support as many items as possible.
I'm probably just talking crazy here. The real fix would be the new Lua API function (set meta nodedef). :-)
But stairs and slabs would add another 52. 10 for fences, 3 walls. 5 gates. Plus it would need much more complex mesh nodes, and custom code to handle all of those.
Right now I can do 251 nodes in a single mesh (ok, maybe not 100% flawless), but it's extremely robust so far. I'd like to iron out the kinks before I add more meshes... I haven't heard from anyone yet who has actually deployed this or the flowerpot on a server, for instance.
- Wuzzy
- Member
- Posts: 4803
- Joined: Mon Sep 24, 2012 15:01
- GitHub: Wuzzy2
- IRC: Wuzzy
- In-game: Wuzzy
- Contact:
Re: [Mod]Frame - lag-free non-entity item frames![frame]
Right ...
I totally forgot that for every item, a new node would be needed, because of the textures. Which essentially doubles the number of nodes. Holy cow!
I guess I just wait until Minetest has some better Lua API support, then.
Thanks for your time anyway.
I totally forgot that for every item, a new node would be needed, because of the textures. Which essentially doubles the number of nodes. Holy cow!
I guess I just wait until Minetest has some better Lua API support, then.
Thanks for your time anyway.
Re: [Mod]Frame - lag-free non-entity item frames![frame]
Remember, even with 250 node registrations, this is still far more reliable and performant than entity based item frames :)Wuzzy wrote:Right ...
I totally forgot that for every item, a new node would be needed, because of the textures. Which essentially doubles the number of nodes. Holy cow!
I guess I just wait until Minetest has some better Lua API support, then.
Thanks for your time anyway.
-
- Member
- Posts: 4290
- Joined: Sun Sep 09, 2012 17:31
- GitHub: Sokomine
- IRC: Sokomine
- In-game: Sokomine
Re: [Mod]Frame - lag-free non-entity item frames![frame]
Thanks for the mod. Reducing the amount of entities will certainly help. Admittedly, the more 3dish appearance of the older itemframe mod also looks very good. Maybe they can be combined? Use your version for the cubic nodes and whatever gets displayed well and the old one for other drawtypes?sofar wrote: Remember, even with 250 node registrations, this is still far more reliable and performant than entity based item frames :)
There's also the smartshop mod that offers up to four items in a shop. Probably too many possible combinations for thsi approach? I didn't take a look at the implementation yet.
A list of my mods can be found here.
Re: [Mod]Frame - lag-free non-entity item frames![frame]
No, that view can currently only be obtained by using an entity to draw the "wieldmesh" appearance, and then you'd lose the benefit of the non-entity item frame entirely.Sokomine wrote:Thanks for the mod. Reducing the amount of entities will certainly help. Admittedly, the more 3dish appearance of the older itemframe mod also looks very good. Maybe they can be combined?
Once `node setmeta` is merged in core, that should be possible as well. With texture compositing, you could draw many nodes on a surface as long as it's smartly UV mapped and the texture string doesn't become too long.Sokomine wrote:Use your version for the cubic nodes and whatever gets displayed well and the old one for other drawtypes?
There's also the smartshop mod that offers up to four items in a shop. Probably too many possible combinations for thsi approach? I didn't take a look at the implementation yet.
-
- Member
- Posts: 818
- Joined: Tue Apr 14, 2015 01:59
- GitHub: raymoo
- IRC: Hijiri
- In-game: Raymoo + Clownpiece
Re: [Mod]Frame - lag-free non-entity item frames![frame]
From what I know about Minetest, Lua entity ticking just calls the on_step of every live lua entity. Wouldn't it be really cheap then (in terms of Lua execution time only) to have ten thousand entities with no on_step callbacks, since it just adds (a loop iteration + a few table accesses) times ten thousand, all in Lua?
I feel that at least for the case of inert (does no API calls or other expensive operations in on_step) entities, Lua execution time is not the bottleneck. A bigger issue might be the 16-bit entity ID.
EDIT: To reduce entity Lua cost even further, the code handling lua entities could keep a separate table for entities with non-nil on_step and only iterate on those. I don't think that is necessary though, because of my previous points.
I feel that at least for the case of inert (does no API calls or other expensive operations in on_step) entities, Lua execution time is not the bottleneck. A bigger issue might be the 16-bit entity ID.
EDIT: To reduce entity Lua cost even further, the code handling lua entities could keep a separate table for entities with non-nil on_step and only iterate on those. I don't think that is necessary though, because of my previous points.
Every time a mod API is left undocumented, a koala dies.
Re: [Mod]Frame - lag-free non-entity item frames![frame]
The engine still needs to render all the entities separately, whereas the nodes are part of the mapblock mesh, and are rendered as one big mesh.Byakuren wrote:From what I know about Minetest, Lua entity ticking just calls the on_step of every live lua entity. Wouldn't it be really cheap then (in terms of Lua execution time only) to have ten thousand entities with no on_step callbacks, since it just adds (a loop iteration + a few table accesses) times ten thousand, all in Lua?
So no matter what, nodes are far more efficient to render.
-
- Member
- Posts: 818
- Joined: Tue Apr 14, 2015 01:59
- GitHub: raymoo
- IRC: Hijiri
- In-game: Raymoo + Clownpiece
Re: [Mod]Frame - lag-free non-entity item frames![frame]
Alright, that makes sense. I was just responding to yoursofar wrote:The engine still needs to render all the entities separately, whereas the nodes are part of the mapblock mesh, and are rendered as one big mesh.Byakuren wrote:From what I know about Minetest, Lua entity ticking just calls the on_step of every live lua entity. Wouldn't it be really cheap then (in terms of Lua execution time only) to have ten thousand entities with no on_step callbacks, since it just adds (a loop iteration + a few table accesses) times ten thousand, all in Lua?
So no matter what, nodes are far more efficient to render.
Which was implied to be a reason that improving entities in the engine would not make it worth using entities for item frames.sofar wrote: While making entities more robust, they are always going to consume lua execution time and require globalstep maintenance.
Every time a mod API is left undocumented, a koala dies.
Re: [Mod]Frame - lag-free non-entity item frames![frame]
Firstly congrats with this mod, really nothing lags
Is it possible to make sword/picks etc at frame more "3d" (1px depth) like at usual frames?
___
frame texture from gif
Is it possible to make sword/picks etc at frame more "3d" (1px depth) like at usual frames?
___
frame texture from gif
Re: [Mod]Frame - lag-free non-entity item frames![frame]
yes, but you'd get back the lag again, because that can only be done by using entities again, which is what this mod avoids.bosapara wrote:Is it possible to make sword/picks etc at frame more "3d" (1px depth) like at usual frames?
Re: [Mod]Frame - lag-free non-entity item frames![frame]
understood, thanxsofar wrote:yes, but you'd get back the lag again, because that can only be done by using entities again, which is what this mod avoids.bosapara wrote:Is it possible to make sword/picks etc at frame more "3d" (1px depth) like at usual frames?
Who is online
Users browsing this forum: No registered users and 44 guests