PaperMC / PaperMC/Paper

Can't remove entities during ChunkUnloadEvent

Open
#8,448 8 comments 0 reactions 1 assignee View on GitHub

@Spottedleaf is already working on this.

Since Oct 12, 2022.

status: accepted status: unlikely type: bug
Dominant language
Java
Stars
12.7k
Forks
3.5k
Avg merge
3d 13h
Merged PRs (30d)
11

Description

Expected behavior

When ChunkUnloadEvent is called, iterating through the entities and removing specific ones by calling that entity's .remove() method should delete it from the world and that would not be saved in the chunk.

Observed/Actual behavior

Entities are not removed, and appear again when the chunk loads.

Steps/models to reproduce

I created a testPlugin that had this listener to check the behaviour

    @EventHandler
    public void onChunkUnload(ChunkUnloadEvent event) {
        for (Entity e:event.getChunk().getEntities()) {
            this.getLogger().info("Removing Entity " + e.getUniqueId());
            e.remove();
        }
    }

Spawn & name some entities, let the chunk unload, reload the chunk, see entities haven't been removed.

Plugin and Datapack List

Only a test plugin to check this behaviour

Paper version

This server is running Paper version git-Paper-200 (MC: 1.19.2) (Implementing API version 1.19.2-R0.1-SNAPSHOT) (Git: c389b1c)
You are running the latest version
Previous version: git-Paper-173 (MC: 1.19.2)

Other

This seems to have started being an issue since the new chunk system, as it works as expected on build #173

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.