Default value for the movement_speed attribute is not correct
Expected behavior
Setting the players movement_speed attribute to its built-in default value should properly reset the players movement_speed attribute to ~0.1
Observed/Actual behavior
Setting the players movement_speed attribute to its built-in default value sets it to 0.7, instead of ~0.1
Steps/models to reproduce
@EventHandler
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
AttributeInstance attribute = player.getAttribute(Attribute.MOVEMENT_SPEED);
if (attribute == null) return;
attribute.setBaseValue(attribute.getDefaultValue());
player.sendRichMessage("Movement speed reset");
}
The code above executes when a player joins and will reset their base movement_speed attribute to its default value. But instead, it sets the players base movement_speed to 0.7
I tested this with every other attribute and their true default value is equal to that of the getDefaultValue function, except for movement_speed.
Plugin and Datapack List
A custom plugin with the code above
Paper version
This server is running Paper version 1.21.10-115-main@af06383 (2025-11-21T23:42:01Z) (Implementing API version 1.21.10-R0.1-SNAPSHOT) You are running the latest version Previous version: 1.21.10-113-9fc21bc (MC: 1.21.10)
Other
No response
This is WAI, but I think some improvement may be possible. AttributeInstance#getDefaultValue returns the server's default value for the attribute rather than any entity overrides it may have, this is specified in the javadoc and is where the 0.7 comes from. The current intended way to get the default for a specific entity type is to use EntityType#getDefaultAttributes, which does return 0.1 for players.
I think this could be made a whole lot more intuitive if a getDefaultValue method existed on the attribute interface and a nullable method on AttributeInstance that returns the entity's default value, or alternatively the docs for the existing method could be adjusted to mention the getDefaultAttributes method, depending on what others prefer.
I think some changes should really be taken here. It's too confusing.
I think some changes are really needed here. The attributes api in general seems a bit confusing with the available docs, especially considering that:
AttributeInstance defaultInstance = EntityType.PLAYER.getDefaultAttributes().getAttribute(Attribute.MOVEMENT_SPEED);
defaultInstance.getBaseValue(); // Correctly returns 0.1
defaultInstance.getDefaultValue(); // Incorrectly returns 0.7 again
Unless I'm using this incorrectly, the getDefaultValue method seems a little unnecessary atm.
The issue here is that the default value for the movement_speed attribute is 0.7, the entity attribute builder stuff does support setting the base value when the attribute is created which is why it returns 0.1 there