Sodium

Sodium

44M Downloads

Optimize chests rendering

Kir-Antipov opened this issue · 3 comments

commented

Is your feature request related to a problem? Please describe.

Hello there! I'm one of those players, who tries to obtain as many resources as possible, so at the moment I have a small storage with 6000 chests chilling around. And there's the problem: something about chests causes enormous lag (350 fps drops to 20-30 near my storage system).

At first, I didn't even think that the main reason could be the chests, and blamed hoppers, but then I held an investigation and realized that it was in fact them. Firstly, I removed every chest in a creative copy of my world from the storage, and the number of frames per second went up to 200. Then I came across the section Block entities and their render limits in an article about block entities at Minecraft Wiki.

Some block entities (e.g., chest), or their effects, stop being rendered beyond a hard-coded block limit which is modeled after the radius of a sphere. This limit is not affected by Render Distance nor the Entity Distance scale in the Video Settings.

Seems like somebody realized that they had coded something terrible and tried to make it not that bad by hardcoding this "optimization".

I went curios, so I made an empty world, selected a zone of 20x20x20 (8000) blocks and started playing around with the fill command. Here're some results (the numbers will be different for different hardware, they're provided solely in order to demonstrate the scale of the problem):

  • air (well, empty world, nothing else): 400 fps
  • chest: 15-20 fps
  • trapped chest: 15-20 fps
  • ender chest: 10 fps
  • shulker box: 15-20 fps
  • head: 20 fps
  • sign: 20 fps
  • end portal: 1-5 fps
  • hopper: 250-300 fps
  • cake: 380-400 fps
  • barrel: 350-400 fps

As you can see, every block mentioned in "Block entities that stop rendering beyond 64 blocks" section, causes a lot of lag.

I checked cakes to make sure that rendering blocks that have a different hitbox than a regular block doesn't cause problems during render.

And also I checked hoppers, since one would expect performance issues from them (not because of their rendering, but because of the logic of their work, since each tick hoppers try to transfer an item, thereby causing additional load on server). As strange as it may seem, but a block that performs calculations every game tick causes less lag than a chest that just stands still... Don't know what about you, but I find it hilarious ¯\(ツ)

hopper vs chest

It is unlikely that someone will place thousands of ender chests, heads, signs etc in one place, but a couple of thousand chests is a simple and practical task for any technical player. So it would be great if their render could be optimized. And since Sodium specializes in this kind of things, I decided to open the issue here


Describe the solution you'd like

I want to apologize in advance for using wrong terminology or incorrectly describing some processes, but I have zero knowledge of the inside of the Minecraft rendering engine.

Based on this article, chests are most likely solid entities, which is where this whole laggy part comes from. I hope that it's possible to change the type of their render, turning them into regular blocks, such as a barrel. Yep, we will definitely lose the chest opening animation, but when it comes to losing 95% FPS, this is definitely something to sacrifice.


Describe alternatives you've considered

If what I've just described is impossible, maybe just add an option that disables chests rendering? :D

commented

There is a mod (that shall not be named) that optimises chests but removes the animation. It is not recommended to use that mod.

There is another mod called EnhancedBlockEntities (takes a bit of work getting it to work with sodium, but it is not too hard), which optimises chests (and bells, signs, etc.) without removing animations and stuff. It works just as well, and does not remove animations, which is a bonus. I recommend this mod.

Although it is true that Sodium does not 100% stick to vanilla behaviour (e.g. transparency issues), it does not compromise vanilla features for the sake of more fps. Because of this, I believe that disabling chest rendering is out of the scope of sodium.

commented

There is a mod (that shall not be named) that optimises chests but removes the animation. It is not recommended to use that mod

Well, I don't know which mod you are talking about anyway :D


There is another mod called EnhancedBlockEntities

Thanks! Will try it in a moment


Although it is true that Sodium does not 100% stick to vanilla behaviour (e.g. transparency issues), it does not compromise vanilla features for the sake of more fps. Because of this, I believe that disabling chest rendering is out of the scope of sodium.

This option was more like a joke. Also, if EnhancedBlockEntities does work, I'll just close the issue, 'cause there's no need to increase the code base, which needs to be maintained, when someone else is already doing it :)

commented

For anyone who will stumble upon this issue: EnhancedBlockEntities works like a charm, no need to ask for the same feature in Sodium :)

@DragonEggBedrockBreaking, thanks a lot!