Inventory Tweaks [1.12 only]

Inventory Tweaks [1.12 only]

127M Downloads

Option to Slow Down Sorting

Opened this issue ยท 14 comments

commented

Minecraft Version: 1.10.2
Inventory Tweaks Version: 1.61
Forge Modloader Version: 8.0.99.99

Hello,
I installed this mod to use in a server - however, because sorting sends too many data packets, I flag the NoCheat plugin and get kicked out. Because of this, I propose that the mod adds an option to slow down sorting to, say, 2-3 moves per second. This would allow players to sort without getting kicked out.

commented

This relates to #417

Using it with 1.11, all of the sort options triggers it. It usually happens when you sort multiple chests at a time. But if you get kicked and login to sort a chest you get kicked, you need to wait a little while. It also happens when you ctrl + shift + click items, but not as often.

Now for a fix, you can add an option for interval / timeout in between sort requests. It would be in milliseconds. This would stop the kicking since you wont send a bunch of packets back to back as fast.

This is how I've handled it with personal Minecraft mods, as well as MMOs such as WoW/ESO that monitor packet sending rates.

Regarding locking up the client, as long as it is threaded it wont lock-up the client, you will need to ensure the player doesn't move while the sorting happens. Since the interval is in milliseconds it will still happen quickly from an end user perspective, and still be faster than a player manually moving items.

commented

It's not as simple as you'd think, especially since you aren't allowed to thread modifications to the inventory (you'll just cause loads of random CMEs)

The interval delay also needs to be relatively long, as most of the plugins a delay is designed to play well with enforce fairly strict limit (i.e., 20 operations a second), and the sorting code would take somewhere from 1-2 seconds to >15 seconds depending on the number of items with a sufficient delay.

I did build a system out to abstract the sorting from the actual state of the inventory ( https://github.com/Inventory-Tweaks/inventory-tweaks/blob/develop/src/main/java/invtweaks/container/IContainerManager.java ) so if you, or anyone else, feels like experimenting it's not hard to test your ideas.

commented

Unfortunately attempting to do that in the current setup doesn't work very well. (There was an old attempt at slowing it down, but it froze the client for a long time due to how it did the delay)

In theory a completed MirroredContainerManager could handle it properly as it would disconnect sorting from sending the packets, but I've been stuck trying to figure out how to efficiently do that.

commented

Durn. Still, thanks for replying! Not many other modders even addressed other issues I had.

commented

Good luck with the mirrored container I look forward to it

commented

Kobata, have you looked into if using Thread.yield() is a possibility to keep it from locking up the client?

commented

It's not on a separate thread, therefore any attempt to pause it must block the client from processing.

As pointed out above, moving it to a separate thread doesn't really help.

commented

I personally would gladly trade off a forced wait while sorting so I don't get repeatedly kicked from servers just for sorting my chests.

commented

Agreed, a forced wait would still be faster than sorting manually. Perhaps have the delay not set, but user set so it can be adjusted as well.

commented

Hi does the mod need to be server side for it to work

commented

yeah slower would be good.
i would be happy to even wait 30 seconds XD i'm terrible at sorting items XD
please do add this

commented

If possible can this be an option? I don't want to wait 30 secs to just sort my inventory and chests, I could do it myself in that time

commented
commented

Too many servers kick you because sorting sends packets too fast.