Add air bubble UI support
This commit translates entity metadata ID 1 into the AIR entity metadata.
@@ -98,7 +98,7 @@ public class Entity {
metadata.put(EntityData.SCALE, 1f);
metadata.put(EntityData.COLOR, 0);
- metadata.put(EntityData.MAX_AIR, (short) 400);
+ metadata.put(EntityData.MAX_AIR, (short) 300);
metadata.put(EntityData.AIR, (short) 0);
metadata.put(EntityData.LEAD_HOLDER_EID, -1L);
metadata.put(EntityData.BOUNDING_BOX_HEIGHT, entityType.getHeight());
@@ -242,6 +242,13 @@ public class Entity {
}
}
break;
+ case 1: // Air/bubbles
+ if ((int) entityMetadata.getValue() == 300) {
+ metadata.put(EntityData.AIR, (short) 0); // Otherwise the bubble counter remains in the UI
+ } else {
+ metadata.put(EntityData.AIR, (short) (int) entityMetadata.getValue());
+ }
+ break;
case 2: // custom name
TextMessage name = (TextMessage) entityMetadata.getValue();
if (name != null)
