mojira.dev
MC-150405

Client handling of unknown entity attributes is bugged

The client-side handler for entity attribute data currently has an error which will cause exceptions to be thrown in a situation where this is most likely not intended to happen.

Using MCP names, the relevant function is NetHandlerPlayClient.handleEntityProperties (handler for this client-bound packet), which has the following block of code:

IAttributeInstance iattributeinstance = abstractattributemap.getAttributeInstanceByName(spacketentityproperties$snapshot.getName());
if (iattributeinstance == null) {
   iattributeinstance = abstractattributemap.registerAttribute(new RangedAttribute((IAttribute)null, spacketentityproperties$snapshot.getName(), 0.0D, Double.MIN_NORMAL, Double.MAX_VALUE));
}
iattributeinstance.setBaseValue(spacketentityproperties$snapshot.getBaseValue());
iattributeinstance.removeAllModifiers();
for(AttributeModifier attributemodifier : spacketentityproperties$snapshot.getModifiers()) {
   iattributeinstance.applyModifier(attributemodifier);
}

While this appears to be intended to register a dummy attribute instance for any unknown attribute data recieved, the RangedAttribute created here is invalid and will cause an IllegalArgumentException to be thrown by the constructor:

else if (defaultValue < minimumValueIn) {
   throw new IllegalArgumentException("Default value cannot be lower than minimum value!");
}

This is because the minimum value specified is greater than the default of 0. The correct minimum value should probably be -Double.MAX_VALUE instead of Double.MIN_NORMAL, as negative values are allowed here (e.g. generic.luck).

Comments 2

Appears to have been an issue ever since the Entity Properties packet was added in 13w21a (1.6).

Looks to have been fixed in 20w14a; unknown attributes are now ignored with a warning message "Entity {} does not have attribute {}" instead of a default attribute being created.

Ben Staddon

(Unassigned)

Confirmed

Crash, Networking

attributes

Minecraft 1.14, Minecraft 1.14.2, 1.15.2, 20w12a

20w14a

Retrieved