sleepylessons / NetherAnarchy

0 stars 0 forks source link

Entity culling to distinguish between item entity item/block ids #14

Open LjubkaLoona opened 3 years ago

LjubkaLoona commented 3 years ago

Afaik, currently entity culling applies equally to all item entities, with there being no way to distinguish between them.

Under some circumstance this causes problems for players (all secondhand information ive seen reported in the discord):
First, on dying with a nearly full inventory or near some item entities (e.g. dying while mining, dying near water streams that contain item entities, etc), the 36-item entity limit can be quite easily exceeded (a full inventory plus armor plus offhand and hotbar is 41). Sometimes this leads to valuable items being culled.

(Similarly, valuable item culling could also happen if for example a chest of valuables was broken by accident, though this is rarely reported.)

Secondly, next to farms that produce or use very significant number of item entities (that take some time to move to storage), it may be dangerous to drop valuable items near these - e.g. a large cactus farm or piglin bartering farm could seriously discourage players from placing shulkers down nearby, as they may be culled before they can be picked up after being broken.

Obviously item entities do contribute a lot to lag, and so while "raise limits a lot until nobody complains of these things anymore" is technically something that would prevent these things, it isn't feasible. Instead, a possible solution to prevent these kinds of complaints would be the ability for the plugin to distinguish between different item/block ids and prioritise which entities to cull based on those; or have different limits (distance and cap) able to be enforced for high-value and low-value categories (or any number of categories, each one containing some number of ids).

For example, if a player dies in an empty area with a suit of god armor and 37 stacks of netherrack, it would be preferable for five stacks of netherrack to always be chosen to be culled rather than having a chance to lose any of the pieces. Similarly, if a player breaks some shulker boxes next to a water stream containing 36 stacks of gold nuggets, the player would rather have no chance of the shulkers being chosen for culling before they can be picked up.

sleepylessons commented 3 years ago

I've been in direct contact with the developer of FarmLimiter, one of the most widely used entity culling plugins available.

He gave me access to the repository where he works on the plugin so that I could submit a PR to allow certain item types to be excluded from the item culling check.

We need to cull items because dropped item entities account for a huge portion of entity-related tick, and we have to reduce this to prevent lag.

I've submitted a Pull Request to the repo to allow certain item types to be excluded, however he has told me that he'd like to rework the fix slightly. I'm awaiting his changes.

Since we don't have infinite time to wait for him to do this, we're going to give him two weeks to make the updates he wants to make. If he doesn't, I'll deploy my fix as-is to our server and build a list of "important" items that should be excluded from the checks entirely. Then when his version of the fix is ready we'll deploy it.