package net.minecraft.server.level.progress;

import javax.annotation.Nullable;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.ChunkPos;
import java.util.concurrent.Executor;
import net.minecraft.util.thread.ProcessorMailbox;

public class ProcessorChunkProgressListener implements ChunkProgressListener {
    private final ChunkProgressListener delegate;
    private final ProcessorMailbox<Runnable> mailbox;
    
    public ProcessorChunkProgressListener(final ChunkProgressListener xm, final Executor executor) {
        this.delegate = xm;
        this.mailbox = ProcessorMailbox.create(executor, "progressListener");
    }
    
    @Override
    public void updateSpawnPos(final ChunkPos bjh) {
        this.mailbox.tell(() -> this.delegate.updateSpawnPos(bjh));
    }
    
    @Override
    public void onStatusChange(final ChunkPos bjh, @Nullable final ChunkStatus cae) {
        this.mailbox.tell(() -> this.delegate.onStatusChange(bjh, cae));
    }
    
    @Override
    public void stop() {
        this.mailbox.tell(this.delegate::stop);
    }
}
