Skip to content

Add entity ID management and player tracking methods#376

Merged
twisti-dev merged 2 commits into
version/26.1from
feat/entity-id-and-player-tracking-bridges
Jun 17, 2026
Merged

Add entity ID management and player tracking methods#376
twisti-dev merged 2 commits into
version/26.1from
feat/entity-id-and-player-tracking-bridges

Conversation

@twisti-dev

Copy link
Copy Markdown
Contributor

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

  • Added setId and getById methods to the SurfPaperNmsEntityBridge interface, allowing setting an entity's internal ID and retrieving an entity by ID within a world. [1] [2]
  • Added removeAllTrackedEntities and removeAllTrackedPlayers methods to the SurfPaperNmsPlayerBridge interface, enabling the removal of all tracked entities or players for a given player, with an option to swallow exceptions. [1] [2]

Implementation Updates

  • Implemented the new setId and getById methods in both V1_21_11SurfPaperNmsEntityBridgeImpl and V26_1SurfPaperNmsEntityBridgeImpl. [1] [2]
  • Implemented the new removeAllTrackedEntities and removeAllTrackedPlayers methods in both V1_21_11SurfPaperNmsPlayerBridgeImpl and V26_1SurfPaperNmsPlayerBridgeImpl. [1] [2]

Versioning

  • Bumped the project version from 3.23.1 to 3.24.0 in gradle.properties.

- implement setId and getById methods for entity management
- add removeAllTrackedEntities and removeAllTrackedPlayers methods for player tracking
- update gradle.properties to version 3.24.0
@twisti-dev twisti-dev self-assigned this Jun 17, 2026
Copilot AI review requested due to automatic review settings June 17, 2026 20:01
@twisti-dev twisti-dev merged commit 3a095ee into version/26.1 Jun 17, 2026
0 of 3 checks passed
@twisti-dev twisti-dev deleted the feat/entity-id-and-player-tracking-bridges branch June 17, 2026 20:02
Copilot stopped reviewing on behalf of twisti-dev due to an error June 17, 2026 20:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 / removeAllTrackedPlayers to SurfPaperNmsPlayerBridge and implement in v26.1 + v1.21.11.
  • Add setId / getById to SurfPaperNmsEntityBridge and implement in v26.1 + v1.21.11.
  • Bump library version to 3.24.0 and 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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants