Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Add ChunkStatusChangeEvent

Open Cryptite opened this issue 2 years ago • 3 comments

Chunk Statuses are a wily thing, but it is nice to know when the state of one changes for concept like lazy-loading, etc.

I'm not sure this event should ever be anything other than read-only but this basic version has worked well for me for awhile.

Cryptite avatar Nov 08 '23 15:11 Cryptite

The event is fired incorrectly. The chunk system changes the chunk status incrementally, and carefully handles concurrent requests to lower it. It is possible that the overall result of the operation is to lower the status, even if initially it was requested to be higher. You can see this by how the function updateCurrentState works.

You should look more carefully at the operations done in each status change to determine where to place the event. In general this area of code is the worst part of the chunk system and needs to be refactored, so it may not be possible to actually place an event in there without causing issues.

Spottedleaf avatar Nov 08 '23 17:11 Spottedleaf

The event is fired incorrectly. The chunk system changes the chunk status incrementally, and carefully handles concurrent requests to lower it. It is possible that the overall result of the operation is to lower the status, even if initially it was requested to be higher. You can see this by how the function updateCurrentState works.

You should look more carefully at the operations done in each status change to determine where to place the event. In general this area of code is the worst part of the chunk system and needs to be refactored, so it may not be possible to actually place an event in there without causing issues.

I do see lower in handleFullStatusChange() that nextState is captured for subsequent potential status changes. Might be sufficient to just lower the event to after that that nextState.isOrAfter(currState) check? nextState isn't even used in that method otherwise...

Cryptite avatar Nov 08 '23 18:11 Cryptite

Hello, does any change are needed for this before being merged ? If yes, i can take time to do it.

rayanbzd avatar Nov 23 '24 18:11 rayanbzd