BeaconDeactivatedEvent called during chunk unloads
Open
Nobody has claimed this yet.
status: accepted
version: 1.21.11
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 3.5k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 11
Description
java.lang.IllegalStateException: Cannot update ticket level while unloading chunks or updating entity manager
at io.papermc.paper.chunk.system.scheduling.ChunkHolderManager.processTicketUpdates(ChunkHolderManager.java:932) ~[paper-1.19.2.jar:git-Paper-307]
at io.papermc.paper.chunk.system.scheduling.ChunkHolderManager.processTicketUpdates(ChunkHolderManager.java:919) ~[paper-1.19.2.jar:git-Paper-307]
at io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.scheduleTickingState(ChunkTaskScheduler.java:293) ~[paper-1.19.2.jar:git-Paper-307]
at io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.scheduleChunkLoad(ChunkTaskScheduler.java:399) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.level.ServerChunkCache.getChunkFutureMainThread(ServerChunkCache.java:533) ~[?:?]
at net.minecraft.server.level.ServerChunkCache.getChunk(ServerChunkCache.java:440) ~[?:?]
at net.minecraft.world.level.Level.getChunk(Level.java:502) ~[?:?]
at net.minecraft.world.level.Level.getBlockState(Level.java:780) ~[?:?]
at org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock.getType(CraftBlock.java:227) ~[paper-1.19.2.jar:git-Paper-307]
at io.papermc.paper.event.block.BeaconDeactivatedEvent.getBeacon(BeaconDeactivatedEvent.java:30) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at com.togiko.minecraft.plugins.beaconPlugin.events.ModifiedBeacon.onBeaconDeactivate(ModifiedBeacon.java:95) ~[minecraft-beacon-plugin-1.0.0.jar:?]
at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor4.execute(Unknown Source) ~[?:?]
at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:77) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:git-Paper-307]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:670) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.event.Event.callEvent(Event.java:45) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at net.minecraft.world.level.block.entity.BeaconBlockEntity.setRemoved(BeaconBlockEntity.java:281) ~[?:?]
at java.util.HashMap$Values.forEach(HashMap.java:1065) ~[?:?]
at net.minecraft.world.level.chunk.LevelChunk.clearAllBlockEntities(LevelChunk.java:1156) ~[?:?]
at net.minecraft.server.level.ServerLevel.unload(ServerLevel.java:1520) ~[?:?]
at io.papermc.paper.chunk.system.scheduling.NewChunkHolder.unloadStage2(NewChunkHolder.java:821) ~[paper-1.19.2.jar:git-Paper-307]
at io.papermc.paper.chunk.system.scheduling.ChunkHolderManager.processUnloads(ChunkHolderManager.java:874) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.level.ChunkMap.processUnloads(ChunkMap.java:630) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.level.ChunkMap.tick(ChunkMap.java:618) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.level.ServerChunkCache.tick(ServerChunkCache.java:654) ~[?:?]
at net.minecraft.server.level.ServerLevel.tick(ServerLevel.java:686) ~[?:?]
at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1535) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:446) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1397) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1173) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:305) ~[paper-1.19.2.jar:git-Paper-307]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
@EventHandler
public void onBeaconDeactivate(BeaconDeactivatedEvent event) {
Main.log("deactivated beacon: " + event);
Beacon beacon = event.getBeacon();
if (beacon == null) {
Block block = event.getBlock();
if (block.getType().equals(Material.BEACON)) {
beacon = (Beacon) block.getState();
....
}
Created issue manually because templates suck for this; but, this event should probably be improved so that it's not firing during chunk unload
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with io/papermc/paper/event/block/BeaconDeactivatedEvent.java and the BeaconBlockEntity.setRemoved call shown in the stack trace, then trace how chunk unloads reach LevelChunk.clearAllBlockEntities. Determine the intended event behavior during unload and add coverage for the unload path, with completion defined by avoiding the ticket-level exception while preserving normal beacon deactivation behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100