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
Modified despawnEntity() in EntityLiving to allow forge event to be called in all ticks #5150
Modified despawnEntity() in EntityLiving to allow forge event to be called in all ticks #5150
Conversation
…ed every tick, not just every 32nd one.
Can someone tell me what next steps are for getting a pull request put in? Thanks. |
Any use case @MrChoke72? I fail to see one. P.S. It was added in 6da6e9d |
The use case is we are incapable of modifying default behavior as it relates to distance checks for despawn. Example 1, the 128 block away forced despawn. Example 2, the 32 block away random check for despawn. We can override idleTime to affect that varaible but that is it. With this fix, we can. So the link you gave, is that coming in 1.13? I don't think its quite the same fix though is it? P.S. I see you are modding Railcraft. Never heard of it but I am going check that mod out! |
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.
After another glance, this 31 tick check is not necessary at all, because with this check mods can never prevent vanilla behaviors.
That commit was an old one when the event was added |
Exactly. So I just removed the 31 tick check. Maybe it was there for performance but I don't think its that critical. So how do pull requests work exactly? Are you admin type that can merge it in? |
I am not an admin. You are supposed to wait very patiently over a period of time (may be over one month). At the time for batch merging, LexManos will either point out issues with your code or merge it if this pr appears fine. By the way, you can go to forge discord to ask for reviews, too. Sometimes, mezz will come to review your pull request before Lexmanos does. |
Ok, thanks. |
This will not go in with this event firing every tick. The limiter was added for performance reasons. |
I just want to say that after this With the tick check limit, mods cannot override vanilla behavior. The vanilla behavior may let the mob despawn before the mod listening to the event could have made a choice. |
I am not sure how else I can explain it. If the despawn handler is not called every tick then whatever you do in it is overridden by the very next tick. My example is that of extending the 128 block distance for a mob to automatically despawn. You cannot do it. Let's say your event handler fires and returns DENY when the distance just exceeded 128. On the very next tick the default handler is going to fire and the mob is gone. And it is IMPOSSIBLE to stop it given the current design. It makes LivingSpawnEvent.AllowDespawn only partially usable. If you don't believe this happens, try it out. I assure you it does. As far as performance, yes I understand why it is there. But to remove it is just part of what modders have to juggle all the time in their mods. Do not write slow code when its executed often (i.e. every tick). |
Could we make it so that returning DENY causes the despawn to be delayed 32 ticks. |
(I am the author of the pull, MrChoke72, on my work GIT), That is a great solution. As long as the event handler is given the opportunity to run BEFORE the default behavior that will work. @LexManos, how about this? A DENY will force no execution of the event handler OR the default behavior for 32 ticks. I can implement this and do a new pull. |
Modified despawnEntity() to allow forge AllowDespawn event to be called every tick, not just every 32nd one.
This is a fix to issues #4485 (closed) and #5148