Tetra

Tetra

12M Downloads

Block Look Trigger Causing Lag Spike

Raycoms opened this issue ยท 6 comments

commented

Bug Report

The BlockLookTrigger in

public void onPlayerTick(TickEvent.PlayerTickEvent event) {

Seems to be causing lag spikes, even though it only happens once a second.
I wonder if there are better ways to solve this. (For example checking via a chunkcapability).

Minimal setup needed to reproduce

commented

I've hardcoded the length of the raytrace (used to base it on the reach attribute to match the block outline, but that's not neccessary) and I've added a config option for disabling the trigger all together if the problem still persists.

Might also be that there's a fake player somewhere in an unloaded chunk that somehow gets ticked? But that shouldn't happen, right?

"Fix" is in 3.4.0.

commented

I was thinking about this. Why don't you hook into this on the client side? There is already code for that on the client side to render collision boxes etc. So, the only thing you'd have to do is detect this, send a message to the server, server checks if the block really exists at this position on the server -> done

commented

Since it's triggering the advancement for all of the players at the same time it's probably quite heavy when there are many players online.

I think the proper-est way of doing it would be to fix my worldgen to use proper structures and then use the location criteron to check if a player is in a ruin.

Was there a lot of players online when you noticed the spikes? If so I could change it to only run the trigger for one player at a time, that would be easy to set up!

commented

Not a whole lot tbf, around 6 as far as I know.

commented

I don't know how the location criterion handles it (since it's mojang based I assume it might be super laggy). What I'd do is mark the chunk capability of the chunk it is in, and store the y height into it. Then on chunk entry, you check the chunk cap for this (super cheap) and calc if the player is on a similar y pos.

commented
	at net.minecraft.world.server.ServerChunkProvider.handler$zbi000$onChunkLoadDebug(SourceFile:1136) ~[?:?]
	at net.minecraft.world.server.ServerChunkProvider.func_217233_c(SourceFile:221) ~[?:?]
	at net.minecraft.world.server.ServerChunkProvider.func_212849_a_(SourceFile:140) ~[?:?]
	at net.minecraft.world.World.func_217353_a(World.java:167) ~[?:?]
	at net.minecraft.world.IWorldReader.func_217348_a(IWorldReader.java:112) ~[?:?]
	at net.minecraft.world.World.func_212866_a_(World.java:163) ~[?:?]
	at net.minecraft.world.World.func_180495_p(World.java:379) ~[?:?]
	at net.minecraft.world.IBlockReader.lambda$rayTraceBlocks$0(IBlockReader.java:46) ~[?:?]
	at net.minecraft.world.IBlockReader.func_217300_a(IBlockReader.java:142) ~[?:?]
	at net.minecraft.world.IBlockReader.func_217299_a(IBlockReader.java:45) ~[?:?]
	at se.mickelus.tetra.advancements.BlockLookTrigger.onPlayerTick(BlockLookTrigger.java:47) ~[tetra:3.3.1]

Apparently the look trigger is loading chunks which is causing the lag spikes