-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Optimize Hoppers - Closes #392 #976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| + } else if (ihopper instanceof EntityMinecartHopper) { | ||
| + ((EntityMinecartHopper) ihopper).setCooldown(ihopper.getWorld().spigotConfig.hopperTransfer / 2); | ||
| + } | ||
| + return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to self, change this to true. false causes this code to be ran for every item. but because we are mode 2, we know item is not going to change the fact this event was cancelled.
return true in mode 0 too. i was originally concerned it would block plugins who want to cancel first and allow 2nd, but the same cant be said for push mode, so we can just make them consistent, and greatly improve performance of cancelled pulls.
45a51e5 to
d8597ab
Compare
|
This looks interesting! |
d8597ab to
3e735af
Compare
|
Exciting, found ways to do these optimizations always without any mode setting, greatly reducing diff and should keep things super safe with plugins. |
|
I have uploaded a paperclip patcher for this patch to <outdated, see Z's link below> I would love to get feedback from users with bad hopper timings who use protection plugins or other hopper related plugins. I'm more interested in knowing that behavior isn't broken than I am about performance, but if you can get a before and after timings/profiler results, that would be good too. |
3e735af to
aabc698
Compare
|
I personally would like a mode 0 or 1 toggle at the very least so I can just ignore/effectively eliminate the event regardless if plugins use it but I guess the best way to go about that is to do something similar to eliminating use of PlayerChatEvent. |
|
@RoboMWM There was a config added for that. |
aabc698 to
6b5ee41
Compare
|
Updated patch to be on top of the latest Paper as of today (with my Cat Hopper Performance fix too) Updated configs to be under the existing hopper. section fixed bug with suck in code not returning false for item not found, and also fixed it to respect the cooldown if full setting. This should be good to go now, need testers. |
|
Re: hoppers picking up dropped items... Items still enter blocked hoppers given hoppers: Push-based true |
|
@aikar Is there any easy way to apply your patch on top of the latest paper jar? I tried compiling upstream with your PR merged but am running into issues with the decompile script during compilation. I ran a timings profile recently and noticed the majority of my tick impact was coming from InventoryMoveItemEvent by two plugins (WorldGuard / ChestShop). I could probably be used as a helpful test candidate to see how much improvement is made with your optimization patch. |
|
This patch applied to latest (1322) |
|
So far early timing indication shows a massive improvement to hopper performance in my environment. I do not notice InventoryMoveItemEvent in the timings profile whatsoever. I will report back later today with a new timings report during around peak hour at the same time as the earlier report. |
|
@mibby behavior wise, does things still function as expected? IE WorldGuard / chestshop able to block restricted hopper access, etc? If so, then we will be good to merge this! |
|
@aikar I believe so. I created a ChestShop shop for testing and couldn't move items out via a hopper. Protecting a chest via LWC, couldn't move items out via hopper unless flagged to do so. Hoppers can move items out of normal chests like vanilla behavior just fine. Unsure how to test hoppers with WorldGuard since there is no protection flag for it. I assume it is also working fine as intended since the above does. New timings with no noticeable impact from InventoryMoveItemEvent. However I doubt the same problem chunks that initially caused the load are presently loaded in this timings, but at first glance, greatly improved performance. |
|
Items can't get into the hopper through a soil with this optimization.
|
|
@ArtNRG what do you mean through a soil? This change doesn't alter hopper suck in mechanics, it impacts the Bukkit Event. Try with push-based disabled, as that is not related to this PR. |
6b5ee41 to
cb2d5bb
Compare
- Lots of itemstack cloning removed. Only clone if the item is actually moved - Return true when a plugin cancels inventory move item event instead of false, as false causes pulls to cycle through all items. However, pushes do not exhibit the same behavior, so this is not something plugins could of been relying on. - Add option (Default on) to cooldown hoppers when they fail to move an item due to full inventory - Skip subsequent InventoryMoveItemEvents if a plugin does not use the item after first event fire for an iteration
cb2d5bb to
094bb03
Compare
Optimize Hoppers
However, pushes do not exhibit the same behavior, so this is not something plugins could of been relying on.
Closes #392