Skip to content
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

Optimize anti beacon to not deadlock worldgen or lag entities #2334

Merged
merged 2 commits into from
Dec 11, 2023

Conversation

TelepathicGrunt
Copy link
Contributor

@TelepathicGrunt TelepathicGrunt commented Oct 25, 2023

resolves #2269 (hopefully)

This works by having caps on living entities that the closest active anti beacon will save its own position into. Then when entities gets an effect, they only need to check the position to see if close enough, anti beacon is still there, and anti beacon is unpowered. Much much much less intensive in modpacks than block scan on every effect add (and these effect scans could load ungenerated chunks too for more lag). Many mods and datapacks expect effect add to be fast and block scans can be problematic. Some tries to add effects every few ticks to refresh the effect timer and so forth. This is when block scans can really start to add up.

We basically move the heavy lifting from entities into antibeacon and antibeacon does entity scan which is much faster than block scan too and wont load ungenerated chunks.

Also added is a check to make sure chunk is fully generated to prevent a deadlock if entity is being spawned by worldgen and given an effect right away. And I noticed the tick field in the block entity was never decremented so the effect clearing that anti beacons do wasn't actually working.

@TelepathicGrunt TelepathicGrunt changed the title Optimize anti beacon to not lag worldgen and entities Optimize anti beacon to not deadlock worldgen or lag entities Oct 25, 2023
@Lothrazar
Copy link
Owner

oh hey this looks amazing! ill take a look this weekend and try to pull it in.

quick question do you think this LivingEntityCapProvider type system would also work if later i tried to backport this to mc1.18 or even 1.16.5 ?

@Lothrazar Lothrazar self-assigned this Nov 29, 2023
@TelepathicGrunt
Copy link
Contributor Author

I don’t think caps changed that much so it should work the same in older Mc versions. At the core, caps it just attaching data to entities and reading it back so even if cap code changed a bit in older forge, the concept is still the same

@Lothrazar Lothrazar merged commit bb665d8 into Lothrazar:trunk/1.20 Dec 11, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants