Feat: server-side dolphins grace to match speed increase#6172
Feat: server-side dolphins grace to match speed increase#6172onebeastchris wants to merge 1 commit intoGeyserMC:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds initial support for server-sent Dolphin’s Grace by synchronizing a Bedrock movement-related attribute when the Java effect is applied/removed, including during dimension switches.
Changes:
- Update Bedrock player attributes when Java Dolphin’s Grace is applied (update effect translator).
- Revert the attribute when Dolphin’s Grace is removed (remove effect translator) and when clearing effects during dimension switches.
- Introduce new attribute types to support underwater/lava movement attribute updates.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| core/src/main/java/org/geysermc/geyser/util/DimensionUtils.java | Sends an attribute update when Dolphin’s Grace is cleared during dimension switching. |
| core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/JavaUpdateMobEffectTranslator.java | Triggers an underwater movement attribute update when Dolphin’s Grace is applied. |
| core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/JavaRemoveMobEffectTranslator.java | Reverts the underwater movement attribute when Dolphin’s Grace is removed. |
| core/src/main/java/org/geysermc/geyser/entity/type/player/SessionPlayerEntity.java | Adds a helper to toggle the Bedrock underwater movement attribute for Dolphin’s Grace. |
| core/src/main/java/org/geysermc/geyser/entity/attribute/GeyserAttributeType.java | Adds attribute enum entries needed to represent underwater/lava movement attributes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| LAVA_MOVEMENT(null, "minecraft:lava_movement", 0f, 3.4028235E38f, 0.02f), | ||
| UNDERWATER_MOVEMENT(null, "minecraft:underwater_movement", 0f, 3.4028235E38f, 0.02f); |
There was a problem hiding this comment.
LAVA_MOVEMENT and UNDERWATER_MOVEMENT use a hard-coded float literal (3.4028235E38f) for the maximum value. Elsewhere in this enum (e.g., ATTACK_KNOCKBACK) Float.MAX_VALUE is used; using the constant here would improve readability and reduce the chance of typos or inconsistencies.
| LAVA_MOVEMENT(null, "minecraft:lava_movement", 0f, 3.4028235E38f, 0.02f), | |
| UNDERWATER_MOVEMENT(null, "minecraft:underwater_movement", 0f, 3.4028235E38f, 0.02f); | |
| LAVA_MOVEMENT(null, "minecraft:lava_movement", 0f, Float.MAX_VALUE, 0.02f), | |
| UNDERWATER_MOVEMENT(null, "minecraft:underwater_movement", 0f, Float.MAX_VALUE, 0.02f); |
| public AttributeData updateDolphinsGrace(boolean value) { | ||
| AttributeData data = GeyserAttributeType.UNDERWATER_MOVEMENT.getAttribute(value ? 0.024f : 0.02f); |
There was a problem hiding this comment.
updateDolphinsGrace hard-codes both the “off” value (0.02f) and the “on” value (0.024f). Consider deriving the “off” value from GeyserAttributeType.UNDERWATER_MOVEMENT.getDefaultValue() (to avoid drift if the default changes) and extracting the “on” multiplier/value into a named constant with a short rationale (magic numbers are hard to validate/maintain).
| public AttributeData updateDolphinsGrace(boolean value) { | |
| AttributeData data = GeyserAttributeType.UNDERWATER_MOVEMENT.getAttribute(value ? 0.024f : 0.02f); | |
| /** | |
| * Multiplier applied to the default underwater movement speed when Dolphin's Grace is active. | |
| * 1.2x corresponds to Java's Dolphin's Grace movement speed increase. | |
| */ | |
| private static final float DOLPHINS_GRACE_UNDERWATER_SPEED_MULTIPLIER = 1.2f; | |
| public AttributeData updateDolphinsGrace(boolean value) { | |
| float baseUnderwaterMovement = (float) GeyserAttributeType.UNDERWATER_MOVEMENT.getDefaultValue(); | |
| float underwaterMovement = value | |
| ? baseUnderwaterMovement * DOLPHINS_GRACE_UNDERWATER_SPEED_MULTIPLIER | |
| : baseUnderwaterMovement; | |
| AttributeData data = GeyserAttributeType.UNDERWATER_MOVEMENT.getAttribute(underwaterMovement); |
No description provided.