Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-150405

Client handling of unknown entity attributes is bugged

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 20w14a
    • Minecraft 1.14, Minecraft 1.14.2, 1.15.2, 20w12a
    • Confirmed
    • Crash, Networking

      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).

            Unassigned Unassigned
            quadraxis Ben Staddon
            Votes:
            2 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: