Use LeafPile and correct threading - #63
Merged
Merged
Conversation
…nnected so that engine threads ticking the object don't break
…s it is after the play-phase join packet. This also requires guarding for null world in engine
…ed from netty thread only so it can be a fastutil map
Contributor
There was a problem hiding this comment.
Pull request overview
This PR integrates the LeafPile submodule and updates the threading model around player/entity tracking so that more packet-state work is done on the Netty side, while the engine performs visibility checks using entity references rather than repeated UUID lookups.
Changes:
- Add LeafPile as a submodule/module and wire it into Gradle builds + shading/relocation.
- Rework player registration/disconnect flow to be driven by PacketEvents login/disconnect, and adjust Paper join handling accordingly.
- Introduce new iteration APIs for entity/tile-entity visibility checks and swap in LeafPile concurrency primitives / thread guards.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
settings.gradle |
Adds a version catalog sourced from leafpile and includes the new leafpile module. |
platform-paper/src/main/resources/plugin.yml |
Bumps declared Paper API version. |
platform-paper/src/main/java/games/cubi/raycastedantiesp/paper/EventListener.java |
Switches join handling to PlayerClientLoadedWorldEvent and changes behavior when packet state isn’t registered. |
platform-paper/src/main/java/games/cubi/raycastedantiesp/paper/commands/RaycastedAntiESPCommand.java |
Enhances debug benchmark output (counts successful raycasts). |
platform-paper/build.gradle.kts |
Updates Paper bundle version; adds LeafPile dependency; shades/relocates ca.spottedleaf and enables minimization. |
packetevents/src/main/java/games/cubi/raycastedantiesp/packetevents/viewcontrollers/PacketEventsEntityViewController.java |
Registers/unregisters players via JOIN_GAME and UserDisconnectEvent; refactors login handling. |
packetevents/src/main/java/games/cubi/raycastedantiesp/packetevents/viewcontrollers/PacketEventsBlockViewController.java |
Adjusts tile-entity transition processing safety checks. |
packetevents/src/main/java/games/cubi/raycastedantiesp/packetevents/view/PacketEventsEntityView.java |
Replaces CHM/CLQ with LeafPile structures, adds single-thread guarding, and adds entity-reference iteration. |
packetevents/build.gradle.kts |
Adds LeafPile as a compileOnly dependency. |
core/src/main/java/games/cubi/raycastedantiesp/core/view/EntityView.java |
Adds entity-reference iteration API for recheck scanning. |
core/src/main/java/games/cubi/raycastedantiesp/core/view/controller/PacketEntityViewController.java |
Moves player registration to play-phase login and centralizes disconnect handling. |
core/src/main/java/games/cubi/raycastedantiesp/core/view/BlockView.java |
Adds VisibilityResolver + new tile-entity visibility update iteration API. |
core/src/main/java/games/cubi/raycastedantiesp/core/view/AbstractBlockView.java |
Uses LeafPile queue and implements new tile-entity visibility update API. |
core/src/main/java/games/cubi/raycastedantiesp/core/utils/SingleThreadedGuard.java |
Introduces a reusable single-thread enforcement helper. |
core/src/main/java/games/cubi/raycastedantiesp/core/players/PlayerRegistry.java |
Refactors registration to include self-entity creation; changes disconnect cleanup semantics. |
core/src/main/java/games/cubi/raycastedantiesp/core/players/PlayerData.java |
Adds connected/disconnected state and constructs NettyData with a required self-entity. |
core/src/main/java/games/cubi/raycastedantiesp/core/players/NettyData.java |
Makes self-entity immutable post-construction and simplifies self-ID checks. |
core/src/main/java/games/cubi/raycastedantiesp/core/locatables/NettyEntityLocatable.java |
Adds offset-location getter and strengthens cross-thread field visibility (volatile). |
core/src/main/java/games/cubi/raycastedantiesp/core/locatables/EntityLocatable.java |
Adds getOffsetEntityLocation() to support engine-side raycast targets. |
core/src/main/java/games/cubi/raycastedantiesp/core/engine/SimpleEngine.java |
Skips disconnected players; uses entity references + offset locations; updates tile-entity visibility flow. |
core/build.gradle.kts |
Adds LeafPile compileOnly and bumps core version. |
.gitmodules |
Adds the LeafPile submodule definition. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
253
to
257
| private PacketEventsEntity getTrackedEntity(int entityID) { | ||
| guardThread(); | ||
| UUID entityUUID = entityUUIDsByID.get(entityID); | ||
| return entityUUID == null ? null : entitiesByUUID.get(entityUUID); | ||
| } |
Owner
Author
There was a problem hiding this comment.
Pending broader refactor to fix this
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.