Skip to content

ChunkSaveEvent

Package: com.hypixel.hytale.server.core.universe.world.events.ecs Extends: CancellableEcsEvent Implements: ICancellableEcsEvent Cancellable: Yes

ECS event dispatched when a chunk is being saved to storage. Cancelling this event prevents the chunk from being saved.

FieldTypeAccessorMutableNullable
chunkWorldChunkgetChunk()NoNo
  • chunk — The world chunk being saved.
  • ChunkSavingSystems.save (lines 76, 95) via componentAccessor.invoke(event) — ECS dispatch when a chunk is being saved (two call sites — different save paths).

ECS events are handled by EntityEventSystem subclasses, not by getEventRegistry().register(). Chunk events operate on the ChunkStore pipeline, not EntityStore.

public class MyChunkSaveHandler extends EntityEventSystem<ChunkStore, ChunkSaveEvent> {
@Override
public Query<ChunkStore> getQuery() {
return MY_COMPONENT_TYPE;
}
@Override
public void handle(int index, ArchetypeChunk<ChunkStore> chunk,
Store<ChunkStore> store, CommandBuffer<ChunkStore> commandBuffer,
ChunkSaveEvent event) {
WorldChunk worldChunk = event.getChunk();
// Example: skip saving empty chunks
if (isChunkEmpty(worldChunk)) {
event.setCancelled(true);
}
}
}
// Register in plugin setup():
getChunkStoreRegistry().registerSystem(new MyChunkSaveHandler());
  • ChunkUnloadEvent — Fired when a chunk is being unloaded from memory. May occur after a save.