Add entity ID management and player tracking methods#376
Merged
twisti-dev merged 2 commits intoJun 17, 2026
Conversation
- implement setId and getById methods for entity management - add removeAllTrackedEntities and removeAllTrackedPlayers methods for player tracking - update gradle.properties to version 3.24.0
Copilot stopped reviewing on behalf of
twisti-dev due to an error
June 17, 2026 20:02
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR extends the Paper NMS bridge API to support clearing entity tracking relationships for players and adds utilities to look up/set entities by numeric ID, with corresponding NMS implementations for v26.1 and v1.21.11.
Changes:
- Add
removeAllTrackedEntities/removeAllTrackedPlayerstoSurfPaperNmsPlayerBridgeand implement in v26.1 + v1.21.11. - Add
setId/getByIdtoSurfPaperNmsEntityBridgeand implement in v26.1 + v1.21.11. - Bump library version to
3.24.0and update the API dump.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| surf-api-paper/src/main/kotlin/dev/slne/surf/api/paper/nms/bridges/SurfPaperNmsPlayerBridge.kt | Exposes new player tracking-removal bridge methods. |
| surf-api-paper/src/main/kotlin/dev/slne/surf/api/paper/nms/bridges/SurfPaperNmsEntityBridge.kt | Exposes new entity ID manipulation/lookup bridge methods. |
| surf-api-paper/api/surf-api-paper.api | Captures the public API surface changes in the ABI dump. |
| surf-api-paper-nms-v26-1/.../V26_1SurfPaperNmsPlayerBridgeImpl.kt | Implements tracking-removal methods for v26.1. |
| surf-api-paper-nms-v26-1/.../V26_1SurfPaperNmsEntityBridgeImpl.kt | Implements entity ID methods for v26.1. |
| surf-api-paper-nms-v1-21-11/.../V1_21_11SurfPaperNmsPlayerBridgeImpl.kt | Implements tracking-removal methods for v1.21.11. |
| surf-api-paper-nms-v1-21-11/.../V1_21_11SurfPaperNmsEntityBridgeImpl.kt | Implements entity ID methods for v1.21.11. |
| gradle.properties | Bumps project version to 3.24.0. |
Comment on lines
+25
to
+26
| fun removeAllTrackedEntities(player: Player, swallowExceptions: Boolean = true) | ||
| fun removeAllTrackedPlayers(player: Player, swallowExceptions: Boolean = true) |
Comment on lines
+60
to
+61
| val distance = player.viewDistance.toDouble() | ||
| player.getNearbyEntities(distance, distance, distance).forEach { entity -> |
Comment on lines
+62
to
+85
| try { | ||
| entity.toNms().`moonrise$getTrackedEntity`().serverEntity.removePairing(nmsPlayer) | ||
| } catch (e: Throwable) { | ||
| if (!swallowExceptions) { | ||
| throw e | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| override fun removeAllTrackedPlayers(player: Player, swallowExceptions: Boolean) { | ||
| val nmsPlayer = player.toNms() | ||
| val trackedEntity = nmsPlayer.`moonrise$getTrackedEntity`() | ||
|
|
||
| for (otherPlayer in MinecraftServer.getServer().playerList.players) { | ||
| if (otherPlayer.uuid == nmsPlayer.uuid) continue | ||
| try { | ||
| trackedEntity.serverEntity.removePairing(otherPlayer) | ||
| } catch (e: Throwable) { | ||
| if (!swallowExceptions) { | ||
| throw e | ||
| } | ||
| } | ||
| } |
Comment on lines
+60
to
+61
| val distance = player.viewDistance.toDouble() | ||
| player.getNearbyEntities(distance, distance, distance).forEach { entity -> |
Comment on lines
+62
to
+85
| try { | ||
| entity.toNms().`moonrise$getTrackedEntity`().serverEntity.removePairing(nmsPlayer) | ||
| } catch (e: Throwable) { | ||
| if (!swallowExceptions) { | ||
| throw e | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| override fun removeAllTrackedPlayers(player: Player, swallowExceptions: Boolean) { | ||
| val nmsPlayer = player.toNms() | ||
| val trackedEntity = nmsPlayer.`moonrise$getTrackedEntity`() | ||
|
|
||
| for (otherPlayer in MinecraftServer.getServer().playerList.players) { | ||
| if (otherPlayer.uuid == nmsPlayer.uuid) continue | ||
| try { | ||
| trackedEntity.serverEntity.removePairing(otherPlayer) | ||
| } catch (e: Throwable) { | ||
| if (!swallowExceptions) { | ||
| throw e | ||
| } | ||
| } | ||
| } |
Comment on lines
+56
to
+62
| override fun setId(entity: Entity, id: Int) { | ||
| entity.toNms().id = id | ||
| } | ||
|
|
||
| override fun getById(world: World, id: Int): Entity? { | ||
| return world.toNms().getEntity(id)?.bukkitEntity | ||
| } |
Comment on lines
+55
to
+61
| override fun setId(entity: Entity, id: Int) { | ||
| entity.toNms().id = id | ||
| } | ||
|
|
||
| override fun getById(world: World, id: Int): Entity? { | ||
| return world.toNms().getEntity(id)?.bukkitEntity | ||
| } |
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.
This pull request introduces new methods to the NMS bridge interfaces and their implementations, enhancing entity and player tracking control and access. The main focus is on adding functionality for manipulating entity IDs and managing tracked entities/players, along with the necessary API and implementation updates for Minecraft 1.21.1 and 1.26.1.
API Additions and Interface Changes
setIdandgetByIdmethods to theSurfPaperNmsEntityBridgeinterface, allowing setting an entity's internal ID and retrieving an entity by ID within a world. [1] [2]removeAllTrackedEntitiesandremoveAllTrackedPlayersmethods to theSurfPaperNmsPlayerBridgeinterface, enabling the removal of all tracked entities or players for a given player, with an option to swallow exceptions. [1] [2]Implementation Updates
setIdandgetByIdmethods in bothV1_21_11SurfPaperNmsEntityBridgeImplandV26_1SurfPaperNmsEntityBridgeImpl. [1] [2]removeAllTrackedEntitiesandremoveAllTrackedPlayersmethods in bothV1_21_11SurfPaperNmsPlayerBridgeImplandV26_1SurfPaperNmsPlayerBridgeImpl. [1] [2]Versioning
3.23.1to3.24.0ingradle.properties.