public static HeadHitboxDefault get(Class<? extends EntityLivingBase> entityClass) { if (entityClass == null) return HeadHitboxDefault.MASTER_DEFAULT; HeadHitboxDefault hitbox; HeadHitboxDefault closestHitbox = null; Class closestClass = EntityLivingBase.class; for (int i = 0; i < HeadHitboxDefault.DEFAULT_HEAD_HITBOXES.size(); i++) { hitbox = HeadHitboxDefault.DEFAULT_HEAD_HITBOXES.get(i); if (closestClass.isAssignableFrom(hitbox.entityClass) && hitbox.entityClass.isAssignableFrom(entityClass)) { closestClass = hitbox.entityClass; closestHitbox = hitbox; } } return closestHitbox; }
/** * API method to add custom default hitboxes. * * @param entityClass The entity class to add the custom default for (also applies to classes * extending this one) * @return The added default hitbox object */ public static HeadHitboxDefault add( Class entityClass, float scale, float childScale, float[] size, float[] offset, float headDamage, float bodyDamage, float headMultiplier, float bodyMultiplier) { HeadHitboxDefault hitbox = new HeadHitboxDefault( scale, childScale, size, offset, headDamage, bodyDamage, headMultiplier, bodyMultiplier); hitbox.entityClass = entityClass; HeadHitboxDefault.DEFAULT_HEAD_HITBOXES.add(hitbox); return hitbox; }
public static HeadHitboxDefault add(Class entityClass, HeadHitboxDefault hitbox) { hitbox.entityClass = entityClass; HeadHitboxDefault.DEFAULT_HEAD_HITBOXES.add(hitbox); return hitbox; }