Conversation
…ockDisplay (#12) * chore: ignore local editor and tooling folders * build: add PacketEvents, JUnit 5 and Mockito dependencies * feat: add backend enum and centering anchor * feat: add display handle abstraction and paper handle * feat: add packet display state, sender interface and id allocator * refactor: back DisplayCrate with DisplayHandle * refactor: key registry by uuid and route transforms through handle * refactor: decouple animator from Bukkit entities * refactor: decouple physics engine from Bukkit entities * feat: add config and optional packet backend detection * feat: add PacketEvents sender and metadata codec * feat: add backend selection and viewers to builder * feat: wire packet backend and global viewer lifecycle * test: cover anchor offset semantics and id allocator * test: cover packet viewer lifecycle and paper handle * test: cover backend selection and registry cleanup * refactor: extract physics force integration * test: cover animation and physics on packet backend * feat: add paper, packet and offset demo commands * docs: document backends, viewers and coordinate behavior * fix: correct BDApi name in init error messages * fix: prevent packet entity id overflow into negatives * fix: warn when packet display spawns with no viewers
Add logo image and center alignment to README
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical and moderate issues remain in PacketEvents metadata, lifecycle, transforms, world handling, and backend configuration.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR adds optional PacketEvents support alongside Paper, expands display/viewer/transform handling, adds tests, and updates the README and documentation site.
Changes:
- Adds backend selection, packet display lifecycle, anchors, animations, and transforms.
- Adds backend, packet, physics, and animation tests.
- Updates build configuration, examples, generated documentation, and adds a custom 404 page.
File summaries
| File | Summary |
|---|---|
test-plugin/src/main/resources/plugin.yml |
Updates test-plugin commands and backend usage. |
test-plugin/src/main/java/fr/redsavant/Main.java |
Adds backend and transform demonstration commands. |
src/test/java/fr/redsavant/bdapi/support/RecordingPacketDisplaySender.java |
Adds a packet sender test double. |
src/test/java/fr/redsavant/bdapi/PhysicsStateTest.java |
Tests physics forces. |
src/test/java/fr/redsavant/bdapi/packet/PacketEntityIdAllocatorTest.java |
Tests packet entity ID allocation. |
src/test/java/fr/redsavant/bdapi/display/PaperDisplayHandleTest.java |
Tests Paper display handles. |
src/test/java/fr/redsavant/bdapi/display/PacketDisplayHandleTest.java |
Tests packet display handles. |
src/test/java/fr/redsavant/bdapi/display/AnchorTest.java |
Tests anchor compensation. |
src/test/java/fr/redsavant/bdapi/BackendSelectionTest.java |
Tests backend selection and cleanup. |
src/test/java/fr/redsavant/bdapi/AnimationBackendTest.java |
Tests backend animations. |
src/main/java/fr/redsavant/bdapi/transform/TransformHandle.java |
Provides direct transform operations. |
src/main/java/fr/redsavant/bdapi/packet/PacketEventsProbe.java |
Probes PacketEvents initialization. |
src/main/java/fr/redsavant/bdapi/packet/PacketEventsDisplaySender.java |
Sends display packets. |
src/main/java/fr/redsavant/bdapi/packet/PacketEntityIdAllocator.java |
Allocates fake entity IDs. |
src/main/java/fr/redsavant/bdapi/packet/PacketDisplaySender.java |
Defines packet sender operations. |
src/main/java/fr/redsavant/bdapi/packet/PacketDisplayMetadataCodec.java |
Encodes display metadata. |
src/main/java/fr/redsavant/bdapi/packet/PacketDisplayListener.java |
Handles packet display viewer lifecycle. |
src/main/java/fr/redsavant/bdapi/packet/PacketBackendSupport.java |
Detects PacketEvents support. |
src/main/java/fr/redsavant/bdapi/internal/PhysicsEngine.java |
Routes physics through display handles. |
src/main/java/fr/redsavant/bdapi/internal/DisplayRegistry.java |
Registers backend-independent displays. |
src/main/java/fr/redsavant/bdapi/internal/Animator.java |
Animates display handles. |
src/main/java/fr/redsavant/bdapi/internal/ActiveAnimation.java |
Stores animation state. |
src/main/java/fr/redsavant/bdapi/Displays.java |
Stores display backend services and configuration. |
src/main/java/fr/redsavant/bdapi/DisplayCrate.java |
Exposes backend-independent display operations. |
src/main/java/fr/redsavant/bdapi/display/PaperDisplayHandle.java |
Implements Paper displays. |
src/main/java/fr/redsavant/bdapi/display/PacketDisplayHandle.java |
Implements client-side displays. |
src/main/java/fr/redsavant/bdapi/display/DisplayHandle.java |
Defines the display handle contract. |
src/main/java/fr/redsavant/bdapi/display/DisplayBackend.java |
Defines supported backends. |
src/main/java/fr/redsavant/bdapi/display/Anchor.java |
Defines transform anchors. |
src/main/java/fr/redsavant/bdapi/builder/BlockDisplayBuilder.java |
Adds backend, viewer, and anchor configuration. |
src/main/java/fr/redsavant/bdapi/BDApiConfig.java |
Adds backend configuration. |
src/main/java/fr/redsavant/bdapi/BDApi.java |
Initializes backend services and listeners. |
src/main/java/fr/redsavant/bdapi/animation/AnimationBuilder.java |
Builds backend-independent animations. |
README.md |
Documents backends and usage. |
docs/markdown-examples.html |
Adds generated documentation examples. |
docs/mark.svg |
Adds documentation branding. |
docs/hashmap.json |
Adds generated page hashes. |
docs/assets/markdown-examples.md.BCG_9Bgl.lean.js |
Adds generated documentation assets. |
docs/assets/markdown-examples.md.BCG_9Bgl.js |
Adds generated documentation assets. |
docs/assets/index.md.BkF2v_em.lean.js |
Adds generated index assets. |
docs/assets/en_index.md.DqtUWZmL.lean.js |
Adds generated English index assets. |
docs/assets/chunks/VPLocalSearchBox.Curd1UgX.js |
Adds generated search assets. |
docs/assets/chunks/metadata.e00ad133.js |
Adds generated site metadata. |
docs/assets/chunks/@localSearchIndexroot.B-XFEoKZ.js |
Adds the root search index. |
docs/assets/chunks/@localSearchIndexen.DkdoG2EJ.js |
Adds the English search index. |
docs/assets/app.BRDBJunw.js |
Adds generated documentation app assets. |
docs/assets/api-examples.md.DBzYl0HB.lean.js |
Adds generated API documentation assets. |
docs/assets/api-examples.md.DBzYl0HB.js |
Adds generated API documentation assets. |
docs/api-examples.html |
Adds generated API documentation. |
docs/404.html |
Adds a custom documentation 404 page. |
build.gradle.kts |
Updates version and dependencies. |
.gitignore |
Ignores additional IDE files. |
Review details
Files not reviewed (12)
- docs/assets/api-examples.md.DBzYl0HB.js: Generated file
- docs/assets/api-examples.md.DBzYl0HB.lean.js: Generated file
- docs/assets/app.BRDBJunw.js: Generated file
- docs/assets/chunks/@localSearchIndexen.DkdoG2EJ.js: Generated file
- docs/assets/chunks/@localSearchIndexroot.B-XFEoKZ.js: Generated file
- docs/assets/chunks/VPLocalSearchBox.Curd1UgX.js: Generated file
- docs/assets/chunks/metadata.e00ad133.js: Generated file
- docs/assets/chunks/theme.8kX2sHLp.js: Generated file
- docs/assets/en_index.md.DqtUWZmL.js: Generated file
- docs/assets/en_index.md.DqtUWZmL.lean.js: Generated file
- docs/assets/index.md.BkF2v_em.js: Generated file
- docs/assets/index.md.BkF2v_em.lean.js: Generated file
Suppressed comments (8)
docs/en/index.html:26
- The published English documentation still renders
fr.redsavant:bdapi:1.0.0-beta.1, while this PR updates the README and project version to1.1.0-beta.1. Users following the documentation site will copy a stale dependency; regenerate the site output from the updated documentation source.
docs/index.html:26 - The published French documentation still renders
fr.redsavant:bdapi:1.0.0-beta.1, while this PR updates the README and project version to1.1.0-beta.1. Users following the documentation site will copy a stale dependency; regenerate the site output from the updated documentation source.
src/main/java/fr/redsavant/bdapi/builder/BlockDisplayBuilder.java:230 - Global packet entities are sent to every online player without checking
location.getWorld(). Spawn packets do not carry a dimension, so a viewer in another world can render this fake display at the same coordinates in their current world, unlike a Paper entity. Limit the initial send to viewers in the display's world and resynchronize when viewers change worlds.
src/main/java/fr/redsavant/bdapi/builder/BlockDisplayBuilder.java:226 - The packet handle receives only the material and transformation here, so the existing builder options for brightness, billboard, view range, and shadow are silently ignored by the PACKET_EVENTS backend; those same options are applied in
configure()for Paper. Encode the corresponding metadata or explicitly reject/document these options as unsupported for packet displays.
src/main/java/fr/redsavant/bdapi/internal/Animator.java:103 - This applies interpolated raw transformation values without reapplying the display's
Anchor. A defaultCENTERdisplay starts with compensated translation, soscaleToorrotateTointerpolates to an uncompensated endpoint and its visual center drifts, contrary to the documented anchor behavior. Carry the anchor into animations and compute compensation for each interpolated scale/rotation.
src/main/java/fr/redsavant/bdapi/packet/PacketDisplayMetadataCodec.java:50 - Every metadata update performs a fresh Bukkit block-data conversion here, even when only a transform changed. Animations invoke metadata updates every tick for each viewer, so this repeated conversion scales with displays × viewers × ticks unnecessarily. Cache the block-state ID or send block-state metadata only on spawn/material changes.
src/main/java/fr/redsavant/bdapi/packet/PacketEventsDisplaySender.java:43 EntityTeleportcarries coordinates but no dimension. If an animation or direct teleport moves a packet display to a differentWorld, this still sends the same-world teleport packet, leaving the fake entity in the wrong client world; reject cross-world moves or destroy and respawn the display for each viewer when the world changes.
test-plugin/src/main/resources/plugin.yml:8- The new packet test commands rely on PacketEvents being initialized before
Main.onEnable, but this plugin descriptor does not declare asoftdepend/load-order entry for it. If PacketEvents loads afterward,BDApi.initcaches no sender and/bdtest packetand/bdtest packetprivateremain unavailable; declare the optional dependency or defer backend initialization.
- Files reviewed: 42/75 changed files
- Comments generated: 8
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+40
to
+42
| if (packetSender != null) { | ||
| plugin.getServer().getPluginManager().registerEvents(new PacketDisplayListener(registry), plugin); | ||
| } |
Comment on lines
+49
to
+50
| if (PacketBackendSupport.available()) { | ||
| return PacketBackendSupport.createSender(); |
| @@ -90,8 +90,8 @@ public void play() { | |||
| Transformation endTransform = new Transformation(endTranslation, endRotation, endScale, new Quaternionf()); | |||
Comment on lines
+25
to
+29
| for (DisplayCrate crate : registry.all()) { | ||
| DisplayHandle handle = crate.handle(); | ||
| if (handle.global() && handle.backend() == fr.redsavant.bdapi.display.DisplayBackend.PACKET_EVENTS) { | ||
| handle.show(uuid); | ||
| } |
Comment on lines
+41
to
+45
| data.add(new EntityData<>(TRANSLATION, EntityDataTypes.VECTOR3F, new Vector3f(translation.x, translation.y, translation.z))); | ||
| data.add(new EntityData<>(SCALE, EntityDataTypes.VECTOR3F, new Vector3f(scale.x, scale.y, scale.z))); | ||
| data.add(new EntityData<>(LEFT_ROTATION, EntityDataTypes.QUATERNION, new Quaternion4f(left.x, left.y, left.z, left.w))); | ||
| data.add(new EntityData<>(RIGHT_ROTATION, EntityDataTypes.QUATERNION, new Quaternion4f(right.x, right.y, right.z, right.w))); | ||
| data.add(new EntityData<>(BLOCK_STATE, EntityDataTypes.BLOCK_STATE, blockStateId(display))); |
| } | ||
|
|
||
| public int next() { | ||
| return counter.updateAndGet(current -> current == Integer.MAX_VALUE ? base + 1 : current + 1); |
Comment on lines
+14
to
+16
| private final Vector3f translation = new Vector3f(0f, 0f, 0f); | ||
| private final Vector3f eulerRotation = new Vector3f(0f, 0f, 0f); | ||
| private Anchor anchor = Anchor.CENTER; |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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 updates the documentation to reflect new backend support and usage patterns in BDApi, and adds a custom 404 error page for the documentation site. The most important changes are grouped below.
Documentation updates for backend support and usage:
README.mdto document support for two backends (PAPERandPACKET_EVENTS), including configuration, per-display backend selection, per-player/global display visibility, and backend requirements. [1] [2] [3]1.1.0-beta.1and clarified requirements for PacketEvents. [1] [2]Documentation site improvement:
404.htmlpage for the documentation site to provide a branded not found page.