Skip to content

Adding chunk serialization events#9990

Closed
derverdox wants to merge 2 commits into
PaperMC:masterfrom
derverdox:feature/chunk_serialization_events
Closed

Adding chunk serialization events#9990
derverdox wants to merge 2 commits into
PaperMC:masterfrom
derverdox:feature/chunk_serialization_events

Conversation

@derverdox
Copy link
Copy Markdown

This patch adds new Chunk events that are called during the serialization / generation process of chunks.
A problem some developers may face while using the ChunkLoad or ChunkUnload events is the fact that they are called synchronously.
These proposed events are called during the process.

The use case of such events is that heavy saving / loading tasks from cache to the chunk nbt container or vice versa are executed asynchronously aswell but in the same thread
that saves / loads / generates the chunk.

@derverdox derverdox requested a review from a team as a code owner November 30, 2023 13:10
Comment thread patches/server/1055-Adding-ChunkSerialization-and-Generation-events.patch Outdated
+
+ @Nullable
+ public Chunk getChunk() {
+ return this.chunk;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should get docs as to when the chunk is null or not null

+import org.jetbrains.annotations.Nullable;
+
+public abstract class ChunkDataEvent extends Event {
+ private static final HandlerList handlers = new HandlerList();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uppercase name for static final fields

+ */
+public class ChunkDeserializeEvent extends ChunkDataEvent {
+ private static final HandlerList handlers = new HandlerList();
+ public ChunkDeserializeEvent(@NotNull final World world, @Nullable final Chunk chunk, final int chunkX, final int chunkZ, @NotNull final PersistentDataContainer chunkPersistentDataContainer) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra line between the field and constructor

Comment on lines +15 to +17
+ // Paper start - add ChunkDataEvents
+ toSerialize = ChunkSerializer.saveChunk(this.world, this.chunk, this.asyncSaveData, false);
+ // Paper end - add ChunkDataEvents
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Single line changes just get a // Paper - ... comment at the end of the line

import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.meta.BookMeta;
+import org.bukkit.persistence.PersistentDataContainer;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Especially in this class it's going to be ugly, but please remove the added imports and instead fully qualify them when used in code to reduce diff

@kennytv kennytv added the pre-softspoon: never rebased Pre-hardfork pull requests that were not re-opened with the new main branch label Mar 23, 2025
@kennytv kennytv deleted the branch PaperMC:master March 23, 2025 19:15
@kennytv kennytv closed this Mar 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pre-softspoon: never rebased Pre-hardfork pull requests that were not re-opened with the new main branch pre-softspoon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants