Turrets on Valkyrein Skies ship causes lag(I already know how to fix)
Closed this issue · 5 comments
Issue Description:
OMT turrets cause lag when placed on Valkyrien Skies ship
What happens:
when there are more than 5 or 6 turrets placed on a Valkyrien Skies ship it causes extreme lag.
What you expected to happen:
I have already find the cause, which is basically this code
if (this.ticks % 5 == 0) {
this.getWorld().notifyBlockUpdate(this.pos, this.getWorld().getBlockState(pos), this.getWorld().getBlockState(pos), 3);
}
this.ticks++;
and
if (this.ticks % 5 == 0) {
this.getWorld().notifyBlockUpdate(this.pos, this.getWorld().getBlockState(pos), this.getWorld().getBlockState(pos), 3);
}
which are of line 158 and 180 in AbstractDirectedTurret class update() method. Simply reduce this update rate by 40 times would make the lag insignificant(at least for my computer it works). So I suggest just make (this.ticks % 5 == 0) configurable in config file, so that people can change the update rate slower depend on how good their computer is.
Steps to reproduce:
- Build a VS ship using Valkyrien Skies 1.0-alpha-1 mod
- put more than 6 turrets on that ship
Affected Versions (Do not use "latest"):
- OMT: 3.1.x VS compatible version(my last pull request)
- OMLib: omlib-1.12.2-3.1.3-246
- Minecraft: 1.12.2
- Forge: forge-1.12.2-14.23.5.2825
- SpongeForge? no
- Optifine? no
- Single Player and Server
Your most recent log file where the issue was present:
This is not needed since the cause of this issue is already known.
That sounds like an external bug, a simple notify shouldn't affect performance that so hard. I think this currently updates the rotation of the turret every 5 ticks. Gonna test what happens if I just comment that out.
Such a problem exists not only on OMT but also on my PlasmaCannon mod. I have tested the performance, I made it update every 200 ticks and the lag becomes insignificant. This has something to do with how Valkyrien Skies ship is coded, which is something different from vanilla minecraft. My suggestion is simply to make this update rate configurable and set 5 as default. In this way you don't have to worry about how VS is coded and it would hurt nothing.
OK, but if you wanna try something else you will need to talk with Triod aka thebest108 to come up with some ideas. Cause you need to know how VS ships do update().
Fixed via f4cdd7c